Description: Update tests for gnupg2 changes
The tests currently rely on gnupg1 formatted outputs, so pass
parameters to gnupg that . Additionally, it
seems some new parameters are needed to get batch behavior correctly.
Thanks to https://github.com/keybase/keybase-issues/issues/1712 for
related, but not identical, issues and solution suggestions.
Author: Nishanth Aravamudan <nish.aravamudan@canonical.com>
Bug-Ubuntu: https://launchpad.net/bugs/1652133
Last-Update: 2016-12-22
--- a/Horde_Crypt-2.7.5/lib/Horde/Crypt/Pgp/Backend/Binary.php
+++ b/Horde_Crypt-2.7.5/lib/Horde/Crypt/Pgp/Backend/Binary.php
@@ -75,8 +75,15 @@
'--no-options',
'--no-default-keyring',
'--yes',
- '--homedir ' . $this->_tempdir
+ '--homedir ' . $this->_tempdir,
+ '--keyid-format short'
);
+
+ $result = $this->_callGpg(array('--version'), 'r', null, false, false, true);
+ /* gpg > 1.x requires specifying the pinentry-mode */
+ if (!preg_match('/gpg \(GnuPG\) = (1\.[0-9\.]+)/', $result->stdout, $m)) {
+ $this->_gnupg[] = '--pinentry-mode loopback';
+ }
}
/**
@@ -678,6 +685,7 @@
if ($parseable) {
putenv('LANGUAGE=C');
}
+ putenv('GPG_TTY=$(tty)');
if ($mode == 'w') {
if ($fp = popen($cmdline, 'w')) {
putenv('LANGUAGE=' . $language);
@@ -723,6 +731,17 @@
}
}
+ $cmdline = array(
+ 'killall',
+ '--quiet',
+ '-SIGHUP',
+ 'gpg-agent'
+ );
+ if (!($fp = popen(implode(' ', $cmdline), 'r'))) {
+ throw new HordeCrypt_Exception(Horde_Crypt_Translation::t("Error while dropping passphrases from agent cache."));
+ }
+ pclose($fp);
+
return $data;
}