tests: Use 'gpg-agent --allow-loopback-pinentry' if applicable.
[gpgme.git] / tests / start-stop-agent
index e843ce5..457f70d 100755 (executable)
@@ -38,6 +38,14 @@ fi
 
 echo "starting gpg-agent.." >&2
 
+# GnuPG prior to 2.1.12 needs --allow-loopback-pinentry for the
+# loopback entry to work.  Old versions do not understand this though,
+# so we need to be careful.
+if "$GPG_AGENT" --gpgconf-test --allow-loopback-pinentry &&
+   ! grep -q allow-loopback-pinentry "$GNUPGHOME/gpg-agent.conf"; then
+    echo allow-loopback-pinentry >> "$GNUPGHOME/gpg-agent.conf"
+fi
+
 gpg-connect-agent --agent-program="${GPG_AGENT}|--debug-quick-random" putval\ $token\ set /bye
 if [ $? -ne 0 -o "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
       != "D set" ]; then