Add ctx flag for auto-key-locate
* src/context.h (gpgme_context): Add auto_key_locate. * src/engine-gpg.c (engine_gpg): Add auto_key_locate. (gpg_set_engine_flags, build_argv): Handle auto_key_locate. (gpg_release): Free auto_key_locate. * src/gpgme.c (gpgme_release): Free auto_key_locate. (gpgme_get_ctx_flag, gpgme_set_ctx_flag): Handle auto-key-locate. * doc/gpgme.texi: Document auto-key-locate flag. * tests/run-keylist.c (show_usage, main): Add --from-wkd option. -- This enables users of GPGME to control more fine grained what auto-key-locate does. Especially for WKD lookups / refreshes can this be useful. GnuPG-Bug-Id: T2917 Differential Revision: https://dev.gnupg.org/D463
This commit is contained in:
parent
cacca62d06
commit
7bc5d3c7e4
4
NEWS
4
NEWS
@ -4,12 +4,16 @@ Noteworthy changes in version 1.11.2 (unreleased)
|
|||||||
* Even for old versions of gpg a missing MDC will now lead to a
|
* Even for old versions of gpg a missing MDC will now lead to a
|
||||||
decryption failure.
|
decryption failure.
|
||||||
|
|
||||||
|
* Added context flag "auto-key-locate" to control the
|
||||||
|
behavior of GPGME_KEYLIST_MODE_LOCATE.
|
||||||
|
|
||||||
* Interface changes relative to the 1.11.1 release:
|
* Interface changes relative to the 1.11.1 release:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
gpgme_decrypt_result_t EXTENDED: New field legacy_cipher_nomdc.
|
gpgme_decrypt_result_t EXTENDED: New field legacy_cipher_nomdc.
|
||||||
gpgme_set_ctx_flag EXTENDED: New flag 'ignore-mdc-error'.
|
gpgme_set_ctx_flag EXTENDED: New flag 'ignore-mdc-error'.
|
||||||
GPGME_AUDITLOG_DEFAULT NEW.
|
GPGME_AUDITLOG_DEFAULT NEW.
|
||||||
GPGME_AUDITLOG_DIAG NEW.
|
GPGME_AUDITLOG_DIAG NEW.
|
||||||
|
gpgme_set_ctx_flag EXTENDED: New flag 'auto-key-locate'.
|
||||||
cpp: DecryptionResult::sessionKey NEW.
|
cpp: DecryptionResult::sessionKey NEW.
|
||||||
cpp: DecryptionResult::symkeyAlgo NEW.
|
cpp: DecryptionResult::symkeyAlgo NEW.
|
||||||
cpp: DecryptionResult::isLegacyCipherNoMDC New.
|
cpp: DecryptionResult::isLegacyCipherNoMDC New.
|
||||||
|
@ -3096,6 +3096,16 @@ result of the former try had the decryption result flag
|
|||||||
@code{legacy_cipher_nomdc} set. For failsafe reasons this flag is
|
@code{legacy_cipher_nomdc} set. For failsafe reasons this flag is
|
||||||
reset after each operation.
|
reset after each operation.
|
||||||
|
|
||||||
|
@item "auto-key-locate"
|
||||||
|
The string given in @var{value} is passed to gpg. This can be used
|
||||||
|
to change the behavior of a @code{GPGME_KEYLIST_MODE_LOCATE} keylisting.
|
||||||
|
Valid values are documented in the GnuPG manual and the gpg man page under
|
||||||
|
the option @option{--auto-key-locate}.
|
||||||
|
Requires at least GnuPG 2.1.18.
|
||||||
|
|
||||||
|
Note: Keys retrieved through @code{auto-key-locate} are automatically
|
||||||
|
imported in the keyring.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
This function returns @code{0} on success.
|
This function returns @code{0} on success.
|
||||||
|
@ -155,6 +155,9 @@ struct gpgme_context
|
|||||||
/* The optional request origin. */
|
/* The optional request origin. */
|
||||||
char *request_origin;
|
char *request_origin;
|
||||||
|
|
||||||
|
/* The optional auto key locate options. */
|
||||||
|
char *auto_key_locate;
|
||||||
|
|
||||||
/* The locale for the pinentry. */
|
/* The locale for the pinentry. */
|
||||||
char *lc_ctype;
|
char *lc_ctype;
|
||||||
char *lc_messages;
|
char *lc_messages;
|
||||||
|
@ -140,6 +140,7 @@ struct engine_gpg
|
|||||||
struct gpgme_io_cbs io_cbs;
|
struct gpgme_io_cbs io_cbs;
|
||||||
gpgme_pinentry_mode_t pinentry_mode;
|
gpgme_pinentry_mode_t pinentry_mode;
|
||||||
char request_origin[10];
|
char request_origin[10];
|
||||||
|
char *auto_key_locate;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
unsigned int no_symkey_cache : 1;
|
unsigned int no_symkey_cache : 1;
|
||||||
@ -453,6 +454,7 @@ gpg_release (void *engine)
|
|||||||
free_argv (gpg->argv);
|
free_argv (gpg->argv);
|
||||||
if (gpg->cmd.keyword)
|
if (gpg->cmd.keyword)
|
||||||
free (gpg->cmd.keyword);
|
free (gpg->cmd.keyword);
|
||||||
|
free (gpg->auto_key_locate);
|
||||||
|
|
||||||
gpgme_data_release (gpg->override_session_key);
|
gpgme_data_release (gpg->override_session_key);
|
||||||
gpgme_data_release (gpg->diagnostics);
|
gpgme_data_release (gpg->diagnostics);
|
||||||
@ -659,6 +661,14 @@ gpg_set_engine_flags (void *engine, const gpgme_ctx_t ctx)
|
|||||||
else
|
else
|
||||||
*gpg->request_origin = 0;
|
*gpg->request_origin = 0;
|
||||||
|
|
||||||
|
if (ctx->auto_key_locate && have_gpg_version (gpg, "2.1.18"))
|
||||||
|
{
|
||||||
|
if (gpg->auto_key_locate)
|
||||||
|
free (gpg->auto_key_locate);
|
||||||
|
gpg->auto_key_locate = _gpgme_strconcat ("--auto-key-locate=",
|
||||||
|
ctx->auto_key_locate, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
gpg->flags.no_symkey_cache = (ctx->no_symkey_cache
|
gpg->flags.no_symkey_cache = (ctx->no_symkey_cache
|
||||||
&& have_gpg_version (gpg, "2.2.7"));
|
&& have_gpg_version (gpg, "2.2.7"));
|
||||||
gpg->flags.offline = (ctx->offline && have_gpg_version (gpg, "2.1.23"));
|
gpg->flags.offline = (ctx->offline && have_gpg_version (gpg, "2.1.23"));
|
||||||
@ -958,6 +968,19 @@ build_argv (engine_gpg_t gpg, const char *pgmname)
|
|||||||
argc++;
|
argc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gpg->auto_key_locate)
|
||||||
|
{
|
||||||
|
argv[argc] = strdup (gpg->auto_key_locate);
|
||||||
|
if (!argv[argc])
|
||||||
|
{
|
||||||
|
int saved_err = gpg_error_from_syserror ();
|
||||||
|
free (fd_data_map);
|
||||||
|
free_argv (argv);
|
||||||
|
return saved_err;
|
||||||
|
}
|
||||||
|
argc++;
|
||||||
|
}
|
||||||
|
|
||||||
if (gpg->flags.no_symkey_cache)
|
if (gpg->flags.no_symkey_cache)
|
||||||
{
|
{
|
||||||
argv[argc] = strdup ("--no-symkey-cache");
|
argv[argc] = strdup ("--no-symkey-cache");
|
||||||
|
12
src/gpgme.c
12
src/gpgme.c
@ -249,6 +249,7 @@ gpgme_release (gpgme_ctx_t ctx)
|
|||||||
free (ctx->lc_messages);
|
free (ctx->lc_messages);
|
||||||
free (ctx->override_session_key);
|
free (ctx->override_session_key);
|
||||||
free (ctx->request_origin);
|
free (ctx->request_origin);
|
||||||
|
free (ctx->auto_key_locate);
|
||||||
_gpgme_engine_info_release (ctx->engine_info);
|
_gpgme_engine_info_release (ctx->engine_info);
|
||||||
ctx->engine_info = NULL;
|
ctx->engine_info = NULL;
|
||||||
DESTROY_LOCK (ctx->lock);
|
DESTROY_LOCK (ctx->lock);
|
||||||
@ -546,6 +547,13 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)
|
|||||||
{
|
{
|
||||||
ctx->ignore_mdc_error = abool;
|
ctx->ignore_mdc_error = abool;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp (name, "auto-key-locate"))
|
||||||
|
{
|
||||||
|
free (ctx->auto_key_locate);
|
||||||
|
ctx->auto_key_locate = strdup (value);
|
||||||
|
if (!ctx->auto_key_locate)
|
||||||
|
err = gpg_error_from_syserror ();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
err = gpg_error (GPG_ERR_UNKNOWN_NAME);
|
err = gpg_error (GPG_ERR_UNKNOWN_NAME);
|
||||||
|
|
||||||
@ -599,6 +607,10 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name)
|
|||||||
{
|
{
|
||||||
return ctx->ignore_mdc_error? "1":"";
|
return ctx->ignore_mdc_error? "1":"";
|
||||||
}
|
}
|
||||||
|
else if (!strcmp (name, "auto-key-locate"))
|
||||||
|
{
|
||||||
|
return ctx->auto_key_locate? ctx->auto_key_locate : "";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ show_usage (int ex)
|
|||||||
" --import import all keys\n"
|
" --import import all keys\n"
|
||||||
" --offline use offline mode\n"
|
" --offline use offline mode\n"
|
||||||
" --from-file list all keys in the given file\n"
|
" --from-file list all keys in the given file\n"
|
||||||
|
" --from-wkd list key from a web key directory\n"
|
||||||
" --require-gnupg required at least the given GnuPG version\n"
|
" --require-gnupg required at least the given GnuPG version\n"
|
||||||
, stderr);
|
, stderr);
|
||||||
exit (ex);
|
exit (ex);
|
||||||
@ -100,6 +101,7 @@ main (int argc, char **argv)
|
|||||||
int only_secret = 0;
|
int only_secret = 0;
|
||||||
int offline = 0;
|
int offline = 0;
|
||||||
int from_file = 0;
|
int from_file = 0;
|
||||||
|
int from_wkd = 0;
|
||||||
gpgme_data_t data = NULL;
|
gpgme_data_t data = NULL;
|
||||||
|
|
||||||
|
|
||||||
@ -194,6 +196,12 @@ main (int argc, char **argv)
|
|||||||
gpgme_set_global_flag ("require-gnupg", *argv);
|
gpgme_set_global_flag ("require-gnupg", *argv);
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp (*argv, "--from-wkd"))
|
||||||
|
{
|
||||||
|
argc--; argv++;
|
||||||
|
mode |= GPGME_KEYLIST_MODE_LOCATE;
|
||||||
|
from_wkd = 1;
|
||||||
|
}
|
||||||
else if (!strncmp (*argv, "--", 2))
|
else if (!strncmp (*argv, "--", 2))
|
||||||
show_usage (1);
|
show_usage (1);
|
||||||
}
|
}
|
||||||
@ -213,6 +221,13 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
gpgme_set_offline (ctx, offline);
|
gpgme_set_offline (ctx, offline);
|
||||||
|
|
||||||
|
if (from_wkd)
|
||||||
|
{
|
||||||
|
err = gpgme_set_ctx_flag (ctx, "auto-key-locate",
|
||||||
|
"clear,nodefault,wkd");
|
||||||
|
fail_if_err (err);
|
||||||
|
}
|
||||||
|
|
||||||
if (from_file)
|
if (from_file)
|
||||||
{
|
{
|
||||||
err = gpgme_data_new_from_file (&data, *argv, 1);
|
err = gpgme_data_new_from_file (&data, *argv, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user