summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2016-07-22 14:47:41 (GMT)
committerMartin Pitt <martin.pitt@ubuntu.com>2016-07-25 14:37:18 (GMT)
commit289952085430a2c6788819bc560f3c0094d6fe87 (patch)
tree8a29554ecd2646952aeae5e76cf388bea08d7670
parent0999d4f784a9c17e57a7349874baba0cba9cc7aa (diff)
Add ssh-agent
-rw-r--r--debian/changelog1
-rw-r--r--debian/systemd-graphical-session.links1
-rwxr-xr-xusr/lib/openssh/agent-launch29
-rw-r--r--usr/lib/systemd/user/ssh-agent.service8
-rw-r--r--usr/share/upstart/systemd-session/upstart/ssh-agent.override1
5 files changed, 40 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 7f8db79..a55e759 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ systemd-graphical-session (0.0.10) UNRELEASED; urgency=medium
[ Martin Pitt ]
* systemd-graphical-session.conf: Update comment and drop stray xargs.
+ * Add ssh-agent.
[ Iain Lane ]
* Drop session-migration, moving to the real package.
diff --git a/debian/systemd-graphical-session.links b/debian/systemd-graphical-session.links
index 1a1000d..a250597 100644
--- a/debian/systemd-graphical-session.links
+++ b/debian/systemd-graphical-session.links
@@ -1,5 +1,6 @@
# launched for all sessions
usr/lib/systemd/user/xeyes.service usr/lib/systemd/user/graphical-session.target.wants/xeyes.service
+usr/lib/systemd/user/ssh-agent.service usr/lib/systemd/user/graphical-session-pre.target.wants/ssh-agent.service
# launched for ubuntu session (TODO: add others)
usr/lib/systemd/user/gnome-session.service usr/lib/systemd/user/ubuntu-session.target.wants/gnome-session.service
usr/lib/systemd/user/unity7.service usr/lib/systemd/user/ubuntu-session.target.wants/unity7.service
diff --git a/usr/lib/openssh/agent-launch b/usr/lib/openssh/agent-launch
new file mode 100755
index 0000000..40479b8
--- /dev/null
+++ b/usr/lib/openssh/agent-launch
@@ -0,0 +1,29 @@
+#!/bin/sh
+# helper script for launching ssh-agent, used by systemd unit and upstart job
+set -e
+
+if [ ! -d "$XDG_RUNTIME_DIR" ]; then
+ echo 'This needs $XDG_RUNTIME_DIR to be set' >&2
+ exit 1
+fi
+
+if [ "$1" = start ]; then
+ if [ -z "$SSH_AUTH_SOCK" ] && grep -s -q '^use-ssh-agent$' /etc/X11/Xsession.options; then
+ S="$XDG_RUNTIME_DIR/openssh_agent"
+ dbus-update-activation-environment --verbose --systemd SSH_AUTH_SOCK=$S SSH_AGENT_LAUNCHER=openssh
+ if type initctl >/dev/null 2>&1; then
+ initctl set-env --global SSH_AUTH_SOCK=$S
+ fi
+ exec ssh-agent -D -a $S
+ fi
+elif [ "$1" = stop ]; then
+ if [ "$SSH_AGENT_LAUNCHER" = openssh ]; then
+ dbus-update-activation-environment --systemd SSH_AUTH_SOCK=
+ if type initctl >/dev/null 2>&1; then
+ initctl unset-env --global SSH_AUTH_SOCK
+ fi
+ fi
+else
+ echo "Unknown command $1" >&2
+ exit 1
+fi
diff --git a/usr/lib/systemd/user/ssh-agent.service b/usr/lib/systemd/user/ssh-agent.service
new file mode 100644
index 0000000..2297f8f
--- /dev/null
+++ b/usr/lib/systemd/user/ssh-agent.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=OpenSSH Agent
+Before=graphical-session-pre.target
+ConditionPathExists=/etc/X11/Xsession.options
+
+[Service]
+ExecStart=/usr/lib/openssh/agent-launch start
+ExecStopPost=/usr/lib/openssh/agent-launch stop
diff --git a/usr/share/upstart/systemd-session/upstart/ssh-agent.override b/usr/share/upstart/systemd-session/upstart/ssh-agent.override
new file mode 100644
index 0000000..2905494
--- /dev/null
+++ b/usr/share/upstart/systemd-session/upstart/ssh-agent.override
@@ -0,0 +1 @@
+manual