From d768f2144b738f7b2bd4d6fc536230dd5523e0ed Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 30 May 2026 14:55:37 +0200 Subject: [PATCH] tests: chown: check --no-dereference on a symlink to a directory * 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/chown/basic.sh b/tests/chown/basic.sh index 77b744f74..16b6c94b0 100755 --- a/tests/chown/basic.sh +++ b/tests/chown/basic.sh @@ -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