From b2a2158384a9f048ff61ee0cebef8346055f0454 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 16 Mar 2022 16:19:50 +0900 Subject: [PATCH] core: Support keylist mode for op_keylist_from_data. * src/engine-backend.h (keylist_data): Add MODE argument. * src/engine-gpg.c (gpg_keylist_data): Add MODE argument. * src/engine.c (_gpgme_engine_op_keylist_data): Likewise. * src/engine.h (_gpgme_engine_op_keylist_data): Declaration. * src/keylist.c (gpgme_op_keylist_from_data_start): Call _gpgme_engine_op_keylist_data with ctx->keylist_mode. -- GnuPG-bug-id: 5438 Signed-off-by: NIIBE Yutaka --- src/engine-backend.h | 3 ++- src/engine-gpg.c | 5 ++++- src/engine.c | 5 +++-- src/engine.h | 1 + src/keylist.c | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/engine-backend.h b/src/engine-backend.h index 9b755a32..75ed49cd 100644 --- a/src/engine-backend.h +++ b/src/engine-backend.h @@ -106,7 +106,8 @@ struct engine_ops int secret_only, int reserved, gpgme_keylist_mode_t mode, int engine_flags); - gpgme_error_t (*keylist_data) (void *engine, gpgme_data_t data); + gpgme_error_t (*keylist_data) (void *engine, gpgme_keylist_mode_t mode, + gpgme_data_t data); gpgme_error_t (*keysign) (void *engine, gpgme_key_t key, const char *userid, unsigned long expires, unsigned int flags, diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 88a248d2..6528e3d5 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -3179,7 +3179,7 @@ gpg_keylist_ext (void *engine, const char *pattern[], int secret_only, static gpgme_error_t -gpg_keylist_data (void *engine, gpgme_data_t data) +gpg_keylist_data (void *engine, gpgme_keylist_mode_t mode, gpgme_data_t data) { engine_gpg_t gpg = engine; gpgme_error_t err; @@ -3198,6 +3198,9 @@ gpg_keylist_data (void *engine, gpgme_data_t data) err = add_arg (gpg, "--dry-run"); if (!err) err = add_arg (gpg, "--import"); + if (!err && (mode & GPGME_KEYLIST_MODE_SIGS) + && have_gpg_version (gpg, "2.0.10")) + err = add_arg (gpg, "--with-sig-check"); if (!err) err = add_arg (gpg, "--"); if (!err) diff --git a/src/engine.c b/src/engine.c index db594cb8..895b7e1a 100644 --- a/src/engine.c +++ b/src/engine.c @@ -897,7 +897,8 @@ _gpgme_engine_op_keylist_ext (engine_t engine, const char *pattern[], gpgme_error_t -_gpgme_engine_op_keylist_data (engine_t engine, gpgme_data_t data) +_gpgme_engine_op_keylist_data (engine_t engine, gpgme_keylist_mode_t mode, + gpgme_data_t data) { if (!engine) return gpg_error (GPG_ERR_INV_VALUE); @@ -905,7 +906,7 @@ _gpgme_engine_op_keylist_data (engine_t engine, gpgme_data_t data) if (!engine->ops->keylist_data) return gpg_error (GPG_ERR_NOT_IMPLEMENTED); - return (*engine->ops->keylist_data) (engine->engine, data); + return (*engine->ops->keylist_data) (engine->engine, mode, data); } diff --git a/src/engine.h b/src/engine.h index 8b45e13a..d580d997 100644 --- a/src/engine.h +++ b/src/engine.h @@ -157,6 +157,7 @@ gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine, gpgme_keylist_mode_t mode, int engine_flags); gpgme_error_t _gpgme_engine_op_keylist_data (engine_t engine, + gpgme_keylist_mode_t mode, gpgme_data_t data); gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in, gpgme_data_t out, gpgme_sig_mode_t mode, diff --git a/src/keylist.c b/src/keylist.c index f2c90d20..883d6257 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -1216,7 +1216,7 @@ gpgme_op_keylist_from_data_start (gpgme_ctx_t ctx, gpgme_data_t data, if (err) return TRACE_ERR (err); - err = _gpgme_engine_op_keylist_data (ctx->engine, data); + err = _gpgme_engine_op_keylist_data (ctx->engine, ctx->keylist_mode, data); return TRACE_ERR (err); }