From unknown Sat Jun 21 12:12:53 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63212: [PATCH] fix NFSv4 acl detection on F39 Resent-From: Ondrej Valousek Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 01 May 2023 19:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63212 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: 63212@debbugs.gnu.org Cc: Ondrej Valousek X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168297016215811 (code B ref -1); Mon, 01 May 2023 19:43:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 May 2023 19:42:42 +0000 Received: from localhost ([127.0.0.1]:41084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptZQ1-00046w-Va for submit@debbugs.gnu.org; Mon, 01 May 2023 15:42:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:57300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptZPy-00046m-NH for submit@debbugs.gnu.org; Mon, 01 May 2023 15:42:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptZPy-0006Bf-6M for bug-coreutils@gnu.org; Mon, 01 May 2023 15:42:38 -0400 Received: from haproxy.adestotech.com ([217.163.77.122]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptZPu-0004To-7d for bug-coreutils@gnu.org; Mon, 01 May 2023 15:42:37 -0400 Received: from skynet19.adestotech.com (unknown [192.168.129.19]) by haproxy.adestotech.com (Postfix) with ESMTP id F011AA222F; Mon, 1 May 2023 20:42:23 +0100 (IST) From: Ondrej Valousek Date: Mon, 1 May 2023 21:38:08 +0200 Message-Id: <20230501193807.57932-1-ondrej.valousek.xm@renesas.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.163.77.122; envelope-from=ondrej.valousek.xm@renesas.com; helo=haproxy.adestotech.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) AC_FROM_MANY_DOTS=2.999, BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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 From unknown Sat Jun 21 12:12:53 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ondrej Valousek Subject: bug#63212: closed (Re: [PATCH] fix NFSv4 acl detection on F39) Message-ID: References: <359603a5-3336-4308-8a70-b214af74508c@cs.ucla.edu> <20230501193807.57932-1-ondrej.valousek.xm@renesas.com> X-Gnu-PR-Message: they-closed 63212 X-Gnu-PR-Package: coreutils X-Gnu-PR-Keywords: patch Reply-To: 63212@debbugs.gnu.org Date: Sun, 16 Feb 2025 06:08:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1739686083-23774-1" This is a multi-part message in MIME format... ------------=_1739686083-23774-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #63212: [PATCH] fix NFSv4 acl detection on F39 which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 63212@debbugs.gnu.org. --=20 63212: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63212 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1739686083-23774-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 63212-done) by debbugs.gnu.org; 16 Feb 2025 06:07:30 +0000 Received: from localhost ([127.0.0.1]:59562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjXoQ-0006Aa-AL for submit@debbugs.gnu.org; Sun, 16 Feb 2025 01:07:30 -0500 Received: from mail.cs.ucla.edu ([131.179.128.66]:55180) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjXoM-0006AE-Vm for 63212-done@debbugs.gnu.org; Sun, 16 Feb 2025 01:07:28 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 7559F3C00E415 for <63212-done@debbugs.gnu.org>; Sat, 15 Feb 2025 22:07:20 -0800 (PST) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id aOuLHAC2_kFN for <63212-done@debbugs.gnu.org>; Sat, 15 Feb 2025 22:07:20 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 331993C00E41C for <63212-done@debbugs.gnu.org>; Sat, 15 Feb 2025 22:07:20 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 331993C00E41C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1739686040; bh=ZnscpkMsbfKTLiNkwIYp244pfc1snhtDmXpb/mHbL2I=; h=Message-ID:Date:MIME-Version:To:From; b=G+Az0i8fIMIuOcUL7h7O7qqt9cZNbvt3V84gPmlScWusvvEznGdVqFX93de3zACcp wJZbuCH9X+E/rOqrV8Rg2VlCo+pW0pWE+/t6USRA3BquvnZN3+kTXqQtjfYggLm/Vy Cz8+o4+oA1zS07tKtPM4qeyo4DauKFLZLLBSI/94lbzCxQNED8uAKYvK9Hojzm58ZT pDkf4dMP41anAGo+4l2mChPsolSPSx4MfsASRt4PqI4tM/AIXkpr1m+Pdfmyu4clae Aox37kV3l0xvnYqPjZswRoOcakd5PHdyuO3Monf59jNr3lkDHI4Wwx4Q8mOOTdMsTq 8+5iqLOL38Pag== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id Tapnkz_hMtvS for <63212-done@debbugs.gnu.org>; Sat, 15 Feb 2025 22:07:20 -0800 (PST) Received: from [192.168.254.12] (unknown [47.147.225.25]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 182C53C00E415 for <63212-done@debbugs.gnu.org>; Sat, 15 Feb 2025 22:07:20 -0800 (PST) Message-ID: <359603a5-3336-4308-8a70-b214af74508c@cs.ucla.edu> Date: Sat, 15 Feb 2025 22:07:19 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: 63212-done@debbugs.gnu.org From: Paul Eggert Subject: Re: [PATCH] fix NFSv4 acl detection on F39 Organization: UCLA Computer Science Department Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63212-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Closing the old bug report as the bug was fixed in Gnulib later that month. See the thread containing . ------------=_1739686083-23774-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 1 May 2023 19:42:42 +0000 Received: from localhost ([127.0.0.1]:41084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptZQ1-00046w-Va for submit@debbugs.gnu.org; Mon, 01 May 2023 15:42:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:57300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptZPy-00046m-NH for submit@debbugs.gnu.org; Mon, 01 May 2023 15:42:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptZPy-0006Bf-6M for bug-coreutils@gnu.org; Mon, 01 May 2023 15:42:38 -0400 Received: from haproxy.adestotech.com ([217.163.77.122]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptZPu-0004To-7d for bug-coreutils@gnu.org; Mon, 01 May 2023 15:42:37 -0400 Received: from skynet19.adestotech.com (unknown [192.168.129.19]) by haproxy.adestotech.com (Postfix) with ESMTP id F011AA222F; Mon, 1 May 2023 20:42:23 +0100 (IST) From: Ondrej Valousek To: bug-coreutils@gnu.org Subject: [PATCH] fix NFSv4 acl detection on F39 Date: Mon, 1 May 2023 21:38:08 +0200 Message-Id: <20230501193807.57932-1-ondrej.valousek.xm@renesas.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.163.77.122; envelope-from=ondrej.valousek.xm@renesas.com; helo=haproxy.adestotech.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) AC_FROM_MANY_DOTS=2.999, BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Ondrej Valousek X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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 ------------=_1739686083-23774-1--