[PATCH GnuPG 2/2] gpg: allow import of previously known keys, even without UIDs
Vincent Breitmoser
look at my.amazin.horse
Sun May 12 12:36:56 CEST 2019
* g10/import.c (import_one): Allow import of keys that have no user ids,
if we already know them. Keys are still rejected if they contained
invalid user ids, or none that pass a given filter criteria.
---
g10/import.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/g10/import.c b/g10/import.c
index 00bc47cc1..89ec18840 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -1806,16 +1806,6 @@ import_one (ctrl_t ctrl,
log_printf ("\n");
}
-
- /* Unless import-drop-uids has been requested we don't allow import
- * of a key without UIDs. */
- if (!uidnode && !(options & IMPORT_DROP_UIDS))
- {
- if (!silent)
- log_error( _("key %s: no user ID\n"), keystr_from_pk(pk));
- return 0;
- }
-
if (screener && screener (keyblock, screener_arg))
{
log_error (_("key %s: %s\n"), keystr_from_pk (pk),
@@ -1888,9 +1878,9 @@ import_one (ctrl_t ctrl,
}
/* Delete invalid parts and without the drop option bail out if
- * there are no user ids. */
+ * there were user ids, but none was actually valid. */
if (!delete_inv_parts (ctrl, keyblock, keyid, options)
- && !(options & IMPORT_DROP_UIDS) )
+ && uidnode && !(options & IMPORT_DROP_UIDS) )
{
if (!silent)
{
@@ -1985,6 +1975,13 @@ import_one (ctrl_t ctrl,
err = 0;
stats->skipped_new_keys++;
}
+ else if (err && !uidnode && !(options & IMPORT_DROP_UIDS) )
+ {
+ if (!silent)
+ log_info( _("key %s: new key but contains no user ID - skipped\n"), keystr(keyid));
+ err = 0;
+ stats->no_user_id++;
+ }
else if (err) /* Insert this key. */
{
/* Note: ERR can only be NO_PUBKEY or UNUSABLE_PUBKEY. */
--
2.20.1
More information about the Gnupg-devel
mailing list