aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-06-23 17:25:53 +0000
committerWerner Koch <[email protected]>2016-06-23 18:01:15 +0000
commit1e5959ec059ba41f4de1e2f953300bc040efc16f (patch)
tree244e65eb505238b73fdc24d14aa0d1d626f116cc
parentgpg: Do not print the validity after key generation. (diff)
downloadgnupg-1e5959ec059ba41f4de1e2f953300bc040efc16f.tar.gz
gnupg-1e5959ec059ba41f4de1e2f953300bc040efc16f.zip
gpg: New import option "import-show".
* g10/options.h (IMPORT_SHOW): New. * g10/import.c (parse_import_options): Add "import-show". (import_one): Implement that. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--doc/gpg.texi7
-rw-r--r--g10/import.c23
-rw-r--r--g10/options.h1
3 files changed, 28 insertions, 3 deletions
diff --git a/doc/gpg.texi b/doc/gpg.texi
index 3ea298eb4..15f58f47e 100644
--- a/doc/gpg.texi
+++ b/doc/gpg.texi
@@ -233,7 +233,7 @@ read from STDIN. If only a one argument is given, it is expected to
be a complete signature.
With more than 1 argument, the first should be a detached signature
-and the remaining files ake up the the signed data. To read the signed
+and the remaining files make up the the signed data. To read the signed
data from STDIN, use @samp{-} as the second filename. For security
reasons a detached signature cannot read the signed material from
STDIN without denoting it in the above way.
@@ -2180,6 +2180,11 @@ opposite meaning. The options are:
subkey. Defaults to no for regular @option{--import} and to yes for
keyserver @option{--recv-keys}.
+ @item import-show
+ Show a listing of the key as imported right before it is stored.
+ This can be combined with the option @option{--dry-run} to only look
+ at keys.
+
@item merge-only
During import, allow key updates to existing keys, but do not allow
any new keys to be imported. Defaults to no.
diff --git a/g10/import.c b/g10/import.c
index 7c0d1e2cc..c4992be69 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -112,6 +112,9 @@ parse_import_options(char *str,unsigned int *options,int noisy)
{"fast-import",IMPORT_FAST,NULL,
N_("do not update the trustdb after import")},
+ {"import-show",IMPORT_SHOW,NULL,
+ N_("show key during import")},
+
{"merge-only",IMPORT_MERGE_ONLY,NULL,
N_("only accept updates to existing keys")},
@@ -936,7 +939,7 @@ import_one (ctrl_t ctrl,
import_screener_t screener, void *screener_arg)
{
PKT_public_key *pk;
- PKT_public_key *pk_orig;
+ PKT_public_key *pk_orig = NULL;
kbnode_t node, uidnode;
kbnode_t keyblock_orig = NULL;
byte fpr2[MAX_FINGERPRINT_LEN];
@@ -1050,6 +1053,22 @@ import_one (ctrl_t ctrl,
return 0;
}
+ /* Get rid of deleted nodes. */
+ commit_kbnode (&keyblock);
+
+ /* Show the key in the form it is merged or inserted. */
+ if ((options & IMPORT_SHOW))
+ {
+ merge_keys_and_selfsig (keyblock);
+ /* Note that we do not want to show the validity because the key
+ * has not yet imported. */
+ list_keyblock_direct (ctrl, keyblock, 0, 0, 1, 1);
+ es_fflush (es_stdout);
+ }
+
+ if (opt.dry_run)
+ goto leave;
+
/* Do we have this key already in one of our pubrings ? */
pk_orig = xmalloc_clear( sizeof *pk_orig );
rc = get_pubkey_byfprint_fast (pk_orig, fpr2, fpr2len);
@@ -1258,7 +1277,7 @@ import_one (ctrl_t ctrl,
keydb_release (hd); hd = NULL;
}
- leave:
+ leave:
if (mod_key || new_key || same_key)
{
/* A little explanation for this: we fill in the fingerprint
diff --git a/g10/options.h b/g10/options.h
index e14bc07d3..58cf1f9a0 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -334,6 +334,7 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
#define IMPORT_LOCAL_SIGS (1<<0)
#define IMPORT_REPAIR_PKS_SUBKEY_BUG (1<<1)
#define IMPORT_FAST (1<<2)
+#define IMPORT_SHOW (1<<3)
#define IMPORT_MERGE_ONLY (1<<4)
#define IMPORT_MINIMAL (1<<5)
#define IMPORT_CLEAN (1<<6)