···11-From: Vincent Breitmoser <look@my.amazin.horse>22-Date: Thu, 13 Jun 2019 21:27:42 +020033-Subject: gpg: allow import of previously known keys, even without UIDs44-55-* g10/import.c (import_one): Accept an incoming OpenPGP certificate that66-has no user id, as long as we already have a local variant of the cert77-that matches the primary key.88-99---1010-1111-This fixes two of the three broken tests in import-incomplete.scm.1212-1313-GnuPG-Bug-id: 43931414-Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>1515----1616- g10/import.c | 44 +++++++++++---------------------------------1717- 1 file changed, 11 insertions(+), 33 deletions(-)1818-1919-2020-diff --git a/g10/import.c b/g10/import.c2121-index 9fab46ca6..61896a6bf 1006442222---- a/g10/import.c2323-+++ b/g10/import.c2424-@@ -1954,7 +1954,6 @@ import_one_real (ctrl_t ctrl,2525- size_t an;2626- char pkstrbuf[PUBKEY_STRING_SIZE];2727- int merge_keys_done = 0;2828-- int any_filter = 0;2929- KEYDB_HANDLE hd = NULL;3030-3131- if (r_valid)3232-@@ -1992,13 +1991,6 @@ import_one_real (ctrl_t ctrl,3333- }3434-3535-3636-- if (!uidnode)3737-- {3838-- if (!silent)3939-- log_error( _("key %s: no user ID\n"), keystr_from_pk(pk));4040-- return 0;4141-- }4242--4343- if (screener && screener (keyblock, screener_arg))4444- {4545- log_error (_("key %s: %s\n"), keystr_from_pk (pk),4646-@@ -2078,18 +2070,10 @@ import_one_real (ctrl_t ctrl,4747- }4848- }4949-5050-- /* Delete invalid parts and bail out if there are no user ids left. */5151-- if (!delete_inv_parts (ctrl, keyblock, keyid, options, otherrevsigs))5252-- {5353-- if (!silent)5454-- {5555-- log_error ( _("key %s: no valid user IDs\n"), keystr_from_pk(pk));5656-- if (!opt.quiet)5757-- log_info(_("this may be caused by a missing self-signature\n"));5858-- }5959-- stats->no_user_id++;6060-- return 0;6161-- }6262-+ /* Delete invalid parts, and note if we have any valid ones left.6363-+ * We will later abort import if this key is new but contains6464-+ * no valid uids. */6565-+ delete_inv_parts (ctrl, keyblock, keyid, options, otherrevsigs);6666-6767- /* Get rid of deleted nodes. */6868- commit_kbnode (&keyblock);6969-@@ -2099,24 +2083,11 @@ import_one_real (ctrl_t ctrl,7070- {7171- apply_keep_uid_filter (ctrl, keyblock, import_filter.keep_uid);7272- commit_kbnode (&keyblock);7373-- any_filter = 1;7474- }7575- if (import_filter.drop_sig)7676- {7777- apply_drop_sig_filter (ctrl, keyblock, import_filter.drop_sig);7878- commit_kbnode (&keyblock);7979-- any_filter = 1;8080-- }8181--8282-- /* If we ran any filter we need to check that at least one user id8383-- * is left in the keyring. Note that we do not use log_error in8484-- * this case. */8585-- if (any_filter && !any_uid_left (keyblock))8686-- {8787-- if (!opt.quiet )8888-- log_info ( _("key %s: no valid user IDs\n"), keystr_from_pk (pk));8989-- stats->no_user_id++;9090-- return 0;9191- }9292-9393- /* The keyblock is valid and ready for real import. */9494-@@ -2174,6 +2145,13 @@ import_one_real (ctrl_t ctrl,9595- err = 0;9696- stats->skipped_new_keys++;9797- }9898-+ else if (err && !any_uid_left (keyblock))9999-+ {100100-+ if (!silent)101101-+ log_info( _("key %s: new key but contains no user ID - skipped\n"), keystr(keyid));102102-+ err = 0;103103-+ stats->no_user_id++;104104-+ }105105- else if (err) /* Insert this key. */106106- {107107- /* Note: ERR can only be NO_PUBKEY or UNUSABLE_PUBKEY. */