Open t-bltg opened 3 years ago
I get different behaviors with and without fakechroot, when issuing a stat on a non-traversable path:
stat
case 1
~$ sudo /usr/sbin/chroot / /# test -e __non_existent_dir__/../usr; echo $? 1
case 2
~$ /usr/bin/fakechroot /usr/sbin/chroot / /$ test -e __non_existent_dir__/../usr; echo $? 0
test -e (in test.c from coreutils) is calling stat(...) without any expansion.
test -e
stat(...)
I believe that calling dedotdot(...) from expand_chroot_path in stat.c is responsible for this.
dedotdot(...)
expand_chroot_path
An ugly patch on the fly using a new environment variable FAKECHROOT_NODEDOTDOT fixes the issue:
FAKECHROOT_NODEDOTDOT
--- src/dedotdot.c 2021-01-02 17:36:49.967851000 +0000 +++ src/dedotdot.c 2021-01-07 21:27:09.163077450 +0000 @@ -51,9 +51,11 @@ */ #include <string.h> +#include <stdlib.h> LOCAL void dedotdot(char * file) { + if (getenv("FAKECHROOT_NODEDOTDOT")) return; char c, *cp, *cp2; int l;
https://github.com/dex4er/fakechroot/pull/46 seems related ...
I get different behaviors with and without fakechroot, when issuing a
stat
on a non-traversable path:case 1
case 2
test -e
(in test.c from coreutils) is callingstat(...)
without any expansion.I believe that calling
dedotdot(...)
fromexpand_chroot_path
in stat.c is responsible for this.An ugly patch on the fly using a new environment variable
FAKECHROOT_NODEDOTDOT
fixes the issue:https://github.com/dex4er/fakechroot/pull/46 seems related ...