From 4cebe1ac6b50c7bc74313e26d44c4fc0af8886aa Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 25 Jul 2016 17:03:17 +0200 Subject: Add debian/agent-launch: Helper script for conditionally starting the SSH agent in the user session Use it in ssh-agent.user-session.upstart. This will also be used in a corresponding systemd user unit. This replaces the backgrounded "ssh-agent -s" with a foreground task which works more nicely with modern init systems for logging/debugging and starting/stopping. Also use a fixed socket file name in $XDG_RUNTIME_DIR -- under both upstart and systemd we can assume this, and it allows restarting the service in a running session. --- debian/ssh-agent.user-session.upstart | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'debian/ssh-agent.user-session.upstart') diff --git a/debian/ssh-agent.user-session.upstart b/debian/ssh-agent.user-session.upstart index 385a9ecc6..672d2a0de 100644 --- a/debian/ssh-agent.user-session.upstart +++ b/debian/ssh-agent.user-session.upstart @@ -3,21 +3,5 @@ author "Stéphane Graber " start on starting xsession-init -pre-start script - [ -e /etc/X11/Xsession.options ] || { stop; exit 0; } - grep -q "^use-ssh-agent$" /etc/X11/Xsession.options || { stop; exit 0; } - [ -z "$SSH_AUTH_SOCK" ] || { stop; exit 0; } - - eval "$(ssh-agent -s)" >/dev/null - initctl set-env --global SSH_AUTH_SOCK=$SSH_AUTH_SOCK - initctl set-env --global SSH_AGENT_PID=$SSH_AGENT_PID - initctl set-env --global SSH_AGENT_LAUNCHER=upstart -end script - -post-stop script - [ "$SSH_AGENT_LAUNCHER" = upstart ] || exit 0 - kill $SSH_AGENT_PID 2>/dev/null || true - initctl unset-env --global SSH_AUTH_SOCK - initctl unset-env --global SSH_AGENT_PID - initctl unset-env --global SSH_AGENT_LAUNCHER -end script +exec /usr/lib/openssh/agent-launch start +post-stop exec /usr/lib/openssh/agent-launch stop -- cgit v1.2.3