Closed inorton closed 2 years ago
Setting -UFAKE_FILE_TIMESTAMPS
doesn't seem to help
It seems, that when run without libfaketime, busybox makes a different call to utimes()
stat("/etc/busybox.conf", 0x7ffd0151f838) = -1 ENOENT (No such file or directory)
getgid() = 10116
setgid(10116) = 0
setuid(10116) = 0
utimes("zebra", NULL) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "zebra", O_RDWR|O_CREAT, 0666) = 3
close(3) = 0
exit_group(0) = ?
+++ exited with 0 +++
With LD_PRELOAD set I see:
getgid() = 10116
setgid(10116) = 0
setuid(10116) = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
openat(AT_FDCWD, "(null)", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/inb/.faketimerc", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/faketimerc", O_RDONLY) = -1 ENOENT (No such file or directory)
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
utimes("zebra", [{tv_sec=1, tv_usec=139677214016545}, {tv_sec=1, tv_usec=139677214016545}]) = -1 EINVAL (Invalid argument)
write(2, "touch: zebra: Invalid argument\n", 31touch: zebra: Invalid argument
) = 31
munmap(0x7f0922c7c000, 8) = 0
munmap(0x7f0922c7d000, 32) = 0
exit_group(1) = ?
+++ exited with 1 +++
With a little printf debugging, (can't get gdb to catch this for some reason) I can see that libfaketime's utimes()
function gets called with NULL
for times. So this triggers the call to fake_gettimeofday()
if fake_utime_disabled == 0
. Which then calls the real utime()
with the faked values.
It seems, that if I compile with -UFAKE_STAT
and ensure FAKE_UTIME=y
is set, then busybox works. I think this is similar to what is discussed in http://lists.busybox.net/pipermail/buildroot/2020-February/273864.html but I think the buildroot people got the compiler flags wrong.
I will put up a PR with my fix that allows for turning off FAKE_STAT
Thanks for tracing and fixing this!! Just merged your PR.
Hi, I have compiled the latest libfaketime (with set time support enabled) and have installed libfaketimeMT.so.1 in my /etc/ld.so.preload file. I have the following env vars set:
And have a
/faketime
file that all users can read. My libfaketime is compiled on debian buster with gcc 8.4. I'm running busybox on this system (it is a docker container based on debian buster) and running simple file creation or update operations fail. eg:Using regular bash or python to read/write/create files works correctly.
I have strace in here and have some output if that helps (here /usr/bin/touch is a symlink to /bin/busybox):