From 3b9815bd8ad723445128ae99883be0072ae389a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Wed, 12 Jun 2024 10:45:11 +0200 Subject: core: Allow setting import options when importing keys * src/context.h (struct gpgme_context): New field import_options. * src/engine-backend.h (struct engine_ops): Add arg import_options to field 'import'. * src/engine-gpg.c (gpg_import): Add arg import_options and pass option --import-options with argument value to gpg. * src/engine-gpgsm.c (gpgsm_import): Add dummy arg import_options. * src/engine.c (_gpgme_engine_op_import): Add arg import_options and pass option to import function of engine. * src/engine.h (_gpgme_engine_op_import): Add arg import_options. * src/gpgme.c (gpgme_release): Free 'import_options'. (gpgme_set_ctx_flag, gpgme_get_ctx_flag): New flag "import-options". * src/import.c (_gpgme_op_import_start, _gpgme_op_import_keys_start, _gpgme_op_receive_keys_start): Pass import options stored in context to _gpgme_engine_op_import. * tests/run-import.c (show_usage, main): Add option --import-options. -- This makes the --import-options option available in the GPGME API for key imports. GnuPG-bug-id: 7152 --- src/gpgme.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gpgme.c') diff --git a/src/gpgme.c b/src/gpgme.c index 135a75a7..f6d7f38d 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -261,6 +261,7 @@ gpgme_release (gpgme_ctx_t ctx) free (ctx->cert_expire); free (ctx->key_origin); free (ctx->import_filter); + free (ctx->import_options); _gpgme_engine_info_release (ctx->engine_info); ctx->engine_info = NULL; DESTROY_LOCK (ctx->lock); @@ -607,6 +608,13 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value) if (!ctx->import_filter) err = gpg_error_from_syserror (); } + else if (!strcmp (name, "import-options")) + { + free (ctx->import_options); + ctx->import_options = strdup (value); + if (!ctx->import_options) + err = gpg_error_from_syserror (); + } else if (!strcmp (name, "no-auto-check-trustdb")) { ctx->no_auto_check_trustdb = abool; @@ -692,6 +700,10 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name) { return ctx->import_filter? ctx->import_filter : ""; } + else if (!strcmp (name, "import-options")) + { + return ctx->import_options? ctx->import_options : ""; + } else if (!strcmp (name, "no-auto-check-trustdb")) { return ctx->no_auto_check_trustdb? "1":""; -- cgit v1.2.3