diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2016-07-25 17:03:17 +0200 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2016-07-29 02:32:54 +0100 |
commit | 4cebe1ac6b50c7bc74313e26d44c4fc0af8886aa (patch) | |
tree | d33233488eac0023ec3a4e5e7edd0180b53318b1 /debian/ssh-agent.user-session.upstart | |
parent | 556ee3d2d433dc70512003667398f0979b0940a9 (diff) |
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.
Diffstat (limited to 'debian/ssh-agent.user-session.upstart')
-rw-r--r-- | debian/ssh-agent.user-session.upstart | 20 |
1 files changed, 2 insertions, 18 deletions
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 <stgraber@ubuntu.com>" | |||
3 | 3 | ||
4 | start on starting xsession-init | 4 | start on starting xsession-init |
5 | 5 | ||
6 | pre-start script | 6 | exec /usr/lib/openssh/agent-launch start |
7 | [ -e /etc/X11/Xsession.options ] || { stop; exit 0; } | 7 | post-stop exec /usr/lib/openssh/agent-launch stop |
8 | grep -q "^use-ssh-agent$" /etc/X11/Xsession.options || { stop; exit 0; } | ||
9 | [ -z "$SSH_AUTH_SOCK" ] || { stop; exit 0; } | ||
10 | |||
11 | eval "$(ssh-agent -s)" >/dev/null | ||
12 | initctl set-env --global SSH_AUTH_SOCK=$SSH_AUTH_SOCK | ||
13 | initctl set-env --global SSH_AGENT_PID=$SSH_AGENT_PID | ||
14 | initctl set-env --global SSH_AGENT_LAUNCHER=upstart | ||
15 | end script | ||
16 | |||
17 | post-stop script | ||
18 | [ "$SSH_AGENT_LAUNCHER" = upstart ] || exit 0 | ||
19 | kill $SSH_AGENT_PID 2>/dev/null || true | ||
20 | initctl unset-env --global SSH_AUTH_SOCK | ||
21 | initctl unset-env --global SSH_AGENT_PID | ||
22 | initctl unset-env --global SSH_AGENT_LAUNCHER | ||
23 | end script | ||