From 3491faa3bb62c1c96c6dd5947516128b2a966535 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 2 Feb 2021 12:57:00 +0100 Subject: [PATCH] gpg: Remove experimental feature to export w/o user-ids. * g10/options.h (IMPORT_DROP_UIDS, EXPORT_DROP_UIDS): Remove. * g10/import.c (parse_import_options): Remove option import-drop-uids. (import_one_real): Remove drop uids code. (remove_all_uids): Remove function. * g10/export.c (parse_export_options): Remove option export-drop-uids. (do_export_one_keyblock): Remove drop uids code. --- doc/gpg.texi | 10 --------- g10/export.c | 19 +--------------- g10/import.c | 60 ++++++--------------------------------------------- g10/options.h | 2 -- 4 files changed, 7 insertions(+), 84 deletions(-) diff --git a/doc/gpg.texi b/doc/gpg.texi index ccf1a2a5c..23b0d9c19 100644 --- a/doc/gpg.texi +++ b/doc/gpg.texi @@ -2451,11 +2451,6 @@ opposite meaning. The options are: on the keyring. This option is the same as running the @option{--edit-key} command "clean" after import. Defaults to no. - @item import-drop-uids - Do not import any user ids or their binding signatures. This option - can be used to update only the subkeys or other non-user id related - information. - @item self-sigs-only Accept only self-signatures while importing a key. All other key signatures are skipped at an early import stage. This option can be @@ -2639,11 +2634,6 @@ opposite meaning. The options are: running the @option{--edit-key} command "minimize" before export except that the local copy of the key is not modified. Defaults to no. - @item export-drop-uids - Do no export any user id or attribute packets or their associates - signatures. Note that due to missing user ids the resulting output is - not strictly RFC-4880 compliant. - @item export-pka Instead of outputting the key material output PKA records suitable to put into DNS zone files. An ORIGIN line is printed before each diff --git a/g10/export.c b/g10/export.c index 5cbe58180..396bc2780 100644 --- a/g10/export.c +++ b/g10/export.c @@ -126,8 +126,6 @@ parse_export_options(char *str,unsigned int *options,int noisy) N_("remove unusable parts from key during export")}, {"export-minimal",EXPORT_MINIMAL|EXPORT_CLEAN,NULL, N_("remove as much as possible from key during export")}, - {"export-drop-uids", EXPORT_DROP_UIDS, NULL, - N_("Do not export user id or attribute packets")}, {"export-pka", EXPORT_PKA_FORMAT, NULL, NULL }, {"export-dane", EXPORT_DANE_FORMAT, NULL, NULL }, @@ -161,9 +159,7 @@ parse_export_options(char *str,unsigned int *options,int noisy) *options &= ~(EXPORT_CLEAN | EXPORT_MINIMAL | EXPORT_PKA_FORMAT | EXPORT_DANE_FORMAT); } - /* Dropping uids also means to drop attributes. */ - if ((*options & EXPORT_DROP_UIDS)) - *options &= ~(EXPORT_ATTRIBUTES); + return rc; } @@ -1718,19 +1714,6 @@ do_export_one_keyblock (ctrl_t ctrl, kbnode_t keyblock, u32 *keyid, } } - /* Don't export user ids (and attributes)? This is not RFC-4880 - * compliant but we allow it anyway. */ - if ((options & EXPORT_DROP_UIDS) - && node->pkt->pkttype == PKT_USER_ID) - { - /* Skip until we get to something that is not a user id (or - * attrib) or a signature on it. */ - while (kbctx->next && kbctx->next->pkt->pkttype == PKT_SIGNATURE) - kbctx = kbctx->next; - - continue; - } - /* Don't export attribs? */ if (!(options & EXPORT_ATTRIBUTES) && node->pkt->pkttype == PKT_USER_ID diff --git a/g10/import.c b/g10/import.c index 80388835e..8e82edec1 100644 --- a/g10/import.c +++ b/g10/import.c @@ -128,7 +128,6 @@ static int chk_self_sigs (ctrl_t ctrl, kbnode_t keyblock, u32 *keyid, static int delete_inv_parts (ctrl_t ctrl, kbnode_t keyblock, u32 *keyid, unsigned int options); static int any_uid_left (kbnode_t keyblock); -static int remove_all_uids (kbnode_t *keyblock); static void remove_all_non_self_sigs (kbnode_t *keyblock, u32 *keyid); static int merge_blocks (ctrl_t ctrl, unsigned int options, kbnode_t keyblock_orig, @@ -196,9 +195,6 @@ parse_import_options(char *str,unsigned int *options,int noisy) {"import-minimal",IMPORT_MINIMAL|IMPORT_CLEAN,NULL, N_("remove as much as possible from key after import")}, - {"import-drop-uids", IMPORT_DROP_UIDS, NULL, - N_("do not import user id or attribute packets")}, - {"self-sigs-only", IMPORT_SELF_SIGS_ONLY, NULL, N_("ignore key-signatures which are not self-signatures")}, @@ -1918,9 +1914,7 @@ import_one_real (ctrl_t ctrl, } - /* Unless import-drop-uids has been requested we don't allow import - * of a key without UIDs. */ - if (!uidnode && !(options & IMPORT_DROP_UIDS)) + if (!uidnode) { if (!silent) log_error( _("key %s: no user ID\n"), keystr_from_pk(pk)); @@ -1955,9 +1949,7 @@ import_one_real (ctrl_t ctrl, remove_all_non_self_sigs (&keyblock, keyid); /* Remove or collapse the user ids. */ - if ((options & IMPORT_DROP_UIDS)) - remove_all_uids (&keyblock); - else if ((options & IMPORT_COLLAPSE_UIDS)) + if ((options & IMPORT_COLLAPSE_UIDS)) collapse_uids (&keyblock); if ((options & IMPORT_COLLAPSE_SUBKEYS)) @@ -2008,15 +2000,13 @@ import_one_real (ctrl_t ctrl, } } - /* Delete invalid parts and without the drop option bail out if - * there are no user ids. */ - if (!delete_inv_parts (ctrl, keyblock, keyid, options) - && !(options & IMPORT_DROP_UIDS) ) + /* Delete invalid parts and bail out if there are no user ids left. */ + if (!delete_inv_parts (ctrl, keyblock, keyid, options)) { if (!silent) { - log_error( _("key %s: no valid user IDs\n"), keystr_from_pk(pk)); - if (!opt.quiet ) + log_error ( _("key %s: no valid user IDs\n"), keystr_from_pk(pk)); + if (!opt.quiet) log_info(_("this may be caused by a missing self-signature\n")); } stats->no_user_id++; @@ -3923,44 +3913,6 @@ any_uid_left (kbnode_t keyblock) } - -/* Delete all user ids from KEYBLOCK. - * Returns: True if the keyblock has changed. */ -static int -remove_all_uids (kbnode_t *keyblock) -{ - kbnode_t node; - int any = 0; - - for (node = *keyblock; node; node = node->next) - { - if (is_deleted_kbnode (node)) - continue; - - if (node->pkt->pkttype != PKT_USER_ID) - continue; - - /* We are at the first user id. Delete everything up to the - * first subkey. */ - for (; node; node = node->next) - { - if (is_deleted_kbnode (node)) - continue; - - if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY - || node->pkt->pkttype == PKT_SECRET_SUBKEY) - break; - delete_kbnode (node); - any = 1; - } - break; /* All done. */ - } - - commit_kbnode (keyblock); - return any; -} - - /* Delete all non-self-sigs from KEYBLOCK. * Returns: True if the keyblock has changed. */ static void diff --git a/g10/options.h b/g10/options.h index 2f4a76960..9e4309671 100644 --- a/g10/options.h +++ b/g10/options.h @@ -368,7 +368,6 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode; #define IMPORT_RESTORE (1<<10) #define IMPORT_REPAIR_KEYS (1<<11) #define IMPORT_DRY_RUN (1<<12) -#define IMPORT_DROP_UIDS (1<<13) #define IMPORT_SELF_SIGS_ONLY (1<<14) #define IMPORT_COLLAPSE_UIDS (1<<15) #define IMPORT_COLLAPSE_SUBKEYS (1<<16) @@ -383,7 +382,6 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode; #define EXPORT_PKA_FORMAT (1<<6) #define EXPORT_DANE_FORMAT (1<<7) #define EXPORT_BACKUP (1<<10) -#define EXPORT_DROP_UIDS (1<<13) #define LIST_SHOW_PHOTOS (1<<0) #define LIST_SHOW_POLICY_URLS (1<<1)