]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: realpath: a trailing slash must not require read permission
authorSylvestre Ledru <sylvestre@debian.org>
Sun, 28 Jun 2026 12:27:46 +0000 (14:27 +0200)
committerPádraig Brady <P@draigBrady.com>
Tue, 30 Jun 2026 15:27:15 +0000 (16:27 +0100)
A trailing slash only asserts that the operand is a directory.  That
is a stat-level check, needing search permission on the parent, not
read permission on the directory itself.
* tests/misc/realpath.sh: Check that a searchable but unreadable
directory still resolves with a trailing slash, with and without -e.

Link: https://github.com/coreutils/coreutils/pull/307
tests/misc/realpath.sh

index 56bd8597a3da265497b350c08c5522851c19eaac..501a7baa605d310701a2f6b6c702ffdebfb0a244 100755 (executable)
@@ -111,4 +111,11 @@ else
   test "$out" = ".$nl." || fail=1
 fi
 
+# A trailing slash only requires the operand to be a directory, which is a
+# stat-level check (search permission on the parent). A directory that is
+# searchable but not readable must still resolve, not fail with EACCES.
+mkdir noread && chmod a-r noread || framework_failure_
+test "$(realpath noread/)" = "$(realpath .)/noread" || fail=1
+test "$(realpath -e noread/)" = "$(realpath .)/noread" || fail=1
+
 Exit $fail