Package: udev
Version: 0.056-3
Followup-For: Bug #395889

Hi,

> on a 2.6.18 powerpc/pegasos system, which is mostly etch with sid
> kernels, i
> tested both proposed fixes :
> 
>   if ! [ -r /proc/1/root -a /proc/1/root/ -ef /proc/self/root/ ]
> 
> returned FALSE in both cases (Well, i think i forgot the !, so it
> probably did return TRUE in both cases). So, this solution is not
> working.

You're right that both tests return exactly the opposite:

! [ -r /proc/1/root -a /proc/1/root/ -ef /proc/self/root/ ]
[ "$(stat -c "%d/%i" /)" = "$(stat -Lc "%d/%i" /proc/1/root)" ]

And that's because of the '!'.  I put the '!' in my patch because it
fitted there: We want to test if we are in a chroot, not if we are
outside.

As Mark pointed out, my test will only work as root.  But the stat(1)
test has the same problem (I've tested this), since it uses the same
information.

Oh, and by the way, mind the trailing slashes in the second and third
path name, they're important.

Both tests won't work if the chroot is bind-mounted to the old root.
I'm not sure if this is a problem.  Anyway the old test did work in
that case.

> Given the critic Christoph had (warnings on pre-2.6.18, altough we hardly care
> for this in etch, which will have 2.6.18), mayeb something like this : 
> 
>   if [ "`uname -r`" -ge 2.6.18 ] &&
>       [ "$(stat -c "%d/%i" /)" = "$(stat -Lc "%d/%i" /proc/1/root)" ]; then
>       # WE ARE IN THE REAL SYSTEM 
>   else
>       # WE ARE IN THE CHROOT
>   fi

If you want to go with the stat(1) test, another way to avoid the
warnings would be

  [ "$(stat -c "%d/%i" /)" = "$(stat -Lc "%d/%i" /proc/1/root)" ] &>/dev/null

Regards,
Christoph


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to