linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
	Olga Kornievskaia <kolga@netapp.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: "Andreas Grünbacher" <andreas.gruenbacher@gmail.com>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] nfsd: better conform to setfacl's method for setting missing ACEs
Date: Fri, 21 Jul 2023 10:26:41 -0400	[thread overview]
Message-ID: <20230721142642.45871-1-jlayton@kernel.org> (raw)

Andreas pointed out that the way we're setting missing ACEs doesn't
quite conform to what setfacl does. Change it to better conform to
how setfacl does this.

Cc: Andreas Grünbacher <andreas.gruenbacher@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfsd/nfs4acl.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Chuck, it might be best to fold this into the original patch, if it
looks ok.

diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index 64e45551d1b6..9ec61bd0e11b 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -742,14 +742,15 @@ static int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *acl,
 	 *  no owner, owning group, or others entry,  a  copy of  the  ACL
 	 *  owner, owning group, or others entry is added to the Default ACL."
 	 *
-	 * If none of the requisite ACEs were set, and some explicit user or group
-	 * ACEs were, copy the requisite entries from the effective set.
+	 * Copy any missing ACEs from the effective set.
 	 */
-	if (!default_acl_state.valid &&
-	    (default_acl_state.users->n || default_acl_state.groups->n)) {
-		default_acl_state.owner = effective_acl_state.owner;
-		default_acl_state.group = effective_acl_state.group;
-		default_acl_state.other = effective_acl_state.other;
+	if (default_acl_state.users->n || default_acl_state.groups->n) {
+		if (!(default_acl_state.valid & ACL_USER_OBJ))
+			default_acl_state.owner = effective_acl_state.owner;
+		if (!(default_acl_state.valid & ACL_GROUP_OBJ))
+			default_acl_state.group = effective_acl_state.group;
+		if (!(default_acl_state.valid & ACL_OTHER))
+			default_acl_state.other = effective_acl_state.other;
 	}
 
 	*pacl = posix_state_to_acl(&effective_acl_state, flags);
-- 
2.41.0


             reply	other threads:[~2023-07-21 14:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 14:26 Jeff Layton [this message]
2023-07-21 16:29 ` [PATCH] nfsd: better conform to setfacl's method for setting missing ACEs Andreas Grünbacher
2023-07-21 16:50   ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230721142642.45871-1-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=andreas.gruenbacher@gmail.com \
    --cc=chuck.lever@oracle.com \
    --cc=kolga@netapp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).