]> Nutra Git (v2) - gamesguru/git-remote-gcrypt.git/commitdiff
Fix to work when there is no controlling terminal, but GPG_AGENT_INFO is set. Pass...
authorJoey Hess <joey@kitenet.net>
Thu, 15 May 2014 18:27:56 +0000 (14:27 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 15 May 2014 18:27:56 +0000 (14:27 -0400)
debian/changelog
git-remote-gcrypt

index 19dcbb104ea7da29847d144924f1a9f4f9c63bd7..89ce70a82333c9653938a3edbf82d319e07e7742 100644 (file)
@@ -1,3 +1,12 @@
+git-remote-gcrypt (0.20130908-6) UNRELEASED; urgency=medium
+
+  * Fix to work when there is no controlling terminal, but GPG_AGENT_INFO
+    is set. Pass --no-tty to gpg in this situation. This is needed
+    to interoperate with the git-annex assistant, which often runs without
+    a controlling terminal, and will in a new version always do so.
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 15 May 2014 14:25:52 -0400
+
 git-remote-gcrypt (0.20130908-5) unstable; urgency=low
 
   * Better signature validation for subkeys.
index 22f19dd04a17b55d1c91c192c1f8aaa287462273..d4407b1984e61d95c35e82c2d08af909eb1e9c23 100755 (executable)
@@ -18,7 +18,6 @@
 # See README.rst for usage instructions
 
 set -e # errexit
-set -u # nounset
 set -f # noglob
 set -C # noclobber
 
@@ -313,14 +312,14 @@ CLEAN_FINAL()
 
 ENCRYPT()
 {
-       gpg --batch --force-mdc --compress-algo none --trust-model=always --passphrase-fd 3 -c 3<<EOF
+       rungpg --batch --force-mdc --compress-algo none --trust-model=always --passphrase-fd 3 -c 3<<EOF
 $1
 EOF
 }
 
 DECRYPT()
 {
-       gpg -q --batch --no-default-keyring --secret-keyring /dev/null \
+       rungpg -q --batch --no-default-keyring --secret-keyring /dev/null \
                --keyring /dev/null --passphrase-fd 3 -d  3<<EOF
 $1
 EOF
@@ -333,7 +332,7 @@ PRIVENCRYPT()
        if isnonnull "$Conf_signkey"; then
                set -- "$@" -u "$Conf_signkey"
        fi
-       gpg --compress-algo none --trust-model=always -se "$@"
+       rungpg --compress-algo none --trust-model=always -se "$@"
 }
 
 # $1 is the match for good signature, $2 is the textual signers list
@@ -341,7 +340,7 @@ PRIVDECRYPT()
 {
        local status_=
        exec 4>&1 &&
-       status_=$(gpg  --status-fd 3 -q -d 3>&1 1>&4) &&
+       status_=$(rungpg --status-fd 3 -q -d 3>&1 1>&4) &&
        xfeed "$status_" grep "^\[GNUPG:\] ENC_TO " >/dev/null &&
        (xfeed "$status_" grep -e "$1" >/dev/null || {
                echo_info "Failed to verify manifest signature!" &&
@@ -353,17 +352,29 @@ PRIVDECRYPT()
 # Generate $1 random bytes
 genkey()
 {
-       gpg --armor --gen-rand 1 "$1"
+       rungpg --armor --gen-rand 1 "$1"
 }
 
 gpg_hash()
 {
        local hash_=
-       hash_=$(gpg --with-colons --print-md "$1" | tr A-F a-f)
+       hash_=$(rungpg --with-colons --print-md "$1" | tr A-F a-f)
        hash_=${hash_#:*:}
        xecho "${hash_%:}"
 }
 
+rungpg()
+{
+       # gpg will fail to run when there is no controlling tty,
+       # due to trying to print messages to it, even if a gpg agent is set
+       # up. --no-tty fixes this.
+       if [ "x$GPG_AGENT_INFO" != "x" ]; then
+               gpg --no-tty "$@"
+       else
+               gpg "$@"
+       fi
+}
+
 # Pass the branch/ref by pipe to git
 safe_git_rev_parse()
 {
@@ -407,7 +418,7 @@ read_config()
 
        for recp_ in $conf_part
        do
-               gpg_list=$(gpg --with-colons --fingerprint -k "$recp_")
+               gpg_list=$(rungpg --with-colons --fingerprint -k "$recp_")
                filter_to @r_keyinfo "pub*" "$gpg_list"
                filter_to @r_keyfpr "fpr*" "$gpg_list"
                isnull "$r_keyinfo" || isnonnull "${r_keyinfo##*"$Newline"*}" ||