From 4926d4f4d32388a120133b50c3067e029e9c54cf Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Thu, 9 Nov 2017 22:13:28 +0200 Subject: [PATCH] gpg: set PATH explicitly for $DEVICE-gpg-agent --- libagent/gpg/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libagent/gpg/__init__.py b/libagent/gpg/__init__.py index 24f2523..725ca39 100644 --- a/libagent/gpg/__init__.py +++ b/libagent/gpg/__init__.py @@ -131,13 +131,22 @@ def run_init(device_type, args): agent_path = util.which('{}-gpg-agent'.format(device_name)) + # Prepare GPG agent invocation script (to pass the PATH from environment). + with open(os.path.join(homedir, 'run-agent.sh'), 'w') as f: + f.write("""#!/bin/sh +export PATH={0} +{1} $* +""".format(os.environ['PATH'], agent_path)) + check_call(['chmod', 'u+x', f.name]) + run_agent_script = f.name + # Prepare GPG configuration file with open(os.path.join(homedir, 'gpg.conf'), 'w') as f: f.write("""# Hardware-based GPG configuration agent-program {0} personal-digest-preferences SHA512 default-key \"{1}\" -""".format(agent_path, args.user_id)) +""".format(run_agent_script, args.user_id)) # Prepare GPG agent configuration file with open(os.path.join(homedir, 'gpg-agent.conf'), 'w') as f: