[Pkg-gnupg-commit] [gnupg2] 07/132: tests: Fix setup of ephemeral home directories.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed May 17 03:07:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gnupg2.
commit 32b75fb7743f35936d7014fce33c90ba97dfa374
Author: Justus Winter <justus at g10code.com>
Date: Tue Apr 4 14:32:04 2017 +0200
tests: Fix setup of ephemeral home directories.
* tests/openpgp/defs.scm (with-ephemeral-home-directory): Create
configuration files when we enter the context.
* tests/openpgp/setup.scm: Do not use an ephemeral home directory.
Tests should always use the cwd.
* tests/gpgsm/setup.scm: Likewise.
* tests/gpgsm/export.scm: Add explicit constructor function.
* tests/openpgp/decrypt-session-key.scm: Likewise.
* tests/openpgp/decrypt-unwrap-verify.scm: Likewise.
--
Previously, ephemeral homedirectories lacked a configuration, hence
GnuPG tried to start backend daemons using their installed locations.
Fix this by explicitly creating a suitable configuration.
GnuPG-bug-id: 3047
Signed-off-by: Justus Winter <justus at g10code.com>
---
tests/gpgsm/export.scm | 2 +-
tests/gpgsm/setup.scm | 8 +++-----
tests/openpgp/decrypt-session-key.scm | 2 +-
tests/openpgp/decrypt-unwrap-verify.scm | 2 +-
tests/openpgp/defs.scm | 12 ++++++++----
tests/openpgp/setup.scm | 13 ++++++-------
6 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/tests/gpgsm/export.scm b/tests/gpgsm/export.scm
index 1ee91e4..47fb06e 100644
--- a/tests/gpgsm/export.scm
+++ b/tests/gpgsm/export.scm
@@ -25,7 +25,7 @@
(lambda (cert)
(lettmp (exported)
(call-check `(, at gpgsm --output ,exported --export ,cert::uid::CN))
- (with-ephemeral-home-directory
+ (with-ephemeral-home-directory setup-gpgsm-environment
(call-check `(, at gpgsm --import ,exported))
(assert (sm-have-public-key? cert)))))
(lambda (cert) cert::uid::CN)
diff --git a/tests/gpgsm/setup.scm b/tests/gpgsm/setup.scm
index 91821a0..aa1ab41 100644
--- a/tests/gpgsm/setup.scm
+++ b/tests/gpgsm/setup.scm
@@ -23,8 +23,6 @@
(unless (and tarball (not (null? tarball)))
(error "Usage: setup.scm --create-tarball <file> ..."))
-(with-ephemeral-home-directory
- (chdir (getenv "GNUPGHOME"))
- (create-gpgsmhome)
- (stop-agent)
- (call-check `(,(tool 'gpgtar) --create --output ,(car tarball) ".")))
+(setenv "GNUPGHOME" (getcwd) #t)
+(create-gpgsmhome)
+(call-check `(,(tool 'gpgtar) --create --output ,(car tarball) "."))
diff --git a/tests/openpgp/decrypt-session-key.scm b/tests/openpgp/decrypt-session-key.scm
index 771b53d..989ce30 100755
--- a/tests/openpgp/decrypt-session-key.scm
+++ b/tests/openpgp/decrypt-session-key.scm
@@ -37,7 +37,7 @@
(lambda (name)
(let* ((source (in-srcdir (string-append name ".asc")))
(key (get-session-key source)))
- (with-ephemeral-home-directory
+ (with-ephemeral-home-directory setup-environment
(tr:do
(tr:open source)
(tr:gpg "" `(--yes --decrypt --override-session-key ,key))
diff --git a/tests/openpgp/decrypt-unwrap-verify.scm b/tests/openpgp/decrypt-unwrap-verify.scm
index 97a72e4..ef9a99a 100755
--- a/tests/openpgp/decrypt-unwrap-verify.scm
+++ b/tests/openpgp/decrypt-unwrap-verify.scm
@@ -35,7 +35,7 @@
;; Then, verify the signature with a clean working directory
;; containing only Steve's public key.
- (with-ephemeral-home-directory
+ (with-ephemeral-home-directory setup-environment
(call-check `(, at gpg --import ,steve's-key))
(call-check `(, at gpg --verify ,unwrapped)))))
'("encsig-2-keys-3" "encsig-2-keys-4")))
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index e8d06c0..4271ba0 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -289,14 +289,18 @@
;; Evaluate a sequence of expressions with an ephemeral home
;; directory.
-(define-macro (with-ephemeral-home-directory . expressions)
+(define-macro (with-ephemeral-home-directory setup-fn . expressions)
(let ((original-home-directory (gensym))
- (ephemeral-home-directory (gensym)))
+ (ephemeral-home-directory (gensym))
+ (setup (gensym)))
`(let ((,original-home-directory (getenv "GNUPGHOME"))
- (,ephemeral-home-directory (mkdtemp)))
+ (,ephemeral-home-directory (mkdtemp))
+ (,setup (delay (,setup-fn))))
(finally (unlink-recursively ,ephemeral-home-directory)
(dynamic-wind
- (lambda () (setenv "GNUPGHOME" ,ephemeral-home-directory #t))
+ (lambda ()
+ (force ,setup)
+ (setenv "GNUPGHOME" ,ephemeral-home-directory #t))
(lambda () , at expressions)
(lambda () (setenv "GNUPGHOME" ,original-home-directory #t)))))))
diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm
index 4b3bfcb..a7d14e7 100755
--- a/tests/openpgp/setup.scm
+++ b/tests/openpgp/setup.scm
@@ -40,10 +40,9 @@
'(gpgconf gpg gpg-agent scdaemon gpgsm dirmngr gpg-connect-agent
gpg-preset-passphrase gpgtar pinentry)))
-(with-ephemeral-home-directory
- (chdir (getenv "GNUPGHOME"))
- (create-gpghome)
- (start-agent)
- (create-legacy-gpghome)
- (stop-agent)
- (call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) ".")))
+(setenv "GNUPGHOME" (getcwd) #t)
+(create-gpghome)
+(start-agent)
+(create-legacy-gpghome)
+(stop-agent)
+(call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) "."))
--
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