[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#703906: Add upstart user session job



Package: src:openssh

Hello,

Starting with Upstart 1.7, users can choose to use it in "user session"
mode. When doing so, the regular Xsession script that usually spawns
ssh-agent doesn't work and so an equivalent upstart job needs to be
installed.

Attached is a debdiff adding such a job to the openssh-client package.

This job is a no-op on non-upstart systems or on upstart systems that
don't use user sessions. For those using user sessions, this job will do
the same work as 90x11-common_ssh-agent including checking
Xsession.options if present.


I'm currently using that job on a standard Ubuntu 13.04 system and I
have done a testbuild with the attached debdiff.

Thanks

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

diff -Nru openssh-6.1p1/debian/changelog openssh-6.1p1/debian/changelog
--- openssh-6.1p1/debian/changelog	2013-02-08 16:07:32.000000000 -0500
+++ openssh-6.1p1/debian/changelog	2013-03-25 11:30:18.000000000 -0400
@@ -1,3 +1,11 @@
+openssh (1:6.1p1-4) UNRELEASED; urgency=low
+
+  * Add ssh-agent upstart user job. This implements something similar to the
+    90x11-common_ssh-agent Xsession script. That's, start ssh-agent and set
+    the appropriate environment variables.
+
+ -- Stéphane Graber <stgraber@ubuntu.com>  Mon, 25 Mar 2013 11:29:10 -0400
+
 openssh (1:6.1p1-3) experimental; urgency=low
 
   * Give ssh and ssh-krb5 versioned dependencies on openssh-client and
diff -Nru openssh-6.1p1/debian/rules openssh-6.1p1/debian/rules
--- openssh-6.1p1/debian/rules	2012-11-26 11:38:45.000000000 -0500
+++ openssh-6.1p1/debian/rules	2013-03-25 11:29:02.000000000 -0400
@@ -187,6 +187,9 @@
 	install -p -m 644 debian/openssh-client.apport debian/openssh-client/usr/share/apport/package-hooks/openssh-client.py
 	install -p -m 644 debian/openssh-server.apport debian/openssh-server/usr/share/apport/package-hooks/openssh-server.py
 
+	# Upstart user job (only used under user sessions)
+	install -m 644 -D debian/ssh-agent.user-session.upstart debian/openssh-client/usr/share/upstart/sessions/ssh-agent.conf
+
 override_dh_installdocs:
 	dh_installdocs -Nopenssh-server -Nssh
 	dh_installdocs -popenssh-server -pssh --link-doc=openssh-client
diff -Nru openssh-6.1p1/debian/ssh-agent.user-session.upstart openssh-6.1p1/debian/ssh-agent.user-session.upstart
--- openssh-6.1p1/debian/ssh-agent.user-session.upstart	1969-12-31 19:00:00.000000000 -0500
+++ openssh-6.1p1/debian/ssh-agent.user-session.upstart	2013-03-25 11:10:22.000000000 -0400
@@ -0,0 +1,20 @@
+description "SSH Agent"
+author "Stéphane Graber <stgraber@ubuntu.com>"
+
+start on starting xsession-init
+
+pre-start script
+    if [ -f /etc/X11/Xsession.options ]; then
+        grep -q "^use-ssh-agent$" /etc/X11/Xsession.options || { stop; exit 0; }
+    fi
+
+    eval "$(ssh-agent)" >/dev/null
+    initctl set-env --global SSH_AUTH_SOCK=$SSH_AUTH_SOCK
+    initctl set-env --global SSH_AGENT_PID=$SSH_AGENT_PID
+end script
+
+post-stop script
+    kill $SSH_AGENT_PID 2>/dev/null || true
+    initctl unset-env --global SSH_AUTH_SOCK
+    initctl unset-env --global SSH_AGENT_PID
+end script

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: