From 69ae16636cb0800d37f5d9eee6bb3d4749e645f7 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 7 May 2008 15:40:36 +0000 Subject: Add command --locate-key. Fix auto-key-locate processing of "nodefault". --- g10/getkey.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'g10/getkey.c') diff --git a/g10/getkey.c b/g10/getkey.c index 5c1ed10e6..93f8f14ce 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -925,8 +925,11 @@ get_pubkey_byname (PKT_public_key *pk, int rc; strlist_t namelist = NULL; struct akl *akl; + int is_mbox; int nodefault = 0; + is_mbox = is_valid_mailbox (name); + /* Check whether we the default local search has been disabled. This is the case if either the "nodefault" or the "local" keyword are in the list of auto key locate mechanisms. */ @@ -940,8 +943,11 @@ get_pubkey_byname (PKT_public_key *pk, } } - if (nodefault) - rc = G10ERR_NO_PUBKEY; + if (nodefault && is_mbox) + { + /* Nodefault but a mailbox - let the AKL locate the key. */ + rc = G10ERR_NO_PUBKEY; + } else { add_to_strlist (&namelist, name); @@ -951,8 +957,7 @@ get_pubkey_byname (PKT_public_key *pk, /* If the requested name resembles a valid mailbox and automatic retrieval has been enabled, we try to import the key. */ - - if (rc == G10ERR_NO_PUBKEY && !no_akl && is_valid_mailbox(name)) + if (gpg_err_code (rc) == G10ERR_NO_PUBKEY && !no_akl && is_mbox) { for (akl=opt.auto_key_locate; akl; akl=akl->next) { -- cgit v1.2.3