Skip to content

Commit

Permalink
Do not stop hosts' SSH + mdadm services in cleanup procedure
Browse files Browse the repository at this point in the history
The init script uses start-stop-daemon with the pidfile
/var/run/sshd.pid. We can't just stop the service from
outside the chroot because this terminates the process of the
host system instead of the process *inside* the chroot.

Thanks: Sebastian Pipping for debugging and bug report
Fixes #63 (GH-37, PR 71)
  • Loading branch information
mika committed Mar 10, 2015
1 parent 762d9ef commit f992b13
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions grml-debootstrap
Expand Up @@ -205,8 +205,11 @@ cleanup() {
if [ -n "$MNTPOINT" ] ; then
if grep -q "$MNTPOINT" /proc/mounts ; then
# make sure nothing is left inside chroot so we can unmount it
[ -x "$MNTPOINT"/etc/init.d/ssh ] && "$MNTPOINT"/etc/init.d/ssh stop
[ -x "$MNTPOINT"/etc/init.d/mdadm ] && "$MNTPOINT"/etc/init.d/mdadm stop
for service in ssh mdadm ; do
if [ -x "${MNTPOINT}/etc/init.d/${service}" ] ; then
chroot "$MNTPOINT" "/etc/init.d/${service}" stop
fi
done

[ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount -a >/dev/null 2>&1

Expand Down

4 comments on commit f992b13

@hartwork
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the new approach works in practice? I wonder because at that point in time things like /dev and /proc are not mounted, if I am not mistaken.

@mika
Copy link
Member Author

@mika mika commented on f992b13 Mar 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure? Nope, but it's better than doing nothing IMHO and shouldn't do any harm. (I'm not really happy about the cleanup procedure as it is, but we need to minimize the changes to have a chance for inclusion in jessie at all.)

@hartwork
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used something like this before:

sudo lsof | fgrep "${MNTPOINT}" | awk '{print $2}' | sort -u | xargs sudo kill -9

I wouldn't use that in production maybe, but the approach could work if implemented well.

@mika
Copy link
Member Author

@mika mika commented on f992b13 Mar 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's something reliable I'm happy to take it, this doesn't look like production ready, agreed. :)

Please sign in to comment.