Support daemonization of GPG agent

This commit is contained in:
Roman Zeyde
2021-10-16 20:58:30 +03:00
parent 37510a2d75
commit 6c2b880b7d
2 changed files with 12 additions and 0 deletions

View File

@@ -226,6 +226,8 @@ def run_agent(device_type):
p.add_argument('-v', '--verbose', default=0, action='count') p.add_argument('-v', '--verbose', default=0, action='count')
p.add_argument('--server', default=False, action='store_true', p.add_argument('--server', default=False, action='store_true',
help='Use stdin/stdout for communication with GPG.') help='Use stdin/stdout for communication with GPG.')
p.add_argument('--daemon', default=False, action='store_true',
help='Daemonize the agent.')
p.add_argument('--pin-entry-binary', type=str, default='pinentry', p.add_argument('--pin-entry-binary', type=str, default='pinentry',
help='Path to PIN entry UI helper.') help='Path to PIN entry UI helper.')
@@ -236,6 +238,15 @@ def run_agent(device_type):
args, _ = p.parse_known_args() args, _ = p.parse_known_args()
if args.daemon:
with daemon.DaemonContext():
run_agent_internal(args, device_type)
else:
run_agent_internal(args, device_type)
def run_agent_internal(args, device_type):
"""Actually run the server."""
assert args.homedir assert args.homedir
log_file = os.path.join(args.homedir, 'gpg-agent.log') log_file = os.path.join(args.homedir, 'gpg-agent.log')

View File

@@ -17,6 +17,7 @@ setup(
], ],
install_requires=[ install_requires=[
'docutils>=0.14', 'docutils>=0.14',
'python-daemon>=2.3.0',
'wheel>=0.32.3', 'wheel>=0.32.3',
'backports.shutil_which>=3.5.1', 'backports.shutil_which>=3.5.1',
'ConfigArgParse>=0.12.1', 'ConfigArgParse>=0.12.1',