aboutsummaryrefslogtreecommitdiffstats
path: root/g10/import.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-01-23 09:12:18 +0000
committerWerner Koch <[email protected]>2017-01-23 09:13:26 +0000
commit953d4ec6afd1b42feb7465ee57e48d72f033019a (patch)
treee780e1c959be23492920d65b2ad76f1b4b2574b8 /g10/import.c
parentscd: Fix INTERRUPT transfer. (diff)
downloadgnupg-953d4ec6afd1b42feb7465ee57e48d72f033019a.tar.gz
gnupg-953d4ec6afd1b42feb7465ee57e48d72f033019a.zip
gpg: New export and import options "backup" and "restore".
* g10/export.c (parse_export_options): Add "backup" and its alias "export-backup". (do_export_one_keyblock): Export ring trust packets in backup mode. * g10/import.c (parse_import_options): Add "restore" and its alias "import-restore". (read_block): Import ring trust packets. -- These options are intended to, well, backup and restore keys between GnuPG implementations. These options may eventually be enhanced to backup and restore all public key related information. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/import.c')
-rw-r--r--g10/import.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/g10/import.c b/g10/import.c
index 1ed11bf38..b6c04dcfc 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -175,6 +175,10 @@ parse_import_options(char *str,unsigned int *options,int noisy)
{"import-export", IMPORT_EXPORT, NULL,
N_("run import filters and export key immediately")},
+ {"restore", IMPORT_RESTORE, NULL,
+ N_("assume the GnuPG key backup format")},
+ {"import-restore", IMPORT_RESTORE, NULL, NULL},
+
/* Aliases for backward compatibility */
{"allow-local-sigs",IMPORT_LOCAL_SIGS,NULL,NULL},
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL,NULL},
@@ -186,8 +190,18 @@ parse_import_options(char *str,unsigned int *options,int noisy)
the new design. */
{NULL,0,NULL,NULL}
};
+ int rc;
- return parse_options(str,options,import_opts,noisy);
+ rc = parse_options (str, options, import_opts, noisy);
+ if (rc && (*options & IMPORT_RESTORE))
+ {
+ /* Alter other options we want or don't want for restore. */
+ *options |= (IMPORT_LOCAL_SIGS | IMPORT_KEEP_OWNERTTRUST);
+ *options &= ~(IMPORT_MINIMAL | IMPORT_CLEAN
+ | IMPORT_REPAIR_PKS_SUBKEY_BUG
+ | IMPORT_MERGE_ONLY);
+ }
+ return rc;
}
@@ -833,7 +847,9 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
break;
case PKT_RING_TRUST:
- /* Skip those packets. */
+ /* Skip those packets unless we are in restore mode. */
+ if ((opt.import_options & IMPORT_RESTORE))
+ goto x_default;
free_packet( pkt );
init_packet(pkt);
break;
@@ -848,6 +864,7 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
}
in_cert = 1;
default:
+ x_default:
if (in_cert && valid_keyblock_packet (pkt->pkttype))
{
if (!root )