[git] GnuPG - branch, master, updated. gnupg-2.1.15-255-g71158d8

by Justus Winter cvs at cvs.gnupg.org
Thu Oct 20 17:04:15 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  71158d8d5f823888abc8588caa6497860ce59c06 (commit)
       via  ca9597f080f70a8435daaeb5449bef0462a1402a (commit)
       via  8c7c4faf3de28ca70a60e6b15f51c1b206e0ddd9 (commit)
       via  bf37916a23bd0929fc4a5f28c9a41f43c5a473f6 (commit)
       via  2d794779e0fd9d9a1efc98e7bd77a296a25f4293 (commit)
      from  9a34e2142b426b98c73fd888102ea1596bbce62a (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 71158d8d5f823888abc8588caa6497860ce59c06
Author: Justus Winter <justus at g10code.com>
Date:   Thu Oct 20 16:54:06 2016 +0200

    tests: Simplify test.
    
    * tests/openpgp/quick-key-manipulation.scm: Avoid creating a temporary
    home directory, just make the uids unique.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/quick-key-manipulation.scm b/tests/openpgp/quick-key-manipulation.scm
index 8a3e3f1..b6411d0 100755
--- a/tests/openpgp/quick-key-manipulation.scm
+++ b/tests/openpgp/quick-key-manipulation.scm
@@ -33,55 +33,50 @@
 		   `(--with-fingerprint
 		     --list-secret-keys ,(exact id))))))
 
-(define old-home (getenv "GNUPGHOME"))
-(define alpha "Alpha <alpha at example.net>")
-(define bravo "Bravo <bravo at example.net>")
+(define alpha "Alpha <alpha at invalid.example.net>")
+(define bravo "Bravo <bravo at invalid.example.net>")
 
 (define (key-data key)
   (filter (lambda (x) (or (string=? (car x) "pub")
                           (string=? (car x) "sub")))
           (gpg-with-colons `(-k ,key))))
 
