1 From: Vincent Breitmoser <look@my.amazin.horse>
2 Date: Thu, 13 Jun 2019 21:27:42 +0200
3 Subject: gpg: allow import of previously known keys, even without UIDs
5 * g10/import.c (import_one): Accept an incoming OpenPGP certificate that
6 has no user id, as long as we already have a local variant of the cert
7 that matches the primary key.
11 This fixes two of the three broken tests in import-incomplete.scm.
14 Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
16 g10/import.c | 44 +++++++++++---------------------------------
17 1 file changed, 11 insertions(+), 33 deletions(-)
20 diff --git a/g10/import.c b/g10/import.c
21 index cd3363fc7..8f10771db 100644
24 @@ -1858,7 +1858,6 @@ import_one_real (ctrl_t ctrl,
26 char pkstrbuf[PUBKEY_STRING_SIZE];
27 int merge_keys_done = 0;
29 KEYDB_HANDLE hd = NULL;
32 @@ -1896,13 +1895,6 @@ import_one_real (ctrl_t ctrl,
39 - log_error( _("key %s: no user ID\n"), keystr_from_pk(pk));
43 if (screener && screener (keyblock, screener_arg))
45 log_error (_("key %s: %s\n"), keystr_from_pk (pk),
46 @@ -1977,18 +1969,10 @@ import_one_real (ctrl_t ctrl,
50 - /* Delete invalid parts and bail out if there are no user ids left. */
51 - if (!delete_inv_parts (ctrl, keyblock, keyid, options, otherrevsigs))
55 - log_error( _("key %s: no valid user IDs\n"), keystr_from_pk(pk));
57 - log_info(_("this may be caused by a missing self-signature\n"));
59 - stats->no_user_id++;
62 + /* Delete invalid parts, and note if we have any valid ones left.
63 + * We will later abort import if this key is new but contains
65 + delete_inv_parts (ctrl, keyblock, keyid, options, otherrevsigs);
67 /* Get rid of deleted nodes. */
68 commit_kbnode (&keyblock);
69 @@ -1998,24 +1982,11 @@ import_one_real (ctrl_t ctrl,
71 apply_keep_uid_filter (ctrl, keyblock, import_filter.keep_uid);
72 commit_kbnode (&keyblock);
75 if (import_filter.drop_sig)
77 apply_drop_sig_filter (ctrl, keyblock, import_filter.drop_sig);
78 commit_kbnode (&keyblock);
82 - /* If we ran any filter we need to check that at least one user id
83 - * is left in the keyring. Note that we do not use log_error in
85 - if (any_filter && !any_uid_left (keyblock))
88 - log_info ( _("key %s: no valid user IDs\n"), keystr_from_pk (pk));
89 - stats->no_user_id++;
93 /* The keyblock is valid and ready for real import. */
94 @@ -2073,6 +2044,13 @@ import_one_real (ctrl_t ctrl,
96 stats->skipped_new_keys++;
98 + else if (err && !any_uid_left (keyblock))
101 + log_info( _("key %s: new key but contains no user ID - skipped\n"), keystr(keyid));
103 + stats->no_user_id++;
105 else if (err) /* Insert this key. */
107 /* Note: ERR can only be NO_PUBKEY or UNUSABLE_PUBKEY. */