Bug#545691: diverting telinit
Hi,
I am pulling this discussion off 545691@bugs.debian.org and on
to the devel list, in case it has broader interest. The issue was that
a maintainer script called telinit to communicate with init, and that
does not work when the kernel has been started with
'init=/bin/bash'. (qemubuilder was impacted in the bug, but this might
need a general fix).
I created a elaborate test case tos ee if we are in a chroot, if
not if /proc/1 is actually /sbin/init, and that telinit exists (example
below).
Does this need discussion?
manoj
if [ -x /sbin/init ] && [ -d /proc/1 ] &&
[ "$(stat -c %d/%i /sbin/init)" = "$(stat -Lc %d/%i /proc/1/exe 2>/dev/null)" ] ; then
# So, init exists, and there is a linuxy /proc, and the inode of
# the executable of the process with uid 1 is the same as
# /sbin/init (ok, no init=/bin/sh going on)
if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
# the devicenumber/inode pair of / is the same as that of
# /sbin/init's root, so we're *not* in a chroot
# Final sanity check. Make sure there is a /dev/initctl
# for us to talk to
if [ -e /dev/initctl ]; then
# Use telinit if available, it is better form, according
# to the sysvinit maintainer.
if [ -x /sbin/telinit ]; then
(telinit u ; sleep 1)
else
(init u ; sleep 1)
fi
fi
fi
fi
--
Whether in the village or the forest, whether on high ground or low,
wherever the enlightened live, that is a delightful spot. 98
Manoj Srivastava <srivasta@debian.org> <http://www.debian.org/~srivasta/>
1024D/BF24424C print 4966 F272 D093 B493 410B 924B 21BA DABB BF24 424C
Reply to: