Package: gnupg2 / 2.2.12-1+deb10u1

from-2.2.14/gpg-During-secret-key-import-print-sec-instead-of-pub.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
From: Werner Koch <wk@gnupg.org>
Date: Fri, 15 Mar 2019 19:11:32 +0100
Subject: 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>
(cherry picked from commit f64477db86568bdc28c313bfeb8b95d8edf05a3c)
(cherry picked from commit db2d75f1ffede2ea77163b487a15e60249daffa0)
---
 g10/gpgcompose.c |  5 +++--
 g10/import.c     | 11 +++++++----
 g10/keyedit.c    | 23 ++++++++++++++---------
 g10/keyedit.h    |  2 +-
 4 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/g10/gpgcompose.c b/g10/gpgcompose.c
index 226f793..aec0b4a 100644
--- a/g10/gpgcompose.c
+++ b/g10/gpgcompose.c
@@ -3058,10 +3058,11 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
 }
 
 void
-show_basic_key_info (ctrl_t ctrl, KBNODE keyblock)
+show_basic_key_info (ctrl_t ctrl, KBNODE keyblock, int made_from_sec)
 {
   (void)ctrl;
-  (void) keyblock;
+  (void)keyblock;
+  (void)made_from_sec;
 }
 
 int
diff --git a/g10/import.c b/g10/import.c
index 29de8ff..a5f4f38 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -1653,7 +1653,8 @@ update_key_origin (kbnode_t keyblock, u32 curtime, int origin, const char *url)
  * the internal errorcount, so that invalid input can be detected by
  * programs which called gpg.  If SILENT is no messages are printed -
  * even most error messages are suppressed.  ORIGIN is the origin of
- * the key (0 for unknown) and URL the corresponding URL.
+ * the key (0 for unknown) and URL the corresponding URL.  FROM_SK
+ * indicates that the key has been made from a secret key.
  */
 static gpg_error_t
 import_one (ctrl_t ctrl,
@@ -1697,9 +1698,11 @@ import_one (ctrl_t ctrl,
   keyid_from_pk( pk, keyid );
   uidnode = find_next_kbnode( keyblock, PKT_USER_ID );
 
-  if (opt.verbose && !opt.interactive && !silent)
+  if (opt.verbose && !opt.interactive && !silent && !from_sk)
     {
-      log_info( "pub  %s/%s %s  ",
+      /* Note that we do not print this info in FROM_SK mode
+       * because import_one already printed that.  */
+      log_info ("pub  %s/%s %s  ",
                 pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
                 keystr_from_pk(pk), datestr_from_pk(pk) );
       if (uidnode)
@@ -1730,7 +1733,7 @@ import_one (ctrl_t ctrl,
         print_import_check (pk, uidnode->pkt->pkt.user_id);
       merge_keys_and_selfsig (ctrl, keyblock);
       tty_printf ("\n");
-      show_basic_key_info (ctrl, keyblock);
+      show_basic_key_info (ctrl, keyblock, from_sk);
       tty_printf ("\n");
       if (!cpr_get_answer_is_yes ("import.okay",
                                   "Do you want to import this key? (y/N) "))
diff --git a/g10/keyedit.c b/g10/keyedit.c
index b717960..f95f02f 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -3662,13 +3662,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;
@@ -3681,13 +3682,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));
diff --git a/g10/keyedit.h b/g10/keyedit.h
index d1f453a..af5e996 100644
--- a/g10/keyedit.h
+++ b/g10/keyedit.h
@@ -50,7 +50,7 @@ void keyedit_quick_set_expire (ctrl_t ctrl,
                                char **subkeyfprs);
 void keyedit_quick_set_primary (ctrl_t ctrl, const char *username,
                                 const char *primaryuid);
-void show_basic_key_info (ctrl_t ctrl, kbnode_t keyblock);
+void show_basic_key_info (ctrl_t ctrl, kbnode_t keyblock, int print_sec);
 int keyedit_print_one_sig (ctrl_t ctrl, estream_t fp,
                            int rc, kbnode_t keyblock,
 			   kbnode_t node, int *inv_sigs, int *no_key,