GNU bug report logs - #63212
[PATCH] fix NFSv4 acl detection on F39

Previous Next

Package: coreutils;

Reported by: Ondrej Valousek <ondrej.valousek.xm <at> renesas.com>

Date: Mon, 1 May 2023 19:43:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63212 in the body.
You can then email your comments to 63212 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#63212; Package coreutils. (Mon, 01 May 2023 19:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ondrej Valousek <ondrej.valousek.xm <at> renesas.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 01 May 2023 19:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ondrej Valousek <ondrej.valousek.xm <at> renesas.com>
To: bug-coreutils <at> gnu.org
Cc: Ondrej Valousek <ondrej.valousek.xm <at> renesas.com>
Subject: [PATCH] fix NFSv4 acl detection on F39
Date: Mon,  1 May 2023 21:38:08 +0200
Sending the other proposed patch fixing the NFSv4 acl detection on Fedora39.
It's bit longer, but I think should be better.
Please review.

---
 lib/file-has-acl.c | 60 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 49 insertions(+), 11 deletions(-)

diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index b31a2ea252..27da1c0607 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -121,6 +121,30 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes)
 
   return 0;
 }
+
+/* Return 1 if ATTR is found in the xattr list given by BUF */
+int have_xattr (char const *attr, char *buf, ssize_t buflen)
+{
+  char const *key = buf;
+  /* Loop over the list of zero terminated strings with the
+     attribute keys. Use the remaining buffer length to determine
+     the end of the list. */
+  while (buflen > 0) {
+    int keylen;
+
+    if (strcmp (key, attr) == 0)
+      {
+        /* we don't expect this function will be called again
+           so we free the buffer so caller does not have to */
+        free (buf);
+        return 1;
+      }
+    keylen = strlen (key) + 1;
+    buflen -= keylen;
+    key += keylen;
+  }
+  return 0;
+}
 #endif
 
 /* Return 1 if NAME has a nontrivial access control list,
@@ -139,25 +163,37 @@ file_has_acl (char const *name, struct stat const *sb)
 
 # if GETXATTR_WITH_POSIX_ACLS
 
-      ssize_t ret;
+      ssize_t ret, buflen;
+      char *attrlist;
       int initial_errno = errno;
 
-      ret = getxattr (name, XATTR_NAME_POSIX_ACL_ACCESS, NULL, 0);
-      if (ret < 0 && errno == ENODATA)
-        ret = 0;
-      else if (ret > 0)
+      ret = listxattr (name, NULL, 0);
+      if (ret <= 0)
+        return ret;
+      attrlist = malloc (ret);
+      if (attrlist == NULL)
+        return -1;
+      buflen = listxattr (name, attrlist, ret);
+      if (buflen == -1)
+        {
+          free (attrlist);
+          return - acl_errno_valid (errno);
+        }
+
+      if(have_xattr (XATTR_NAME_POSIX_ACL_ACCESS, attrlist, buflen))
         return 1;
+      else
+        ret = 0;
 
-      if (ret == 0 && S_ISDIR (sb->st_mode))
+      if (S_ISDIR (sb->st_mode))
         {
-          ret = getxattr (name, XATTR_NAME_POSIX_ACL_DEFAULT, NULL, 0);
-          if (ret < 0 && errno == ENODATA)
-            ret = 0;
-          else if (ret > 0)
+          if (have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, attrlist, buflen))
             return 1;
+          else
+            ret = 0;
         }
 
-      if (ret < 0)
+      if (have_xattr (XATTR_NAME_NFSV4_ACL, attrlist, buflen))
         {
           /* Check for NFSv4 ACLs.  The max length of a trivial
              ACL is 6 words for owner, 6 for group, 7 for everyone,
@@ -186,6 +222,8 @@ file_has_acl (char const *name, struct stat const *sb)
               errno = initial_errno;
             }
         }
+      else
+        free (attrlist);
       if (ret < 0)
         return - acl_errno_valid (errno);
       return ret;
-- 
2.40.1





Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sun, 16 Feb 2025 06:08:02 GMT) Full text and rfc822 format available.

Notification sent to Ondrej Valousek <ondrej.valousek.xm <at> renesas.com>:
bug acknowledged by developer. (Sun, 16 Feb 2025 06:08:02 GMT) Full text and rfc822 format available.

Message #10 received at 63212-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 63212-done <at> debbugs.gnu.org
Subject: Re: [PATCH] fix NFSv4 acl detection on F39
Date: Sat, 15 Feb 2025 22:07:19 -0800
Closing the old bug report <https://bugs.gnu.org/63212> as the bug was 
fixed in Gnulib later that month. See the thread containing 
<https://lists.gnu.org/r/bug-gnulib/2023-05/msg00092.html>.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 16 Mar 2025 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.