]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: chown: check --no-dereference on a symlink to a directory
authorSylvestre Ledru <sylvestre@debian.org>
Sat, 30 May 2026 12:55:37 +0000 (14:55 +0200)
committerPádraig Brady <P@draigBrady.com>
Sat, 30 May 2026 13:08:14 +0000 (14:08 +0100)
* tests/chown/basic.sh: Add a case ensuring that "chown
--no-dereference" on a symlink to a directory operates on the link
itself and does not dereference it to change the owner of the target
directory.
https://github.com/coreutils/coreutils/pull/272

tests/chown/basic.sh

index 77b744f743560eb02f3821fed58c5bc769cb00aa..16b6c94b0f7ed8872c9cf07fa46af80f6c6da006 100755 (executable)
@@ -56,4 +56,15 @@ chown --no-dereference --from=0:1 2:010 slink || fail=1
 # owner/group on the symlink should be changed
 set _ $(ls -n slink); shift; test "$3:$4" = 2:10 || fail=1
 
+# Likewise for a symlink to a directory: --no-dereference must operate
+# on the link itself, not descend into the target directory.
+mkdir d || framework_failure_
+chown 2:10 d || fail=1
+ln -s d dlink || framework_failure_
+chown --no-dereference 0:1 dlink || fail=1
+# owner/group on the symlink should be set
+set _ $(ls -n dlink); shift; test "$3:$4" = 0:1  || fail=1
+# owner/group on the target directory should remain unchanged
+set _ $(ls -dn d);    shift; test "$3:$4" = 2:10 || fail=1
+
 Exit $fail