Patrice Duroux wrote:
option: --preserve=mode
cp: preserving permissions for '/tmp/test.sh': Operation not supported exitcode: 1
[...]
It says that the operation is not supported but still the mode of the
copy is ok.
Maybe it sees ACL at the source file and your /tmp filesystem cannot
do ACL ?
Try with setfacl(1) whether files in the /tmp directory accept non-trivial ACLs, like
touch /tmp/x
setfacl -m u:1234:w /tmp/x
The inquiry by
getfacl /tmp/x
should then report among others a line:
user:1234:-w-
cp: preserving permissions for '/tmp/test.sh': Operation not supported
I was thinking something similar, but the "ls -l ./test.sh" did not
show any markup indicating ACL.
option: --preserve=mode
cp: preserving permissions for '/tmp/test.sh': Operation not supported exitcode: 1
[...]
It says that the operation is not supported but still the mode of the
copy is ok.
$ cat test.sh
#!/usr/bin/sh
export LANG=C
ls -l ./test.sh
echo "option: -p"
cp -p ./test.sh /tmp
echo "exitcode: "$?
ls -l /tmp/test.sh
rm /tmp/test.sh
for p in mode timestamps ownership ; do
echo "option: --preserve=$p"
cp --preserve=$p ./test.sh /tmp
echo "exitcode: "$?
ls -l /tmp/test.sh
rm /tmp/test.sh
done
On Sid (amd64), I am facing the following:
$ ./test.sh
-rwxr-x--- 1 patrice patrice 300 Jul 9 10:46 ./test.sh
option: -p
cp: preserving permissions for '/tmp/test.sh': Operation not supported exitcode: 1
-rwxr-x--- 1 patrice patrice 300 Jul 9 10:46 /tmp/test.sh
It says that the operation is not supported but still the mode of the
copy is ok.
Is there an issue somewhere?
Hi,
Patrice Duroux wrote:
cp: preserving permissions for '/tmp/test.sh': Operation not supported
Greg Wooledge wrote:
I was thinking something similar, but the "ls -l ./test.sh" did not
show any markup indicating ACL.
At least cp calls ACL "permissions". See
https://sources.debian.org/src/coreutils/9.4-3.1/lib/copy-acl.c/?hl=54#L54 After getting return value -1 from copy_acl(), it does:
error (0, errno, _("preserving permissions for %s"), quote (dst_name));
The other two occurences of the error message are not as easy to decode:
https://sources.debian.org/src/coreutils/9.4-3.1/src/copy.c/?hl=1696#L1696
https://sources.debian.org/src/coreutils/9.4-3.1/src/copy.c/?hl=3340#L3340
Other thought:
Maybe chattr(1) attribute "i" can be considered a permission, too.
user:1234:-w-
getfacl : suppression du premier « / » des noms de chemins absolus
(sorry for the french output)
$ LANG=C strace cp -p test.sh /tmp[...]
read(6, "# /etc/xattr.conf\n#\n# Format:\n# "..., 4096) = 681
read(6, "", 4096) = 0
close(6) = 0
fgetxattr(4, "system.nfs4_acl", NULL, 0) = 80
fgetxattr(4, "system.nfs4_acl", "\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\247\0\0\0\6OWNER@\0\0\0\0\0", 80) = 80
fsetxattr(5, "system.nfs4_acl", "\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\247\0\0\0\6OWNER@\0\0\0\0\0", 80, 0) = -1 EOPNOTSUPP (Operation not supported)
write(2, "cp: ", 4cp: ) = 4
write(2, "preserving permissions for '/tmp"..., 41preserving permissions for '/tmp/test.sh') = 41
write(2, ": Operation not supported", 25: Operation not supported) = 25 write(2, "\n", 1
$ mount | grep patrice
/home/patrice type nfs4 (rw,nosuid,nodev,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=X,local_lock=none,addr=Y)
Finally, note that I am a «he» otherwise in French it's generally Patricia for
«her»
:-D
$ LANG=C strace cp -p test.sh /tmp
flistxattr(4, NULL, 0) = 16
flistxattr(4, "system.nfs4_acl\0", 16) = 16
openat(AT_FDCWD, "/etc/xattr.conf", O_RDONLY) = 6
fsetxattr(5, "system.nfs4_acl", "\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\247\0\0\0\6OWNER@\0\0\0\0\0", 80, 0) = -1 EOPNOTSUPP (Operation not supported)
On 10/07/2024 02:35, Thomas Schmitt wrote:
Here the error happens while trying to set the attribute.
Shell equivalent is
setfattr -n system.nfs4_acl -v '\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\247\0\0\0\6OWNER@\0\0\0\0\0' /tmp/x
Shell does not interpret backslashes in single (and double) quotes. $'\0...' might be better
echo '\026' | xxd -g 1
00000000: 5c 30 32 36 0a \026.
echo $'\026' | xxd -g 1
00000000: 16 0a ..
setfattr -n system.nfs4_acl -v '\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\247\0\0\0\6OWNER@\0\0\0\0\0' /tmp/x
Shell does not interpret backslashes in single (and double) quotes.
Thomas's command is *relying* on setfattr interpreting the backslash sequences, because the shell cannot be allowed to do so.
On the other hand, after modifying /etc/xattr.conf to replace: system.nfs4_acl permissions
by:
system.nfs4_acl skip
then test.sh works nicely:
Is there a risk to leave /etc/xattr.conf like this?
If I am right, this file is provided by libattr1 package and its
content is from upstream: https://git.savannah.nongnu.org/cgit/attr.git/tree/xattr.conf
$ getfattr -d test.sh
$
$ nfs4_getfacl test.sh
# file: test.sh
A::OWNER@:rwaxtTcCy
A::GROUP@:rxtcy
A::EVERYONE@:tcy
Thomas, do you have in your collection of strange files a one moved out of a directory encrypted using fscrypt?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 149:52:10 |
Calls: | 10,383 |
Files: | 14,054 |
Messages: | 6,417,777 |