On my mac machine this just works as expected:
#!/bin/sh -euf
touch test.sh
chown 888:888 test.sh
busybox tar -czvf out.tar.gz test.sh
Invocation:
$ fakeroot -- ./generateArchive.sh
$ busybox tar -tzvf out.tar.gz
-rw-r--r-- 888/888 0 2017-08-02 20:52:50 test.sh
But on my virtual ubuntu machine I get:
$ fakeroot -- ./generateArchive.sh
$ busybox tar -tzvf out.tar.gz
-rwxrwxr-x marco/marco 215 2017-08-02 20:53:32 test.sh
Why does busybox on ubuntu not "fall" for the faked ownership?
It works on ubuntu when I use tar
instead of busybox tar
.
Additional information:
Mac (10.12.5):
fakeroot version 1.20.2
BusyBox v1.20.0.git (2017-05-17 10:01:40 CEST) multi-call binary.
Ubuntu (14.04.5 LTS):
fakeroot version 1.20
BusyBox v1.21.1 (Ubuntu 1:1.21.0-1ubuntu1) multi-call binary.
Most likely reason is that your busybox was statically linked. Fakeroot uses LD_PRELOAD, which intercepts the calls as they pass from the program to the run time library (glibc). Statically linked executables are invisible to LD_PRELOAD, and thus, to fakeroot.
Fakeroot-ng uses the ptrace mechanism, which intercepts system calls when they pass from the program to the kernel. As such, fakeroot-ng, can catch system calls executed by statically linked programs (which is one of the reasons I created fakeroot-ng in the first place).
On Mac, statically linking of the run time library is not allowed. They do not even provide a static version of the run time library. As such, fakeroot has no problem intercepting the system calls there (which is a good thing, because fakeroot-ng does not have an OS-X version, partially for the reason stated above).