Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 201578 - default stage3 /sbin/rc from chroot reboots whole system
Summary: default stage3 /sbin/rc from chroot reboots whole system
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on: 198494
Blocks:
  Show dependency tree
 
Reported: 2007-12-07 12:04 UTC by Dima Tisnek
Modified: 2008-01-01 18:29 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dima Tisnek 2007-12-07 12:04:46 UTC
/sbin/rc tries to reboot the system if it cannot mount / from /etc/fstab
/etc/init.d/<anything> <somecommand> runs dependency check which triggers /sbin/rc

as a result, if one does the following:
mkdir /mychroot
tar xzvf stage3-xxx.tgz -C /mychroot
chroot /mychroot /etc/init.d/sshd start # for example to generate ssh keys

user is presented with:
<some errors>
Enter root password for mainenance (^D to conitnue):

pressing ^D (or in fact even killing the chroot process) results in entire (host) system going for reboot.


Reproducible: Always

Steps to Reproduce:



Expected Results:  
Either notice that /sbin/rc or /etc/fstab or something is actually in chroot, or
Correct sysvinit (reboot, shutdown) not take the whole system down from within chroot jail.

this happened to me several times (bad), one of which on a remote production server (really very bad indeed)
Comment 1 Roy Marples (RETIRED) gentoo-dev 2007-12-07 17:41:22 UTC
Is there anyway in a userland to detect if we are in a chroot or not?
Comment 2 Roy Marples (RETIRED) gentoo-dev 2007-12-07 18:09:11 UTC
OK, for Linux I can check to see if /proc/1/root exists.
My tests show that this never exists in a chroot, even with proc mount.
I was unable to test if it exists if proc was mounted inside the chroot though.
Comment 3 Roy Marples (RETIRED) gentoo-dev 2007-12-07 18:16:12 UTC
We can add this to a few init scripts, such as checkroot

depend() {
   keywords nochroot
}

Basically, rc will mark the service as started if we're in a chroot but not actually start it. You will, however, be able to start the service manually.

Once a version that supports keywords as described on bug #198494 is in the tree.
Comment 4 SpanKY gentoo-dev 2007-12-07 22:00:40 UTC
we've already shown in the past that there isnt a reliable way to detect a chroot

look at all the history of the udev crap
Comment 5 Roy Marples (RETIRED) gentoo-dev 2007-12-07 22:40:31 UTC
(In reply to comment #4)
> we've already shown in the past that there isnt a reliable way to detect a
> chroot
> 
> look at all the history of the udev crap

Got a pointer to this history?
Comment 6 SpanKY gentoo-dev 2007-12-07 23:12:56 UTC
the end result was "not doable", so i dont think it's relevant

the interesting point is that you cant say "if in chroot, do nothing" because some systems (like one of mine) actually boot up in a chroot, so having rc short circuit everything is incorrect
Comment 7 Roy Marples (RETIRED) gentoo-dev 2007-12-08 02:29:01 UTC
I suppose a stage tarball could automatically mark some services as "started", which would also solve the initial bug report.

Also, as technically there are no critical services anymore the only reboot occurs in sysinit - and there are special checks to ensure that sysvinit (or bsd init) has called rc shutdown|single|restart - this bug should not be relevant with baselayout-2 / openrc.

But I've not tested that :)
Comment 8 SpanKY gentoo-dev 2008-01-01 18:29:27 UTC
if you want correct behavior with baselayout-1, sync the init.d state dir yourself