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

Paul Eggert <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Organization UCLA Computer Science Department
Message-ID <[email protected]>
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) = ?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.