Merge lp:~clint-fewbar/ubuntu/natty/openssh/init.d-chroot-aware into lp:ubuntu/natty/openssh

Proposed by Clint Byrum
Status: Merged
Merged at revision: 3232
Proposed branch: lp:~clint-fewbar/ubuntu/natty/openssh/init.d-chroot-aware
Merge into: lp:ubuntu/natty/openssh
Diff against target: 44 lines (+26/-0)
2 files modified
debian/changelog (+9/-0)
debian/openssh-server.ssh.init (+17/-0)
To merge this branch: bzr merge lp:~clint-fewbar/ubuntu/natty/openssh/init.d-chroot-aware
Reviewer Review Type Date Requested Status
Colin Watson Approve
Ubuntu Sponsors Pending
Review via email: mp+48070@code.launchpad.net

Description of the change

This copies code from initramfs-tools per cjwatson's suggestion to test whether or not the init.d script is running chrooted. If it is not chrooted, then we just exec /lib/init/upstart-job, making it work much the same way as if /etc/init.d/ssh were symlinked.

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

I suspect that it does not matter, but I'm fairly sure that the check given there would fail if inside a container rather than a chroot. (container's /proc/1 probably isn't /sbin/init).

I suspect that this is fine, and even intended as likely/possibly inside a container they would have their own ssh.

Revision history for this message
Evan Broder (broder) wrote :

This patch looks good to me.

But...it looks like Upstart just landed chroot support. Does that mean that we can just completely replace /etc/init.d/ssh with a symlink to /lib/init/upstart-job now? Do we want to do that instead of this patch?

Revision history for this message
Colin Watson (cjwatson) wrote :

Chroot support doesn't quite work yet IME. I still want to land this
patch in the meantime.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-01-27 12:22:49 +0000
3+++ debian/changelog 2011-01-31 22:22:12 +0000
4@@ -1,3 +1,12 @@
5+openssh (1:5.7p1-2ubuntu2) natty; urgency=low
6+
7+ * debian/openssh-server.ssh.init: Adding upstart awareness that will
8+ call /lib/init/upstart-job when script is run outside of a chroot.
9+ While this fixes LP: #531912 , the change should be reverted when
10+ upstart gains chroot session support.
11+
12+ -- Clint Byrum <clint@ubuntu.com> Mon, 31 Jan 2011 14:06:56 -0800
13+
14 openssh (1:5.7p1-2ubuntu1) natty; urgency=low
15
16 * Resynchronise with Debian experimental. Remaining changes:
17
18=== modified file 'debian/openssh-server.ssh.init'
19--- debian/openssh-server.ssh.init 2010-04-16 09:59:45 +0000
20+++ debian/openssh-server.ssh.init 2011-01-31 22:22:12 +0000
21@@ -16,6 +16,23 @@
22 test -x /usr/sbin/sshd || exit 0
23 ( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0
24
25+chrooted() {
26+ # borrowed from udev's postinst
27+ # and then borrowed from initramfs-tools's preinst
28+ if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
29+ # the devicenumber/inode pair of / is the same as that of
30+ # /sbin/init's root, so we're *not* in a chroot and hence
31+ # return false.
32+ return 1
33+ fi
34+ return 0
35+}
36+
37+# The init.d script is only for chroots
38+if ! chrooted ; then
39+ exec /lib/init/upstart-job ssh $@
40+fi
41+
42 umask 022
43
44 if test -f /etc/default/ssh; then

Subscribers

People subscribed via source and target branches

to all changes: