From a97b280fdca2e30e18491eed88e911ae7c613a80 Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Tue, 29 Oct 2024 18:21:15 +0100 Subject: [PATCH] Prevent agent hang on alternative gpg homedir Fix: https://github.com/QubesOS/qubes-issues/issues/9534 --- gpg-agent-placeholder | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gpg-agent-placeholder b/gpg-agent-placeholder index 1858c4c..15fce67 100755 --- a/gpg-agent-placeholder +++ b/gpg-agent-placeholder @@ -1,11 +1,16 @@ #!/bin/bash +set -euo pipefail -set -eo pipefail - -# prevent starting real gpg-agent locally if it's redirected via split-gpg2 +# Prevent starting real gpg-agent locally if it's redirected via split-gpg2, +# which only uses the default GnuPG home directory. if [ -e /run/qubes-service/split-gpg2-client ]; then - exit 0 + case "$@" in + *"--homedir $HOME/.gnupg "*) + exit 0 + ;; + esac fi -# otherwise, launch gpg-agent -gpgagent=$(gpgconf --list-components | grep ^gpg-agent: | cut -d ':' -f 3) + +# Otherwise, launch gpg-agent. +gpgagent="$(gpgconf --list-components | awk -F: '/^gpg-agent:/{print $3}')" exec "$gpgagent" "$@"