-(with-temporary-working-directory
- (file-copy (path-join old-home "gpg.conf") "gpg.conf")
- (file-copy (path-join old-home "gpg-agent.conf") "gpg-agent.conf")
- (setenv "GNUPGHOME" "." #t)
- (setenv "PINENTRY_USER_DATA" "test" #t)
+(setenv "PINENTRY_USER_DATA" "test" #t)
 
- (info "Checking quick key generation...")
- (call-check `(, at GPG --quick-gen-key ,alpha))
+(info "Checking quick key generation...")
+(call-check `(, at GPG --quick-gen-key ,alpha))
 
- (call-check `(, at GPG --check-trustdb)) ; XXX why?
+(call-check `(, at GPG --check-trustdb)) ; XXX why?
 
- (assert (= 1 (count-uids-of-secret-key alpha)))
+(assert (= 1 (count-uids-of-secret-key alpha)))
 
- (info "Checking that we can add a user ID...")
+(info "Checking that we can add a user ID...")
 
- ;; Make sure the key capabilities don't change when we add a user id.
- ;; (See bug #2697.)
- (let ((pre (key-data (exact alpha)))
-       (result (call-check `(, at GPG --quick-adduid ,(exact alpha) ,bravo)))
-       (post (key-data (exact alpha))))
-   (if (not (equal? pre post))
-       (begin
-         (display "Key capabilities changed when adding a user id:")
-         (newline)
-         (display "  Pre: ")
-         (display pre)
-         (newline)
-         (display " Post: ")
-         (display post)
-         (newline)
-         (exit 1))))
+;; Make sure the key capabilities don't change when we add a user id.
+;; (See bug #2697.)
+(let ((pre (key-data (exact alpha)))
+      (result (call-check `(, at GPG --quick-adduid ,(exact alpha) ,bravo)))
+      (post (key-data (exact alpha))))
+  (if (not (equal? pre post))
+      (begin
+	(display "Key capabilities changed when adding a user id:")
+	(newline)
+	(display "  Pre: ")
+	(display pre)
+	(newline)
+	(display " Post: ")
+	(display post)
+	(newline)
+	(exit 1))))
 
- (call-check `(, at GPG --check-trustdb)) ; XXX why?
+(call-check `(, at GPG --check-trustdb)) ; XXX why?
 
- (assert (= 2 (count-uids-of-secret-key alpha)))
- (assert (= 2 (count-uids-of-secret-key bravo)))
+(assert (= 2 (count-uids-of-secret-key alpha)))
+(assert (= 2 (count-uids-of-secret-key bravo)))
 
- (info "Checking that we can revoke a user ID...")
- (call-check `(, at GPG --quick-revuid ,(exact bravo) ,alpha))
+(info "Checking that we can revoke a user ID...")
+(call-check `(, at GPG --quick-revuid ,(exact bravo) ,alpha))
 
- (call-check `(, at GPG --check-trustdb)) ; XXX why?
+(call-check `(, at GPG --check-trustdb)) ; XXX why?
 
- (assert (= 1 (count-uids-of-secret-key bravo))))
+(assert (= 1 (count-uids-of-secret-key bravo)))

commit ca9597f080f70a8435daaeb5449bef0462a1402a
Author: Justus Winter <justus at g10code.com>
Date:   Thu Oct 20 16:50:11 2016 +0200

    tests: Flush stdout in the fake pinentry.
    
    * tests/openpgp/fake-pinentry.c (reply): Flush stdout.
    
    Fixes-commit: 94504b3d5af126abb591dedda1ca0f0970822f55
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/fake-pinentry.c b/tests/openpgp/fake-pinentry.c
index 6ef6126..ce89765 100644
--- a/tests/openpgp/fake-pinentry.c
+++ b/tests/openpgp/fake-pinentry.c
@@ -42,6 +42,7 @@ reply (const char *fmt, ...)
   result = vprintf (fmt, ap);
   va_end (ap);
 
+  fflush (stdout);
   return result;
 }
 

commit 8c7c4faf3de28ca70a60e6b15f51c1b206e0ddd9
Author: Justus Winter <justus at g10code.com>
Date:   Thu Oct 20 16:45:18 2016 +0200

    common,w32: Fix setting environment variables on Windows.
    
    * common/sysutils.c (gnupg_setenv): Also update the environment block
    maintained by the C runtime.
    (gnupg_unsetenv): Likewise.
    * tests/gpgscm/ffi.c (do_setenv): Fix error handling.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/common/sysutils.c b/common/sysutils.c
index 2e663bc..85eb203 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -754,38 +754,51 @@ gnupg_setenv (const char *name, const char *value, int overwrite)
   (void)value;
   (void)overwrite;
   return 0;
-#elif defined(HAVE_W32_SYSTEM)
-  if (!overwrite)
-    {
-      char tmpbuf[10];
-      if (GetEnvironmentVariable (name, tmpbuf, sizeof tmpbuf))
-        return 0; /* Exists but overwrite was not requested.  */
-    }
-  if (!SetEnvironmentVariable (name, value))
-    {
-      gpg_err_set_errno (EINVAL); /* (Might also be ENOMEM.) */
-      return -1;
-    }
-  return 0;
-#elif defined(HAVE_SETENV)
-  return setenv (name, value, overwrite);
 #else
-  char *buf;
+#if defined(HAVE_W32_SYSTEM)
+  /*  Windows maintains (at least) two sets of environment variables.
+      One set can be accessed by GetEnvironmentVariable and
+      SetEnvironmentVariable.  This set is inherited by the children.
+      The other set is maintained in the C runtime, and is accessed
+      using getenv and putenv.  We try to keep them in sync by
+      modifying both sets.  */
+  {
+    int exists;
+    char tmpbuf[10];
+    exists = GetEnvironmentVariable (name, tmpbuf, sizeof tmpbuf);
+
+    if ((! exists || overwrite) && !SetEnvironmentVariable (name, value))
+      {
+        gpg_err_set_errno (EINVAL); /* (Might also be ENOMEM.) */
+        return -1;
+      }
+  }
+#endif
 
-  (void)overwrite;
-  if (!name || !value)
+#if defined(HAVE_SETENV)
+  return setenv (name, value, overwrite);
+#else
+  if (! getenv (name) || overwrite)
     {
-      gpg_err_set_errno (EINVAL);
-      return -1;
-    }
-  buf = xtrymalloc (strlen (name) + 1 + strlen (value) + 1);
-  if (!buf)
-    return -1;
-  strcpy (stpcpy (stpcpy (buf, name), "="), value);
+      char *buf;
+
+      (void)overwrite;
+      if (!name || !value)
+        {
+          gpg_err_set_errno (EINVAL);
+          return -1;
+        }
+      buf = xtrymalloc (strlen (name) + 1 + strlen (value) + 1);
+      if (!buf)
+        return -1;
+      strcpy (stpcpy (stpcpy (buf, name), "="), value);
 #if __GNUC__
 # warning no setenv - using putenv but leaking memory.
 #endif
-  return putenv (buf);
+      return putenv (buf);
+    }
+  return 0;
+#endif
 #endif
 }
 
@@ -796,30 +809,40 @@ gnupg_unsetenv (const char *name)
 #ifdef HAVE_W32CE_SYSTEM
   (void)name;
   return 0;
-#elif defined(HAVE_W32_SYSTEM)
+#else
+#if defined(HAVE_W32_SYSTEM)
+  /*  Windows maintains (at least) two sets of environment variables.
+      One set can be accessed by GetEnvironmentVariable and
+      SetEnvironmentVariable.  This set is inherited by the children.
+      The other set is maintained in the C runtime, and is accessed
+      using getenv and putenv.  We try to keep them in sync by
+      modifying both sets.  */
   if (!SetEnvironmentVariable (name, NULL))
     {
       gpg_err_set_errno (EINVAL); /* (Might also be ENOMEM.) */
       return -1;
     }
-  return 0;
-#elif defined(HAVE_UNSETENV)
+#endif
+#if defined(HAVE_UNSETENV)
   return unsetenv (name);
 #else
-  char *buf;
-
-  if (!name)
-    {
-      gpg_err_set_errno (EINVAL);
+  {
+    char *buf;
+
+    if (!name)
+      {
+        gpg_err_set_errno (EINVAL);
+        return -1;
+      }
+    buf = xtrystrdup (name);
+    if (!buf)
       return -1;
-    }
-  buf = xtrystrdup (name);
-  if (!buf)
-    return -1;
 #if __GNUC__
 # warning no unsetenv - trying putenv but leaking memory.
 #endif
-  return putenv (buf);
+    return putenv (buf);
+  }
+#endif
 #endif
 }
 
diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c
index a0fbe2e..8e21ba6 100644
--- a/tests/gpgscm/ffi.c
+++ b/tests/gpgscm/ffi.c
@@ -236,7 +236,9 @@ do_setenv (scheme *sc, pointer args)
   FFI_ARG_OR_RETURN (sc, char *, value, string, args);
   FFI_ARG_OR_RETURN (sc, int, overwrite, bool, args);
   FFI_ARGS_DONE_OR_RETURN (sc, args);
-  FFI_RETURN_ERR (sc, gnupg_setenv (name, value, overwrite));
+  if (gnupg_setenv (name, value, overwrite))
+    FFI_RETURN_ERR (sc, gpg_error_from_syserror ());
+  FFI_RETURN (sc);
 }
 
 static pointer

commit bf37916a23bd0929fc4a5f28c9a41f43c5a473f6
Author: Justus Winter <justus at g10code.com>
Date:   Thu Oct 20 16:41:18 2016 +0200

    tests,w32: Cope with Windows line endings.
    
    * tests/openpgp/issue2015.scm: Rstrip line before comparison.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/issue2015.scm b/tests/openpgp/issue2015.scm
index 536cb8f..e51ece4 100755
--- a/tests/openpgp/issue2015.scm
+++ b/tests/openpgp/issue2015.scm
@@ -25,5 +25,6 @@
 
 (let ((response (call-popen `(,(tool 'gpg-connect-agent))
 			    "GET_PASSPHRASE --no-ask some_id X X X")))
-  (unless (string=? response "OK 736F6D655F70617373706872617365\n")
+  (unless (string=? (string-rtrim char-whitespace? response)
+		    "OK 736F6D655F70617373706872617365")
 	  (error "Could not retrieve passphrase from cache:" response)))

commit 2d794779e0fd9d9a1efc98e7bd77a296a25f4293
Author: Justus Winter <justus at g10code.com>
Date:   Thu Oct 20 11:37:26 2016 +0200

    tests: Create and remove socket directories.
    
    * tests/openpgp/defs.scm (start-agent): Move function here and create
    the socket directory prior to starting the agent.
    (stop-agent): Move function here and remove the socket directory.
    * tests/openpgp/finish.scm: Adapt.
    * tests/openpgp/setup.scm: Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index e484e86..48ac46c 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -146,3 +146,20 @@
 (let ((verbose (string->number (getenv "verbose"))))
   (if (number? verbose)
       (*set-verbose!* verbose)))
+
+;; Create the socket dir and start the agent.
+(define (start-agent)
+  (echo "Starting gpg-agent...")
+  (catch (echo "Warning: Creating socket directory failed:" (car *error*))
+	 (call-popen `(,(tool 'gpgconf) --create-socketdir) ""))
+  (call-check `(,(tool 'gpg-connect-agent) --verbose
+		,(string-append "--agent-program=" (tool 'gpg-agent)
+				"|--debug-quick-random")
+		/bye)))
+
+;; Stop the agent and remove the socket dir.
+(define (stop-agent)
+  (echo "Stopping gpg-agent...")
+  (catch (echo "Warning: Removing socket directory failed.")
+	 (call-popen `(,(tool 'gpgconf) --remove-socketdir) ""))
+  (call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye)))
diff --git a/tests/openpgp/finish.scm b/tests/openpgp/finish.scm
index 48801c8..37845ae 100755
--- a/tests/openpgp/finish.scm
+++ b/tests/openpgp/finish.scm
@@ -19,5 +19,4 @@
 
 (load (with-path "defs.scm"))
 
-(echo "Killing gpg-agent...")
-(call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye))
+(stop-agent)
diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm
index 75310d1..99fbdea 100755
--- a/tests/openpgp/setup.scm
+++ b/tests/openpgp/setup.scm
@@ -95,13 +95,7 @@
    (pipe:spawn `(, at GPG --dearmor))
    (pipe:spawn `(, at GPG --yes --import))))
 
-(define (start-agent)
-  (echo "Starting gpg-agent...")
-  (call-check `(,(tool 'gpg-connect-agent) --verbose
-		,(string-append "--agent-program=" (tool 'gpg-agent)
-				"|--debug-quick-random")
-		/bye))
-
+(define (preset-passphrases)
   (info "Preset passphrases")
   ;; one at example.com
   (call-check `(,(tool 'gpg-preset-passphrase)
@@ -119,19 +113,18 @@
 		"A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD"))
   (echo "All set up."))
 
-(define (kill-agent)
-  (call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye)))
-
 (cond
  ((member "--create-tarball" *args*)
   (with-temporary-working-directory
    (setenv "GNUPGHOME" (getcwd) #t)
    (create-gpghome)
-   (kill-agent)
+   (stop-agent)
    (call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) "."))))
  ((member "--unpack-tarball" *args*)
   (call-check `(,(tool 'gpgtar) --extract --directory=. ,(cadr *args*)))
-  (start-agent))
+  (start-agent)
+  (preset-passphrases))
  (else
   (create-gpghome)
-  (start-agent)))
+  (start-agent)
+  (preset-passphrases)))

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

Summary of changes:
 common/sysutils.c                        | 101 +++++++++++++++++++------------
 tests/gpgscm/ffi.c                       |   4 +-
 tests/openpgp/defs.scm                   |  17 ++++++
 tests/openpgp/fake-pinentry.c            |   1 +
 tests/openpgp/finish.scm                 |   3 +-
 tests/openpgp/issue2015.scm              |   3 +-
 tests/openpgp/quick-key-manipulation.scm |  67 ++++++++++----------
 tests/openpgp/setup.scm                  |  19 ++----
 8 files changed, 123 insertions(+), 92 deletions(-)


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




More information about the Gnupg-commits mailing list