diff options
author | Werner Koch <wk@gnupg.org> | 2017-01-23 10:12:18 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2017-01-23 10:13:26 +0100 |
commit | 953d4ec6afd1b42feb7465ee57e48d72f033019a (patch) | |
tree | e780e1c959be23492920d65b2ad76f1b4b2574b8 /g10/export.c | |
parent | scd: Fix INTERRUPT transfer. (diff) | |
download | gnupg2-953d4ec6afd1b42feb7465ee57e48d72f033019a.tar.xz gnupg2-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 <wk@gnupg.org>
Diffstat (limited to 'g10/export.c')
-rw-r--r-- | g10/export.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/g10/export.c b/g10/export.c index b36200ac0..f354ca0f6 100644 --- a/g10/export.c +++ b/g10/export.c @@ -116,6 +116,10 @@ parse_export_options(char *str,unsigned int *options,int noisy) {"export-pka", EXPORT_PKA_FORMAT, NULL, NULL }, {"export-dane", EXPORT_DANE_FORMAT, NULL, NULL }, + {"backup", EXPORT_BACKUP, NULL, + N_("use the GnuPG key backup format")}, + {"export-backup", EXPORT_BACKUP, NULL, NULL }, + /* Aliases for backward compatibility */ {"include-local-sigs",EXPORT_LOCAL_SIGS,NULL,NULL}, {"include-attributes",EXPORT_ATTRIBUTES,NULL,NULL}, @@ -127,8 +131,18 @@ parse_export_options(char *str,unsigned int *options,int noisy) {NULL,0,NULL,NULL} /* add tags for include revoked and disabled? */ }; + int rc; - return parse_options(str,options,export_opts,noisy); + rc = parse_options (str, options, export_opts, noisy); + if (rc && (*options & EXPORT_BACKUP)) + { + /* Alter other options we want or don't want for restore. */ + *options |= (EXPORT_LOCAL_SIGS | EXPORT_ATTRIBUTES + | EXPORT_SENSITIVE_REVKEYS); + *options &= ~(EXPORT_CLEAN | EXPORT_MINIMAL + | EXPORT_PKA_FORMAT | EXPORT_DANE_FORMAT); + } + return rc; } @@ -1535,8 +1549,9 @@ do_export_one_keyblock (ctrl_t ctrl, kbnode_t keyblock, u32 *keyid, if (node->pkt->pkttype == PKT_COMMENT) continue; - /* Make sure that ring_trust packets never get exported. */ - if (node->pkt->pkttype == PKT_RING_TRUST) + /* Make sure that ring_trust packets are only exported in backup + * mode. */ + if (node->pkt->pkttype == PKT_RING_TRUST && !(options & EXPORT_BACKUP)) continue; /* If exact is set, then we only export what was requested |