gpg: Add sub-option ignore-attributes to --import-options.

* g10/options.h (IMPORT_IGNORE_ATTRIBUTES): New.
* g10/import.c (parse_import_options): Add new sub-option.
(read_block): Implement sub-option.
--

Suggested-by: Robin H. Johnson

Tested using the import-export feature:

  gpg --export KEY_WITH_PICTURE \
   | gpg --import --import-options import-export,ignore-attributes \
   | gpg --show-key
This commit is contained in:
Werner Koch 2024-01-24 18:23:02 +01:00
parent a227a0d54d
commit d4976e35d2
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 17 additions and 0 deletions

View File

@ -2579,6 +2579,10 @@ opposite meaning. The options are:
import-clean it suppresses the final clean step after merging the import-clean it suppresses the final clean step after merging the
imported key into the existing key. imported key into the existing key.
@item ignore-attributes
Ignore all attribute user IDs (photo IDs) and their signatures while
importing a key.
@item repair-keys @item repair-keys
After import, fix various problems with the After import, fix various problems with the
keys. For example, this reorders signatures, and strips duplicate keys. For example, this reorders signatures, and strips duplicate

View File

@ -209,6 +209,9 @@ parse_import_options(char *str,unsigned int *options,int noisy)
{"repair-keys", IMPORT_REPAIR_KEYS, NULL, {"repair-keys", IMPORT_REPAIR_KEYS, NULL,
N_("repair keys on import")}, N_("repair keys on import")},
/* New options. Right now, without description string. */
{"ignore-attributes", IMPORT_IGNORE_ATTRIBUTES, NULL, NULL},
/* Hidden options which are enabled by default and are provided /* Hidden options which are enabled by default and are provided
* in case of problems with the respective implementation. */ * in case of problems with the respective implementation. */
{"collapse-uids", IMPORT_COLLAPSE_UIDS, NULL, NULL}, {"collapse-uids", IMPORT_COLLAPSE_UIDS, NULL, NULL},
@ -1008,6 +1011,15 @@ read_block( IOBUF a, unsigned int options,
init_packet(pkt); init_packet(pkt);
continue; continue;
} }
else if ((opt.import_options & IMPORT_IGNORE_ATTRIBUTES)
&& (pkt->pkttype == PKT_USER_ID || pkt->pkttype == PKT_ATTRIBUTE)
&& pkt->pkt.user_id->attrib_data)
{
skip_sigs = 1;
free_packet (pkt, &parsectx);
init_packet (pkt);
continue;
}
if (skip_sigs) if (skip_sigs)
{ {

View File

@ -406,6 +406,7 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
#define IMPORT_COLLAPSE_UIDS (1<<15) #define IMPORT_COLLAPSE_UIDS (1<<15)
#define IMPORT_COLLAPSE_SUBKEYS (1<<16) #define IMPORT_COLLAPSE_SUBKEYS (1<<16)
#define IMPORT_BULK (1<<17) #define IMPORT_BULK (1<<17)
#define IMPORT_IGNORE_ATTRIBUTES (1<<18)
#define EXPORT_LOCAL_SIGS (1<<0) #define EXPORT_LOCAL_SIGS (1<<0)
#define EXPORT_ATTRIBUTES (1<<1) #define EXPORT_ATTRIBUTES (1<<1)