grml-chroot: properly handle multiple chroots [Closes: issue659] mika/grml_chroot_multi
authorMichael Prokop <mika@grml.org>
Fri, 13 Jan 2012 00:57:46 +0000 (01:57 +0100)
committerMichael Prokop <mika@grml.org>
Fri, 13 Jan 2012 02:21:26 +0000 (03:21 +0100)
commit0c13608cebe81e80909349b719c004bcc5dc78cf
treecd7f0a210daf0ba5eeb55e7851e1afdc3e965527
parented04d5a64caaa421e2ffdf3e06b88e763504b91f
grml-chroot: properly handle multiple chroots [Closes: issue659]

Iff /tmp is available inside the chroot then use /tmp/grml-chroot
for storing information about active grml-chroot sessions.

This patch is based on work by Marc Haber and addresses the following issue
reported by him in http://bts.grml.org/grml/issue659:

| grml-chroot does not properly handle the situation when the user decides to
| chroot into the same chroot multiple times (for example, in different windows).
| When the first chroot terminates, the unconditional umount leaves the other
| chroots without mounted /proc, /dev etc.

Sadly this isn't bullet proof though.
Quoting Gebi from the according discussion on IRC (with his permission):

02:48 < gebi> you know that /tmp was to bind mounted too if you want to use X?
02:49 < gebi> not a good idea to use a bind mounted /tmp inside of the chroot for saving state which ultimatly goes back to the
              base image
02:50 < gebi> mrud: but you e.g HAVE to mount --bind /tmp chroot/tmp to use X in chroot
02:51 < gebi> so it would be no fun to use chroot/tmp as state dir for grml-chroot, because on unmounting your files would not be
              there anymore
02:51 < gebi> because hidden by the mount --bind

Thanks to Ulrich Dangel and Michael Gebetsroither for
code review and improvement suggestions.
usr_sbin/grml-chroot