[Pkg-gnupg-commit] [gnupg2] 155/241: gpg: Fail if the search description passed to --gen-revoke is ambiguous.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Dec 9 20:32:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 178af9c3f56d385fe28a9e5e8bde0ab34c0b260e
Author: Neal H. Walfield <neal at g10code.com>
Date:   Fri Nov 20 13:00:19 2015 +0100

    gpg: Fail if the search description passed to --gen-revoke is ambiguous.
    
    * g10/revoke.c (gen_revoke): Error out if the search description is
    ambiguous.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>
---
 g10/revoke.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/g10/revoke.c b/g10/revoke.c
index 0ed2604..8599d17 100644
--- a/g10/revoke.c
+++ b/g10/revoke.c
@@ -630,6 +630,47 @@ gen_revoke (const char *uname)
       goto leave;
     }
 
+  rc = keydb_search (kdbhd, &desc, 1, NULL);
+  if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
+    /* Not ambiguous.  */
+    {
+    }
+  else if (rc == 0)
+    /* Ambiguous.  */
+    {
+      char *info;
+
+      log_error (_("'%s' matches multiple secret keys:\n"), uname);
+
+      info = format_seckey_info (keyblock->pkt->pkt.public_key);
+      log_error ("  %s\n", info);
+      xfree (info);
+      release_kbnode (keyblock);
+
+      rc = keydb_get_keyblock (kdbhd, &keyblock);
+      while (! rc)
+        {
+          info = format_seckey_info (keyblock->pkt->pkt.public_key);
+          log_error ("  %s\n", info);
+          xfree (info);
+          release_kbnode (keyblock);
+          keyblock = NULL;
+
+          rc = keydb_search (kdbhd, &desc, 1, NULL);
+          if (! rc)
+            rc = keydb_get_keyblock (kdbhd, &keyblock);
+        }
+
+      rc = GPG_ERR_AMBIGUOUS_NAME;
+
+      goto leave;
+    }
+  else
+    {
+      log_error (_("error searching the keyring: %s\n"), gpg_strerror (rc));
+      goto leave;
+    }
+
   /* Get the keyid from the keyblock.  */
   node = find_kbnode (keyblock, PKT_PUBLIC_KEY);
   if (!node)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list