Skip to content

Comments

ssh-agent: exit 0 from SIGTERM under systemd socket-activation#565

Closed
dkg wants to merge 1 commit intoopenssh:masterfrom
dkg:ssh-agent-systemd-cleanup
Closed

ssh-agent: exit 0 from SIGTERM under systemd socket-activation#565
dkg wants to merge 1 commit intoopenssh:masterfrom
dkg:ssh-agent-systemd-cleanup

Conversation

@dkg
Copy link
Contributor

@dkg dkg commented Apr 16, 2025

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.

This was also reported on the mailing list.

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>
@dkg
Copy link
Contributor Author

dkg commented May 7, 2025

a gentle nudge here -- it'd be great to get feedback on this. If there's a problem, i'm happy to try to resolve it.

@djmdjm
Copy link
Contributor

djmdjm commented May 24, 2025

this was merged a few weeks ago as 0863697

@djmdjm djmdjm closed this May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants