diff options
-rwxr-xr-x | policy-rc.d | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/policy-rc.d b/policy-rc.d index bf0e993..8972383 100755 --- a/policy-rc.d +++ b/policy-rc.d @@ -1,6 +1,6 @@ #!/bin/sh -# $Id: policy-rc.d,v 1.3 2006-04-22 16:04:55 jonas Exp $ +# $Id: policy-rc.d,v 1.4 2007-01-03 14:38:03 jonas Exp $ # # Copyright © 2006 Jonas Smedegaard <dr@jones.dk> # Description: Suppress system V scripts if invoked within a chroot. @@ -26,6 +26,18 @@ TEMP=`getopt -s sh --long list,quiet -n "$PRG" -- "$@"` if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi eval set -- "$TEMP" +# Stolen from udev postinst +chrooted() { + 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 and hence return false. + return 1 + fi + echo "A chroot environment has been detected, udev not started." + return 0 +} + quiet="" list="" while true ; do @@ -55,7 +67,7 @@ EOF exit 0 fi -if [ ! -r /proc/1/root ]; then +if ! chrooted; then if ! [ "$quiet" ]; then echo >&2 "Chroot environment detected, suppressing sysV script." fi |