[git] GnuPG - branch, master, updated. gnupg-2.1.15-82-g13ddc17

by Neal H. Walfield cvs at cvs.gnupg.org
Tue Sep 6 22:41:02 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  13ddc17ddb266d74033d5739fec932034fa85c72 (commit)
       via  ee19eacd1d688d3a98cd66e5ef2f42079eb829f1 (commit)
       via  67cef405cbfad2e53fc388dd6591ee4f7cb0d973 (commit)
      from  875ac9216f1383851a82bd240cadb17c7112f6a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 13ddc17ddb266d74033d5739fec932034fa85c72
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Sep 6 22:40:59 2016 +0200

    g10: Make sure some functions are passed a primary key.
    
    * g10/tofu.c (get_trust): Make sure the caller provides a primary key.
    (tofu_register_signature): Likewise.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/tofu.c b/g10/tofu.c
index 0fda536..9e07d21 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -2011,6 +2011,8 @@ get_trust (ctrl_t ctrl, PKT_public_key *pk,
   if (opt.batch)
     may_ask = 0;
 
+  log_assert (keyid_cmp (pk_keyid (pk), pk->main_keyid) == 0);
+
   /* Make sure _tofu_GET_TRUST_ERROR isn't equal to any of the trust
      levels.  */
   log_assert (_tofu_GET_TRUST_ERROR != TRUST_UNKNOWN
@@ -2778,6 +2780,8 @@ tofu_register_signature (ctrl_t ctrl,
   if (rc)
     return rc;
 
+  log_assert (keyid_cmp (pk_keyid (pk), pk->main_keyid) == 0);
+
   sig_digest = make_radix64_string (sig_digest_bin, sig_digest_bin_len);
   fingerprint = hexfingerprint (pk, NULL, 0);
 

commit ee19eacd1d688d3a98cd66e5ef2f42079eb829f1
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Sep 6 22:27:40 2016 +0200

    g10: Tweak TOFU's verbosity.
    
    * g10/tofu.c (time_ago_str): Only show the most significant unit.
    * g10/tofu.c (show_statistics): Tweak the output.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/tofu.c b/g10/tofu.c
index f5e3273..0fda536 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -2343,7 +2343,7 @@ time_ago_str (long long int t)
       first = i;
     }
   i ++;
-  if ((first == -1 || i - first <= 3) && months)
+  if ((first == -1 || i - first <= 3) && count <= 0 && months)
     {
       if (count)
         es_fprintf (fp, ", ");
@@ -2352,7 +2352,7 @@ time_ago_str (long long int t)
       first = i;
     }
   i ++;
-  if ((first == -1 || i - first <= 3) && count < 2 && days)
+  if ((first == -1 || i - first <= 3) && count <= 0 && days)
     {
       if (count)
         es_fprintf (fp, ", ");
@@ -2361,7 +2361,7 @@ time_ago_str (long long int t)
       first = i;
     }
   i ++;
-  if ((first == -1 || i - first <= 3) && count < 2 && hours)
+  if ((first == -1 || i - first <= 3) && count <= 0 && hours)
     {
       if (count)
         es_fprintf (fp, ", ");
@@ -2370,7 +2370,7 @@ time_ago_str (long long int t)
       first = i;
     }
   i ++;
-  if ((first == -1 || i - first <= 3) && count < 2 && minutes)
+  if ((first == -1 || i - first <= 3) && count <= 0 && minutes)
     {
       if (count)
         es_fprintf (fp, ", ");
@@ -2379,7 +2379,7 @@ time_ago_str (long long int t)
       first = i;
     }
   i ++;
-  if ((first == -1 || i - first <= 3) && count < 2)
+  if ((first == -1 || i - first <= 3) && count <= 0)
     {
       if (count)
         es_fprintf (fp, ", ");
@@ -2482,6 +2482,8 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
 
   int show_warning = 0;
 
+  (void) user_id;
+
   fingerprint_pp = format_hexfingerprint (fingerprint, NULL, 0);
 
   /* Get the signature stats.  */
@@ -2568,10 +2570,11 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
         log_fatal ("error creating memory stream: %s\n",
                    gpg_strerror (gpg_error_from_syserror()));
 
+      es_fprintf (fp, _("%s: "), email);
+
       if (signature_count == 0)
         {
-          es_fprintf (fp, _("Verified %ld messages signed by \"%s\"."),
-                      0L, user_id);
+          es_fprintf (fp, _("Verified %ld signatures"), 0L);
           es_fputc ('\n', fp);
         }
       else
@@ -2581,31 +2584,17 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
           /* TRANSLATORS: The final %s is replaced by a string like
              "7 months, 1 day, 5 minutes, 0 seconds". */
           es_fprintf (fp,
-                      ngettext("Verified %ld message signed by \"%s\"\n"
-                               "in the past %s.",
-                               "Verified %ld messages signed by \"%s\"\n"
-                               "in the past %s.",
+                      ngettext("Verified %ld signature in the past %s",
+                               "Verified %ld signatures in the past %s",
                                signature_count),
-                      signature_count, user_id, first_seen_ago_str);
+                      signature_count, first_seen_ago_str);
 
-          if (signature_count > 1)
-            {
-              char *tmpstr = time_ago_str (now - signature_most_recent);
-              es_fputs ("  ", fp);
-              es_fprintf (fp, _("The most recent message was"
-                                " verified %s ago."), tmpstr);
-              xfree (tmpstr);
-            }
           xfree (first_seen_ago_str);
         }
 
-      es_fprintf (fp, "  ");
-
       if (encryption_count == 0)
         {
-          es_fprintf (fp, _("Encrypted %ld messages to \"%s\"."),
-                      0L, user_id);
-          es_fputc ('\n', fp);
+          es_fprintf (fp, _(", and encrypted %ld messages"), 0L);
         }
       else
         {
@@ -2614,21 +2603,11 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
           /* TRANSLATORS: The final %s is replaced by a string like
              "7 months, 1 day, 5 minutes, 0 seconds". */
           es_fprintf (fp,
-                      ngettext("Encrypted %ld message to \"%s\"\n"
-                               "in the past %s.",
-                               "Encrypted %ld messages to \"%s\"\n"
-                               "in the past %s.",
+                      ngettext(", and encrypted %ld message in the past %s",
+                               ", and encrypted %ld messages in the past %s",
                                encryption_count),
-                      encryption_count, user_id, first_done_ago_str);
+                      encryption_count, first_done_ago_str);
 
-          if (encryption_count > 1)
-            {
-              char *tmpstr = time_ago_str (now - encryption_most_recent);
-              es_fputs ("  ", fp);
-              es_fprintf (fp, _("The most recent message was"
-                                " verified %s ago."), tmpstr);
-              xfree (tmpstr);
-            }
           xfree (first_done_ago_str);
         }
 
@@ -2637,10 +2616,10 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
           es_fputs ("  ", fp);
           es_fputc ('(', fp);
           es_fprintf (fp, _("policy: %s"), tofu_policy_str (policy));
-          es_fputs (")\n", fp);
+          es_fputs (").\n", fp);
         }
       else
-        es_fputs ("\n", fp);
+        es_fputs (".\n", fp);
 
 
       {
@@ -2666,19 +2645,26 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
       log_string (GPGRT_LOG_INFO, msg);
       xfree (msg);
 
-      if (policy == TOFU_POLICY_AUTO
-          /* Cf. write_stats_status  */
-          && (sqrtu32 (encryption_count) + sqrtu32 (signature_count)
-              < sqrtu32 (2 * BASIC_TRUST_THRESHOLD)))
+      if (policy == TOFU_POLICY_AUTO)
         {
           if (signature_count == 0)
             log_info (_("Warning: we have yet to see"
                         " a message signed using this key and user id!\n"));
           else if (signature_count == 1)
-            log_info (_("Warning: we've only seen a single message"
+            log_info (_("Warning: we've only seen one message"
                         " signed using this key and user id!\n"));
 
-          show_warning = 1;
+          if (encryption_count == 0)
+            log_info (_("Warning: you have yet to encrypt"
+                        " a message to this key and user id!\n"));
+          else if (encryption_count == 1)
+            log_info (_("Warning: you have only encrypted"
+                        "  one message to this key and user id!\n"));
+
+          /* Cf. write_stats_status  */
+          if (sqrtu32 (encryption_count) + sqrtu32 (signature_count)
+              < sqrtu32 (2 * BASIC_TRUST_THRESHOLD))
+            show_warning = 1;
         }
     }
 

commit 67cef405cbfad2e53fc388dd6591ee4f7cb0d973
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Sep 6 22:10:57 2016 +0200

    g10: Only show the TOFU warning once per key.
    
    * g10/tofu.c (show_statistics): Return whether to call show_warning.
    Move the warning from here...
    (show_warning): ... to this new function.
    (tofu_get_validity): If show_statistics returns a non-zero value, call
    show_warning.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/tofu.c b/g10/tofu.c
index defc54f..f5e3273 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -2454,10 +2454,13 @@ write_stats_status (estream_t fp,
     }
 }
 
-
 /* Note: If OUTFP is not NULL, this function merely prints a "tfs" record
- * to OUTFP.  In this case USER_ID is not required.  */
-static void
+ * to OUTFP.  In this case USER_ID is not required.
+ *
+ * Returns whether the caller should call show_warning after iterating
+ * over all user ids.
+ */
+static int
 show_statistics (tofu_dbs_t dbs, const char *fingerprint,
 		 const char *email, const char *user_id,
 		 estream_t outfp)
@@ -2477,6 +2480,8 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
   unsigned long encryption_most_recent = 0;
   unsigned long encryption_count = 0;
 
+  int show_warning = 0;
+
   fingerprint_pp = format_hexfingerprint (fingerprint, NULL, 0);
 
   /* Get the signature stats.  */
@@ -2666,51 +2671,59 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
           && (sqrtu32 (encryption_count) + sqrtu32 (signature_count)
               < sqrtu32 (2 * BASIC_TRUST_THRESHOLD)))
         {
-          char *set_policy_command;
-          char *text;
-          char *tmpmsg;
-
           if (signature_count == 0)
             log_info (_("Warning: we have yet to see"
-                        " a message signed by this key and user id!\n"));
+                        " a message signed using this key and user id!\n"));
           else if (signature_count == 1)
             log_info (_("Warning: we've only seen a single message"
-                        " signed by this key and user id!\n"));
-
-          set_policy_command =
-            xasprintf ("gpg --tofu-policy bad %s", fingerprint);
-
-          tmpmsg = xasprintf
-            (ngettext
-             ("Warning: if you think you've seen more than %ld message "
-              "signed by this key and user id, then this key might be a "
-              "forgery!  Carefully examine the email address for small "
-              "variations.  If the key is suspect, then use\n"
-              "  %s\n"
-              "to mark it as being bad.\n",
-              "Warning: if you think you've seen more than %ld messages "
-              "signed by this key, then this key might be a forgery!  "
-              "Carefully examine the email address for small "
-              "variations.  If the key is suspect, then use\n"
-              "  %s\n"
-              "to mark it as being bad.\n",
-              signature_count),
-             signature_count, set_policy_command);
-          text = format_text (tmpmsg, 0, 72, 80);
-          xfree (tmpmsg);
-          log_string (GPGRT_LOG_INFO, text);
-          xfree (text);
-
-          es_free (set_policy_command);
+                        " signed using this key and user id!\n"));
+
+          show_warning = 1;
         }
     }
 
  out:
   xfree (fingerprint_pp);
 
-  return;
+  return show_warning;
 }
 
+static void
+show_warning (const char *fingerprint, strlist_t user_id_list)
+{
+  char *set_policy_command;
+  char *text;
+  char *tmpmsg;
+
+  set_policy_command =
+    xasprintf ("gpg --tofu-policy bad %s", fingerprint);
+
+  tmpmsg = xasprintf
+    (ngettext
+     ("Warning: if you think you've seen more signatures "
+      "by this key and user id, then this key might be a "
+      "forgery!  Carefully examine the email address for small "
+      "variations.  If the key is suspect, then use\n"
+      "  %s\n"
+      "to mark it as being bad.\n",
+      "Warning: if you think you've seen more signatures "
+      "by this key and these user ids, then this key might be a "
+      "forgery!  Carefully examine the email addresses for small "
+      "variations.  If the key is suspect, then use\n"
+      "  %s\n"
+      "to mark it as being bad.\n",
+      strlist_length (user_id_list)),
+     set_policy_command);
+
+  text = format_text (tmpmsg, 0, 72, 80);
+  xfree (tmpmsg);
+  log_string (GPGRT_LOG_INFO, text);
+  xfree (text);
+
+  es_free (set_policy_command);
+}
+
+
 /* Extract the email address from a user id and normalize it.  If the
    user id doesn't contain an email address, then we use the whole
    user_id and normalize that.  The returned string must be freed.  */
@@ -3120,6 +3133,7 @@ tofu_get_validity (ctrl_t ctrl, PKT_public_key *pk, strlist_t user_id_list,
   int trust_level = TRUST_UNKNOWN;
   int bindings = 0;
   int bindings_valid = 0;
+  int need_warning = 0;
 
   dbs = opendbs (ctrl);
   if (! dbs)
@@ -3162,7 +3176,8 @@ tofu_get_validity (ctrl_t ctrl, PKT_public_key *pk, strlist_t user_id_list,
         bindings_valid ++;
 
       if (may_ask && tl != TRUST_ULTIMATE && tl != TRUST_EXPIRED)
-        show_statistics (dbs, fingerprint, email, user_id->d, NULL);
+        need_warning |=
+          show_statistics (dbs, fingerprint, email, user_id->d, NULL);
 
       if (tl == TRUST_NEVER)
         trust_level = TRUST_NEVER;
@@ -3188,6 +3203,9 @@ tofu_get_validity (ctrl_t ctrl, PKT_public_key *pk, strlist_t user_id_list,
       xfree (email);
     }
 
+  if (need_warning)
+    show_warning (fingerprint, user_id_list);
+
  die:
   tofu_end_batch_update (ctrl);
 

-----------------------------------------------------------------------

Summary of changes:
 g10/tofu.c | 172 ++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 90 insertions(+), 82 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list