diff options
author | Ingo Klöcker <[email protected]> | 2021-12-13 15:52:23 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2021-12-13 15:52:23 +0000 |
commit | 60880adafa93e1a1e8e9fecf03c14d56bbd55345 (patch) | |
tree | 881579c7b75cbaaa800224eb981e6c15e15b4b9e /src/gpgme.c | |
parent | doc: Fix a few errors in the documentation of gpgme_op_import_* (diff) | |
download | gpgme-60880adafa93e1a1e8e9fecf03c14d56bbd55345.tar.gz gpgme-60880adafa93e1a1e8e9fecf03c14d56bbd55345.zip |
core: Allow specifiying a key origin when importing keys
* src/context.h (struct gpgme_context): New field key_origin.
* src/engine-backend.h (struct engine_ops): Add arg key_origin to
field 'import'.
* src/engine-gpg.c (gpg_import): Add arg key_origin and pass option
--key-origin with argument value to gpg. Adjust all callers.
* src/engine-gpgsm.c (gpgsm_import): Add dummy arg key_origin.
* src/gpgme.c (gpgme_release): Free 'key_origin'.
(gpgme_set_ctx_flag, gpgme_get_ctx_flag): New flag "key-origin".
* tests/run-import.c (main): Add option --key-origin.
* tests/gpg/t-import.c (main): Set and verify key origin.
--
This makes the --key-origin option available in the GPGME API for
key imports.
GnuPG-bug-id: 5733
Diffstat (limited to 'src/gpgme.c')
-rw-r--r-- | src/gpgme.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gpgme.c b/src/gpgme.c index 255d1165..2703cd72 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -254,6 +254,7 @@ gpgme_release (gpgme_ctx_t ctx) free (ctx->auto_key_locate); free (ctx->trust_model); free (ctx->cert_expire); + free (ctx->key_origin); _gpgme_engine_info_release (ctx->engine_info); ctx->engine_info = NULL; DESTROY_LOCK (ctx->lock); @@ -586,6 +587,13 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value) if (!ctx->cert_expire) err = gpg_error_from_syserror (); } + else if (!strcmp (name, "key-origin")) + { + free (ctx->key_origin); + ctx->key_origin = strdup (value); + if (!ctx->key_origin) + err = gpg_error_from_syserror (); + } else err = gpg_error (GPG_ERR_UNKNOWN_NAME); @@ -659,6 +667,10 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name) { return ctx->cert_expire? ctx->cert_expire : ""; } + else if (!strcmp (name, "key-origin")) + { + return ctx->key_origin? ctx->key_origin : ""; + } else return NULL; } |