]> Savannah Git Hosting - gnulib.git/commitdiff
file-has-acl: port to Linux 6.12 + NFS listxattr
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 10 Jan 2025 04:37:13 +0000 (20:37 -0800)
committerBruno Haible <bruno@clisp.org>
Sat, 18 Jan 2025 08:11:33 +0000 (09:11 +0100)
* lib/file-has-acl.c (get_aclinfo): Try the getxattr-related calls
even if [l]listxattr fails with EACCES.  Problem reported by
Pádraig Brady <https://bugs.gnu.org/74692#25>.  Also, treat E2BIG
like EACCES.

ChangeLog
lib/file-has-acl.c

index ad37cb17e76ba8c70ab2ab0aeb58a390081d0bfa..cf2abb2f6d32086ea6f1c974606eabf7788f3f89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-01-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       file-has-acl: port to Linux 6.12 + NFS listxattr
+       * lib/file-has-acl.c (get_aclinfo): Try the getxattr-related calls
+       even if [l]listxattr fails with EACCES.  Problem reported by
+       Pádraig Brady <https://bugs.gnu.org/74692#25>.  Also, treat E2BIG
+       like EACCES.
+
 2025-01-08  Paul Eggert  <eggert@cs.ucla.edu>
 
        fcntl-h: port better to musl on GNU/Linux
index 35dcc19f169cc2b817059cb03d432d8c43b584a1..5ec6b256ef762d7e0d867323dc34dc23f1c7865f 100644 (file)
@@ -176,11 +176,17 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags)
         }
     }
 
-  if (0 < ai->size && flags & ACL_GET_SCONTEXT)
+  /* A security context can exist only if extended attributes do: i.e.,
+     [l]listxattr either returned a positive number, or failed with E2BIG,
+     or failed with EACCES which in Linux kernel 6.12 NFS can mean merely
+     that we lack read access.  */
+  if (flags & ACL_GET_SCONTEXT
+      && (0 < ai->size
+          || (ai->size < 0 && (ai->u.err == E2BIG || ai->u.err == EACCES))))
     {
       if (is_smack_enabled ())
         {
-          if (aclinfo_has_xattr (ai, XATTR_NAME_SMACK))
+          if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SMACK))
             {
               ssize_t r = smack_new_label_from_path (name, "security.SMACK64",
                                                      flags & ACL_SYMLINK_FOLLOW,
@@ -191,7 +197,7 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags)
       else
         {
 # if USE_SELINUX_SELINUX_H
-          if (aclinfo_has_xattr (ai, XATTR_NAME_SELINUX))
+          if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SELINUX))
             {
               ssize_t r =
                 ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon)