[git] GnuPG - branch, master, updated. gnupg-2.1.15-29-ge4d5e3c

by Neal H. Walfield cvs at cvs.gnupg.org
Wed Aug 31 11:52:26 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  e4d5e3cb0d10e8f77c7100d42cfdb32051de1c18 (commit)
       via  247eef005cf4c34e9a82227e4ab7823e04911be4 (commit)
      from  70df5a8fd781d8774d835384ca28c4d8518bb9d0 (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 e4d5e3cb0d10e8f77c7100d42cfdb32051de1c18
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Aug 31 11:40:33 2016 +0200

    g10: Update a key's TOFU policy in a transaction.
    
    * g10/tofu.c (tofu_set_policy): Do the update in a transaction.
    * g10/gpg.c (main): Do a TOFU policy update in a batch transaction.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/gpg.c b/g10/gpg.c
index 3193e74..a9770d7 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -4664,6 +4664,8 @@ main (int argc, char **argv)
 	  if (! hd)
             g10_exit (1);
 
+          tofu_begin_batch_update (ctrl);
+
 	  for (i = 1; i < argc; i ++)
 	    {
 	      KEYDB_SEARCH_DESC desc;
@@ -4721,8 +4723,9 @@ main (int argc, char **argv)
 		g10_exit (1);
 	    }
 
-	  keydb_release (hd);
+          tofu_end_batch_update (ctrl);
 
+	  keydb_release (hd);
 	}
 #endif /*USE_TOFU*/
 	break;
diff --git a/g10/tofu.c b/g10/tofu.c
index 137065a..4285e96 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -2584,6 +2584,8 @@ tofu_set_policy (ctrl_t ctrl, kbnode_t kb, enum tofu_policy policy)
 
   fingerprint = hexfingerprint (pk, NULL, 0);
 
+  begin_transaction (ctrl);
+
   for (; kb; kb = kb->next)
     {
       PKT_user_id *user_id;
@@ -2605,6 +2607,8 @@ tofu_set_policy (ctrl_t ctrl, kbnode_t kb, enum tofu_policy policy)
       xfree (email);
     }
 
+  end_transaction (ctrl, 0);
+
   xfree (fingerprint);
   return 0;
 }

commit 247eef005cf4c34e9a82227e4ab7823e04911be4
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Aug 31 11:39:35 2016 +0200

    g10: Fix the show old policy functionality when changing a TOFU policy.
    
    * g10/tofu.c (record_binding): Fix the show old policy functionality.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/tofu.c b/g10/tofu.c
index 62c6efc..137065a 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -767,10 +767,6 @@ record_binding (tofu_dbs_t dbs, const char *fingerprint, const char *email,
   char *fingerprint_pp = format_hexfingerprint (fingerprint, NULL, 0);
   gpg_error_t rc;
   char *err = NULL;
-  /* policy_old needs to be a long and not an enum tofu_policy,
-     because we pass it by reference to get_single_long_cb2, which
-     expects a long.  */
-  long policy_old = TOFU_POLICY_NONE;
 
   if (! (policy == TOFU_POLICY_AUTO
 	 || policy == TOFU_POLICY_GOOD
@@ -780,11 +776,17 @@ record_binding (tofu_dbs_t dbs, const char *fingerprint, const char *email,
     log_bug ("%s: Bad value for policy (%d)!\n", __func__, policy);
 
 
-  if (show_old)
+  if (DBG_TRUST || show_old)
     {
       /* Get the old policy.  Since this is just for informational
        * purposes, there is no need to start a transaction or to die
        * if there is a failure.  */
+
+      /* policy_old needs to be a long and not an enum tofu_policy,
+         because we pass it by reference to get_single_long_cb2, which
+         expects a long.  */
+      long policy_old = TOFU_POLICY_NONE;
+
       rc = gpgsql_stepx
 	(dbs->db, &dbs->s.record_binding_get_old_policy,
          get_single_long_cb2, &policy_old, &err,
@@ -799,28 +801,27 @@ record_binding (tofu_dbs_t dbs, const char *fingerprint, const char *email,
 	  sqlite3_free (err);
 	}
 
-      if (DBG_TRUST)
+      if (policy_old != TOFU_POLICY_NONE)
+        (show_old ? log_info : log_debug)
+          ("Changing TOFU trust policy for binding"
+           " <key: %s, user id: %s> from %s to %s.\n",
+           fingerprint, show_old ? user_id : email,
+           tofu_policy_str (policy_old),
+           tofu_policy_str (policy));
+      else
+        (show_old ? log_info : log_debug)
+          ("Setting TOFU trust policy for new binding"
+           " <key: %s, user id: %s> to %s.\n",
+           fingerprint, show_old ? user_id : email,
+           tofu_policy_str (policy));
+
+      if (policy_old == policy)
         {
-          if (policy_old != TOFU_POLICY_NONE)
-            log_debug ("Changing TOFU trust policy for binding"
-                       " <key: %s, user id: %s> from %s to %s.\n",
-                       fingerprint, email,
-                       tofu_policy_str (policy_old),
-                       tofu_policy_str (policy));
-          else
-            log_debug ("Setting TOFU trust policy for new binding"
-                       " <key: %s, user id: %s> to %s.\n",
-                       fingerprint, email,
-                       tofu_policy_str (policy));
+          rc = 0;
+          goto leave; /* Nothing to do.  */
         }
     }
 
-  if (policy_old == policy)
-    {
-      rc = 0;
-      goto leave; /* Nothing to do.  */
-    }
-
   if (opt.dry_run)
     {
       log_info ("TOFU database update skipped due to --dry-run\n");

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

Summary of changes:
 g10/gpg.c  |  5 ++++-
 g10/tofu.c | 51 ++++++++++++++++++++++++++++-----------------------
 2 files changed, 32 insertions(+), 24 deletions(-)


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




More information about the Gnupg-commits mailing list