gpg: handle KILLAGENT command

so `gpg-connect-agent KILLAGENT` should stop the running agent
This commit is contained in:
Roman Zeyde
2016-11-10 23:29:47 +02:00
parent 9be6504658
commit 827119a18d
2 changed files with 6 additions and 0 deletions

View File

@@ -112,6 +112,9 @@ def main_agent():
with contextlib.closing(conn):
try:
agent.handle_connection(conn)
except StopIteration:
log.info('stopping gpg-agent')
return
except Exception as e: # pylint: disable=broad-except
log.exception('gpg-agent failed: %s', e)

View File

@@ -142,6 +142,9 @@ def handle_connection(conn):
keyring.sendline(conn, fmt.format(keygrip).encode('ascii'))
elif command == b'BYE':
return
elif command == b'KILLAGENT':
keyring.sendline(conn, b'OK')
raise StopIteration
else:
log.error('unknown request: %r', line)
return