]> git.ipfire.org Git - thirdparty/openssh-portable.git/commit
ssh-agent: exit 0 from SIGTERM under systemd socket-activation
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Wed, 16 Apr 2025 00:18:34 +0000 (10:18 +1000)
committerDamien Miller <djm@mindrot.org>
Thu, 8 May 2025 00:08:30 +0000 (10:08 +1000)
commit086369736a9496b39af0d9f09443fa81b59b7f05
tree7480427f040bf3b5a5b865e30b7d3f6648c41324
parent755c3d082e59e6884f28d30e6333a1444e9173d1
ssh-agent: exit 0 from SIGTERM under systemd socket-activation

When the ssh-agent service is configured to be launched under systemd
socket-activation, the user can inspect the status of the agent with
something like:

    systemctl --user status ssh-agent.service

If the user does:

    systemctl --user stop ssh-agent.service

it causes the `systemd --user` supervisor to send a SIGTERM to the
agent, which terminates while leaving the systemd-managed socket in
place.  That's good, and as expected. (If the user wants to close the
socket, they can do "systemctl --user stop ssh-agent.socket" instead)

But because ssh-agent exits with code 2 in response to a SIGTERM, the
supervisor marks the service as "failed", even though the state of the
supervised service is exactly the same as during session startup (not
running, ready to launch when a client connects to the socket).

This change makes ssh-agent exit cleanly (code 0) in response to a
SIGTERM when launched under socket activation. This aligns the systemd
supervisor's understanding of the state of supervised ssh-agent with
reality.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
ssh-agent.c