diff options
author | Werner Koch <wk@gnupg.org> | 2019-03-15 19:11:32 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2019-03-15 19:14:34 +0100 |
commit | f64477db86568bdc28c313bfeb8b95d8edf05a3c (patch) | |
tree | 983f74812b96e9f10c697bbef7c03d3337821da8 /g10/keyedit.c | |
parent | gpg: Simplify an interactive import status line. (diff) | |
download | gnupg2-f64477db86568bdc28c313bfeb8b95d8edf05a3c.tar.xz gnupg2-f64477db86568bdc28c313bfeb8b95d8edf05a3c.zip |
gpg: During secret key import print "sec" instead of "pub".
* g10/keyedit.c (show_basic_key_info): New arg 'print_sec'. Remove
useless code for "sub" and "ssb".
* g10/import.c (import_one): Pass FROM_SK to show_basic_key_info. Do
not print the first keyinfo in FROM_SK mode.
printing.
--
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/keyedit.c')
-rw-r--r-- | g10/keyedit.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/g10/keyedit.c b/g10/keyedit.c index 34b7679e4..4ec6ce503 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -3677,13 +3677,14 @@ show_key_with_all_names (ctrl_t ctrl, estream_t fp, /* Display basic key information. This function is suitable to show - information on the key without any dependencies on the trustdb or - any other internal GnuPG stuff. KEYBLOCK may either be a public or - a secret key. This function may be called with KEYBLOCK containing - secret keys and thus the printing of "pub" vs. "sec" does only - depend on the packet type and not by checking with gpg-agent. */ + * information on the key without any dependencies on the trustdb or + * any other internal GnuPG stuff. KEYBLOCK may either be a public or + * a secret key. This function may be called with KEYBLOCK containing + * secret keys and thus the printing of "pub" vs. "sec" does only + * depend on the packet type and not by checking with gpg-agent. If + * PRINT_SEC ist set "sec" is printed instead of "pub". */ void -show_basic_key_info (ctrl_t ctrl, kbnode_t keyblock) +show_basic_key_info (ctrl_t ctrl, kbnode_t keyblock, int print_sec) { KBNODE node; int i; @@ -3696,13 +3697,17 @@ show_basic_key_info (ctrl_t ctrl, kbnode_t keyblock) || node->pkt->pkttype == PKT_SECRET_KEY) { PKT_public_key *pk = node->pkt->pkt.public_key; + const char *tag; + + if (node->pkt->pkttype == PKT_SECRET_KEY || print_sec) + tag = "sec"; + else + tag = "pub"; /* Note, we use the same format string as in other show functions to make the translation job easier. */ tty_printf ("%s %s/%s ", - node->pkt->pkttype == PKT_PUBLIC_KEY ? "pub" : - node->pkt->pkttype == PKT_PUBLIC_SUBKEY ? "sub" : - node->pkt->pkttype == PKT_SECRET_KEY ? "sec" :"ssb", + tag, pubkey_string (pk, pkstrbuf, sizeof pkstrbuf), keystr_from_pk (pk)); tty_printf (_("created: %s"), datestr_from_pk (pk)); |