Subject: Re: bug#79433: 9.7: cp(1): lchownat(2/3) fallback bogus?

From: Paul Eggert <[email-masked]>
Date: Tue, 16 Sep 2025 12:21:46 -0700

On 2025-09-16 11:51, Steffen Nurpmeso wrote:
> I attach a tar archives of the two different logfiles, maybe some
> GNU build system guru can figure out more.

The first difference in those logs occurs when 'configure' compiles and 
run the following program. It should succeed (exit status 0) but in your 
fakeroot build it fails and 'configure' then assumes chown needs 
replacement. Can you figure out why the test program fails (exit status 
5) in the fakeroot environment? You can use strace to help find out. 
Once we figure this out, it may explain the other differences in the logs.

   #include <unistd.h>
   #include <stdlib.h>
   #include <errno.h>
   #include <fcntl.h>
   #include <sys/stat.h>

   int
   main (void)
   {
     struct stat st1, st2;
     if (close (creat ("conftest.file", 0600))) return 1;
     if (stat ("conftest.file", &st1)) return 2;
     sleep (1);
     if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3;
     if (stat ("conftest.file", &st2)) return 4;
     if (st2.st_ctime <= st1.st_ctime) return 5;
   }

Here's what strace says on my Fedora 42 host:

   creat("conftest.file", 0600) = 3
   close(3) = 0
   newfstatat(AT_FDCWD, "conftest.file", {st_mode=S_IFREG|0600, 
st_size=0, ...}, 0) = 0
   clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 
0x7fffc15bb1f0) = 0
   chown("conftest.file", 1000, 1000) = 0
   newfstatat(AT_FDCWD, "conftest.file", {st_mode=S_IFREG|0600, 
st_size=0, ...}, 0) = 0
   exit_group(0) = ?