This issue was introduced in commit ccc26ad (Sep 2024).
* lib/file-has-acl.c (file_has_acl): Set ACL_SYMLINK_FOLLOW when the stat
buffer is not describing a symbolic link.
---
 ChangeLog          | 7 +++++++
 lib/file-has-acl.c | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 2115938896..3ebc036724 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-11-03  Lukáš Zaoral  <[email protected]>
+
+       file-has-acl: Fix dereferencing of symbolic links.
+       This issue was introduced in commit ccc26ad (Sep 2024).
+       * lib/file-has-acl.c (file_has_acl): Set ACL_SYMLINK_FOLLOW when the
+       stat buffer is not describing a symbolic link.
+
 2026-11-02  Bruno Haible  <[email protected]>
 
        findprog-in: Use a default PATH like POSIX specifies.
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index 8b9bb0468f..d2d5aec110 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -979,6 +979,10 @@ file_has_acl (char const *name, struct stat const *sb)
   int flags = IFTODT (sb->st_mode);
   if (!S_ISDIR (sb->st_mode))
     flags |= _GL_DT_NOTDIR;
+  /* If mode is not a symlink, assume that the stat buffer
+     was obtained through stat().  */
+  if (!S_ISLNK (sb->st_mode))
+    flags |= ACL_SYMLINK_FOLLOW;
   struct aclinfo ai;
   int r = file_has_aclinfo (name, &ai, flags);
   aclinfo_free (&ai);
-- 
2.56.0


Reply via email to