I get different behaviors with and without fakechroot, when issuing a stat on a non-traversable path:
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.
I believe that calling dedotdot(...) from expand_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:
--- 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;
#46 seems related ...
I get different behaviors with and without fakechroot, when issuing a
staton 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_pathin stat.c is responsible for this.An ugly patch on the fly using a new environment variable
FAKECHROOT_NODEDOTDOTfixes the issue:#46 seems related ...