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: