[Pkg-gnupg-commit] [gnupg2] 50/160: gpg: Do not print the validity after key generation.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Jul 15 09:36:35 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch upstream
in repository gnupg2.

commit 09c6f7135150efbbeb459d4ae0189a81e9d180f8
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jun 23 19:22:13 2016 +0200

    gpg: Do not print the validity after key generation.
    
    * g10/keylist.c (struct keylist_context): Add field NO_VALIDITY.
    (list_keyblock_print): Take care of it.
    (list_keyblock_direct): Add arg NO_VALIDITY.
    * g10/keygen.c (do_generate_keypair): Merge keyblock and print w/o
    validity.
    --
    
    It will always be ultimate and by not printing it we avoid a lot of
    garbage output due to the trustdb re-calculation.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 g10/keygen.c  |  6 +++++-
 g10/keylist.c | 14 ++++++++++----
 g10/main.h    |  2 +-
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/g10/keygen.c b/g10/keygen.c
index 74fd370..b7c8e83 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -4340,11 +4340,15 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
 
           gen_standard_revoke (pk, cache_nonce);
 
+          /* Get rid of the first empty packet.  */
+          commit_kbnode (&pub_root);
+
           if (!opt.batch)
             {
               tty_printf (_("public and secret key created and signed.\n") );
               tty_printf ("\n");
-              list_keyblock_direct (ctrl, pub_root, 0, 1, 1);
+              merge_keys_and_selfsig (pub_root);
+              list_keyblock_direct (ctrl, pub_root, 0, 1, 1, 1);
             }
 
 
diff --git a/g10/keylist.c b/g10/keylist.c
index 0ac763d..e595fe3 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -59,6 +59,7 @@ struct keylist_context
   int inv_sigs;    /* Counter used if CHECK_SIGS is set.  */
   int no_key;      /* Counter used if CHECK_SIGS is set.  */
   int oth_err;     /* Counter used if CHECK_SIGS is set.  */
+  int no_validity; /* Do not show validity.  */
 };
 
 
@@ -1052,7 +1053,8 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr,
         secret = 2;  /* Key not found.  */
     }
 
-  check_trustdb_stale (ctrl);
+  if (!listctx->no_validity)
+    check_trustdb_stale (ctrl);
 
   /* Print the "pub" line and in KF_NONE mode the fingerprint.  */
   print_key_line (es_stdout, pk, secret);
@@ -1090,7 +1092,8 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr,
 	    dump_attribs (uid, pk);
 
 	  if ((uid->is_revoked || uid->is_expired)
-	      || (opt.list_options & LIST_SHOW_UID_VALIDITY))
+	      || ((opt.list_options & LIST_SHOW_UID_VALIDITY)
+                  && !listctx->no_validity))
 	    {
 	      const char *validity;
 
@@ -1755,14 +1758,17 @@ list_keyblock (ctrl_t ctrl,
 }
 
 
-/* Public function used by keygen to list a keyblock.  */
+/* Public function used by keygen to list a keyblock.  If NO_VALIDITY
+ * is set the validity of a key is never shown.  */
 void
 list_keyblock_direct (ctrl_t ctrl,
-                      kbnode_t keyblock, int secret, int has_secret, int fpr)
+                      kbnode_t keyblock, int secret, int has_secret, int fpr,
+                      int no_validity)
 {
   struct keylist_context listctx;
 
   memset (&listctx, 0, sizeof (listctx));
+  listctx.no_validity = !!no_validity;
   list_keyblock (ctrl, keyblock, secret, has_secret, fpr, &listctx);
   keylist_context_release (&listctx);
 }
diff --git a/g10/main.h b/g10/main.h
index 7b716ff..e6f2070 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -415,7 +415,7 @@ void secret_key_list (ctrl_t ctrl, strlist_t list );
 void print_subpackets_colon(PKT_signature *sig);
 void reorder_keyblock (KBNODE keyblock);
 void list_keyblock_direct (ctrl_t ctrl, kbnode_t keyblock, int secret,
-                           int has_secret, int fpr);
+                           int has_secret, int fpr, int no_validity);
 void print_fingerprint (estream_t fp, PKT_public_key *pk, int mode);
 void print_revokers (estream_t fp, PKT_public_key *pk);
 void show_policy_url(PKT_signature *sig,int indent,int mode);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list