diff options
| author | Werner Koch <[email protected]> | 2019-07-04 13:13:26 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2019-07-04 13:13:26 +0000 |
| commit | d00c8024e58822e0623b3fad99248ce68a8b7725 (patch) | |
| tree | 414888fefeb31f7a455a610b39fc9ec4c832f561 /g10/getkey.c | |
| parent | gpg: Make the get_pubkey_byname interface easier to understand. (diff) | |
| download | gnupg-d00c8024e58822e0623b3fad99248ce68a8b7725.tar.gz gnupg-d00c8024e58822e0623b3fad99248ce68a8b7725.zip | |
gpg: New command --locate-external-key.
* g10/gpg.c (aLocateExtKeys): New.
(opts): Add --locate-external-keys.
(main): Implement that.
* g10/getkey.c (get_pubkey_byname): Implement GET_PUBKEY_NO_LOCAL.
(get_best_pubkey_byname): Add arg 'mode' and pass on to
get_pubkey_byname. Change callers.
* g10/keylist.c (public_key_list): Add arg 'no_local'.
(locate_one): Ditto. Pass on to get_best_pubkey_byname.
--
This new command is a shortcut for
--auto-key-locate nodefault,clear,wkd,... --locate-key
and uses the default or configured AKL list but does so without local.
See also
GnuPG-bug-id: 4599
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/getkey.c')
| -rw-r--r-- | g10/getkey.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/g10/getkey.c b/g10/getkey.c index f7158c2b6..62142772e 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -936,7 +936,9 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode, * Note: we only save the search context in RETCTX if the local * method is the first method tried (either explicitly or * implicitly). */ - if (mode != GET_PUBKEY_NO_AKL) + if (mode == GET_PUBKEY_NO_LOCAL) + nodefault = 1; /* Auto-key-locate but ignore "local". */ + else if (mode != GET_PUBKEY_NO_AKL) { /* auto-key-locate is enabled. */ @@ -965,7 +967,13 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode, anylocalfirst = 1; } - if (nodefault && is_mbox) + if (mode == GET_PUBKEY_NO_LOCAL) + { + /* Force using the AKL. If IS_MBOX is not set this is the final + * error code. */ + rc = GPG_ERR_NO_PUBKEY; + } + else if (nodefault && is_mbox) { /* Either "nodefault" or "local" (explicitly) appeared in the * auto key locate list and NAME appears to be an email address. @@ -1012,17 +1020,25 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode, break; case AKL_LOCAL: - mechanism_string = "Local"; - did_akl_local = 1; - if (retctx) - { - getkey_end (ctrl, *retctx); - *retctx = NULL; - } - add_to_strlist (&namelist, name); - rc = key_byname (ctrl, anylocalfirst ? retctx : NULL, - namelist, pk, 0, - include_unusable, ret_keyblock, ret_kdbhd); + if (mode == GET_PUBKEY_NO_LOCAL) + { + mechanism_string = "None"; + rc = GPG_ERR_NO_PUBKEY; + } + else + { + mechanism_string = "Local"; + did_akl_local = 1; + if (retctx) + { + getkey_end (ctrl, *retctx); + *retctx = NULL; + } + add_to_strlist (&namelist, name); + rc = key_byname (ctrl, anylocalfirst ? retctx : NULL, + namelist, pk, 0, + include_unusable, ret_keyblock, ret_kdbhd); + } break; case AKL_CERT: @@ -1157,7 +1173,6 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode, } } - if (rc && retctx) { getkey_end (ctrl, *retctx); @@ -1310,7 +1325,8 @@ pubkey_cmp (ctrl_t ctrl, const char *name, struct pubkey_cmp_cookie *old, * resembles a mail address, the results are ranked and only the best * result is returned. */ gpg_error_t -get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk, +get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode, + GETKEY_CTX *retctx, PKT_public_key *pk, const char *name, KBNODE *ret_keyblock, int include_unusable) { @@ -1333,7 +1349,7 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk, getkey_end (ctrl, ctx); ctx = NULL; } - err = get_pubkey_byname (ctrl, GET_PUBKEY_NORMAL, + err = get_pubkey_byname (ctrl, mode, &ctx, pk, name, ret_keyblock, NULL, include_unusable); if (err) |
