[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: errors from fchownat copying directories
From: |
Bruno Haible |
Subject: |
Re: errors from fchownat copying directories |
Date: |
Sat, 26 Aug 2023 18:40:20 +0200 |
Paul Eggert wrote:
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=349798a9b81fb4f7f8e1e1963ea9039a4a68a471
Isn't there something missing in this function 'copy-directory',
around emacs/lisp/files.el line 6624? I see code for preserving the modes
and the times, but not for preserving the owner.
For comparison, 'mv' from GNU coreutils 9.3.147-d553ab contains also code
for preserving the owner, and this code sometimes gives diagnostics that
are ignored, in the sense that 'mv' terminates with exit code 0.
See:
$ ldd mv
linux-vdso.so.1 (0x00007fff51f73000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1
(0x00007f856994a000)
libacl.so.1 => /lib/x86_64-linux-gnu/libacl.so.1 (0x00007f8569940000)
libattr.so.1 => /lib/x86_64-linux-gnu/libattr.so.1 (0x00007f8569938000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8569710000)
libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0
(0x00007f8569679000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8569998000)
$ mkdir dir1
$ echo foo > dir1/file1
$ mv dir1 /media/nas/bruno/dir1
mv: failed to preserve ownership for '/media/nas/bruno/dir1': Permission denied
$ echo $?
0
Here /media/nas/bruno/dir1 is on a CIFS version 1 file system, and the
'strace' log from the 'mv' command shows the essential syscalls:
utimensat(AT_FDCWD, "/media/nas/bruno/dir1", [{tv_sec=1693067148,
tv_nsec=145342620} /* 2023-08-26T18:25:48.145342620+0200 */,
{tv_sec=1693067154, tv_nsec=717388257} /* 2023-08-26T18:25:54.717388257+0200
*/], 0) = 0
fchownat(AT_FDCWD, "/media/nas/bruno/dir1", 1000, 1000, AT_SYMLINK_NOFOLLOW) =
-1 EACCES (Permission denied)
Note: In earlier versions of coreutils 'mv', instead of an fchownat call, we
saw an equivalent lchown call:
lchown("/media/nas/bruno/dir1", 1000, 1000) = -1 EACCES (Permission denied)
Bruno