mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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 <wk@gnupg.org>
(cherry picked from commit d00c8024e5
)
This commit is contained in:
parent
1187143343
commit
46f3283b34
7 changed files with 63 additions and 32 deletions
48
g10/getkey.c
48
g10/getkey.c
|
@ -1043,7 +1043,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. */
|
||||
|
||||
|
@ -1072,7 +1074,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.
|
||||
|
@ -1119,17 +1127,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:
|
||||
|
@ -1264,7 +1280,6 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc && retctx)
|
||||
{
|
||||
getkey_end (ctrl, *retctx);
|
||||
|
@ -1417,7 +1432,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)
|
||||
{
|
||||
|
@ -1440,7 +1456,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue