Blame SOURCES/gnupg-2.2.18-gpg-allow-import-of-previously-known-keys-even-without-UI.patch

8a904a
From: Vincent Breitmoser <look@my.amazin.horse>
8a904a
Date: Thu, 13 Jun 2019 21:27:42 +0200
8a904a
Subject: gpg: allow import of previously known keys, even without UIDs
8a904a
8a904a
* g10/import.c (import_one): Accept an incoming OpenPGP certificate that
8a904a
has no user id, as long as we already have a local variant of the cert
8a904a
that matches the primary key.
8a904a
8a904a
--
8a904a
8a904a
This fixes two of the three broken tests in import-incomplete.scm.
8a904a
8a904a
GnuPG-Bug-id: 4393
8a904a
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
8a904a
---
8a904a
 g10/import.c | 44 +++++++++++---------------------------------
8a904a
 1 file changed, 11 insertions(+), 33 deletions(-)
8a904a
8a904a
diff --git a/g10/import.c b/g10/import.c
8a904a
index 5d3162c..f9acf95 100644
8a904a
--- a/g10/import.c
8a904a
+++ b/g10/import.c
8a904a
@@ -1788,7 +1788,6 @@ import_one_real (ctrl_t ctrl,
8a904a
   size_t an;
8a904a
   char pkstrbuf[PUBKEY_STRING_SIZE];
8a904a
   int merge_keys_done = 0;
8a904a
-  int any_filter = 0;
8a904a
   KEYDB_HANDLE hd = NULL;
8a904a
 
8a904a
   if (r_valid)
8a904a
@@ -1825,14 +1824,6 @@ import_one_real (ctrl_t ctrl,
8a904a
       log_printf ("\n");
8a904a
     }
8a904a
 
8a904a
-
8a904a
-  if (!uidnode )
8a904a
-    {
8a904a
-      if (!silent)
8a904a
-        log_error( _("key %s: no user ID\n"), keystr_from_pk(pk));
8a904a
-      return 0;
8a904a
-    }
8a904a
-
8a904a
   if (screener && screener (keyblock, screener_arg))
8a904a
     {
8a904a
       log_error (_("key %s: %s\n"), keystr_from_pk (pk),
8a904a
@@ -1907,17 +1898,10 @@ import_one_real (ctrl_t ctrl,
8a904a
 	  }
8a904a
     }
8a904a
 
8a904a
-  if (!delete_inv_parts (ctrl, keyblock, keyid, options ) )
8a904a
-    {
8a904a
-      if (!silent)
8a904a
-        {
8a904a
-          log_error( _("key %s: no valid user IDs\n"), keystr_from_pk(pk));
8a904a
-          if (!opt.quiet )
8a904a
-            log_info(_("this may be caused by a missing self-signature\n"));
8a904a
-        }
8a904a
-      stats->no_user_id++;
8a904a
-      return 0;
8a904a
-    }
8a904a
+  /* Delete invalid parts, and note if we have any valid ones left.
8a904a
+   * We will later abort import if this key is new but contains
8a904a
+   * no valid uids.  */
8a904a
+  delete_inv_parts (ctrl, keyblock, keyid, options);
8a904a
 
8a904a
   /* Get rid of deleted nodes.  */
8a904a
   commit_kbnode (&keyblock);
8a904a
@@ -1927,24 +1911,11 @@ import_one_real (ctrl_t ctrl,
8a904a
     {
8a904a
       apply_keep_uid_filter (ctrl, keyblock, import_filter.keep_uid);
8a904a
       commit_kbnode (&keyblock);
8a904a
-      any_filter = 1;
8a904a
     }
8a904a
   if (import_filter.drop_sig)
8a904a
     {
8a904a
       apply_drop_sig_filter (ctrl, keyblock, import_filter.drop_sig);
8a904a
       commit_kbnode (&keyblock);
8a904a
-      any_filter = 1;
8a904a
-    }
8a904a
-
8a904a
-  /* If we ran any filter we need to check that at least one user id
8a904a
-   * is left in the keyring.  Note that we do not use log_error in
8a904a
-   * this case. */
8a904a
-  if (any_filter && !any_uid_left (keyblock))
8a904a
-    {
8a904a
-      if (!opt.quiet )
8a904a
-        log_info ( _("key %s: no valid user IDs\n"), keystr_from_pk (pk));
8a904a
-      stats->no_user_id++;
8a904a
-      return 0;
8a904a
     }
8a904a
 
8a904a
   /* The keyblock is valid and ready for real import.  */
8a904a
@@ -2002,6 +1973,13 @@ import_one_real (ctrl_t ctrl,
8a904a
       err = 0;
8a904a
       stats->skipped_new_keys++;
8a904a
     }
8a904a
+  else if (err && !any_uid_left (keyblock))
8a904a
+    {
8a904a
+      if (!silent)
8a904a
+        log_info( _("key %s: new key but contains no user ID - skipped\n"), keystr(keyid));
8a904a
+      err = 0;
8a904a
+      stats->no_user_id++;
8a904a
+    }
8a904a
   else if (err)  /* Insert this key. */
8a904a
     {
8a904a
       /* Note: ERR can only be NO_PUBKEY or UNUSABLE_PUBKEY.  */