diff mbox

posix remove acl support

Message ID CAH2r5mvcidQk7C47ZSFLPZ0yaU2yzzAabWDK2f19VMxBi3NzTg@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Steve French Nov. 21, 2013, 5:04 a.m. UTC
Jeremy,
As you noted we need to add support to cifs kernel client to remove POSIX ACLs.

This patch is close (it seems to work, but wireshark did not like the
buffer lengths when I did a setfacl -k although setacl -b looked fine.

It works basically by passing the minimum size in for the ACL (0
entries) - sending a zero in the number of ACEs removes the entry.

Comments/feedback?

  cifs_dbg(FYI,

Comments

Jeremy Allison Nov. 21, 2013, 5:16 a.m. UTC | #1
On Wed, Nov 20, 2013 at 11:04:57PM -0600, Steve French wrote:
> Jeremy,
> As you noted we need to add support to cifs kernel client to remove POSIX ACLs.
> 
> This patch is close (it seems to work, but wireshark did not like the
> buffer lengths when I did a setfacl -k although setacl -b looked fine.
> 
> It works basically by passing the minimum size in for the ACL (0
> entries) - sending a zero in the number of ACEs removes the entry.
> 
> Comments/feedback?

Yep, sending a zero size for the number of ACE entries
will delete the ACL on the Samba server side.

I don't have the capability to test your patch right now
though, but you should be able to test it against any
modern Samba server installation.

Jeremy.
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve French Nov. 21, 2013, 5:35 a.m. UTC | #2
On Wed, Nov 20, 2013 at 11:16 PM, Jeremy Allison <jra@samba.org> wrote:
> On Wed, Nov 20, 2013 at 11:04:57PM -0600, Steve French wrote:
>> Jeremy,
>> As you noted we need to add support to cifs kernel client to remove POSIX ACLs.
>>
>> This patch is close (it seems to work, but wireshark did not like the
>> buffer lengths when I did a setfacl -k although setacl -b looked fine.
>>
>> It works basically by passing the minimum size in for the ACL (0
>> entries) - sending a zero in the number of ACEs removes the entry.
>>
>> Comments/feedback?
>
> Yep, sending a zero size for the number of ACE entries
> will delete the ACL on the Samba server side.
>
> I don't have the capability to test your patch right now
> though, but you should be able to test it against any
> modern Samba server installation.

Looks fine so far (with the exception of the on the wire formatting
problem in one case above - which samba seems ok with or wireshark has
a bug - need to check tomorrow)
diff mbox

Patch

diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 09afda4..c301651 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -69,6 +69,33 @@  int cifs_removexattr(struct dentry *direntry, const char *ea_name)
 	}
 	if (ea_name == NULL) {
 		cifs_dbg(FYI, "Null xattr names not supported\n");
+
+#ifdef CONFIG_CIFS_POSIX		
+	} else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
+				   strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
+		if (sb->s_flags & MS_POSIXACL) {
+			posix_acl_xattr_header acl;
+			acl.a_version = cpu_to_le32(2);
+			rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
+				(const char *)&acl,
+				4 /* min struct posix_acl_xattr_header */,
+				ACL_TYPE_ACCESS, cifs_sb->local_nls,
+				cifs_sb->mnt_cifs_flags &
+					CIFS_MOUNT_MAP_SPECIAL_CHR);
+			cifs_dbg(VFS, "set POSIX ACL rc %d\n", rc); /* BB FIXME BB */
+		}
+	} else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
+				   strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
+		if (sb->s_flags & MS_POSIXACL) {
+			posix_acl_xattr_header acl;
+			acl.a_version = cpu_to_le32(2);
+			rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
+				(const char *)&acl, 4, ACL_TYPE_DEFAULT,
+				cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
+					CIFS_MOUNT_MAP_SPECIAL_CHR);
+			cifs_dbg(VFS, "set POSIX default ACL rc %d\n", rc); /* BB FIXME BB */
+		}
+#endif /* CONFIG_CIFS_POSIX */
 	} else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
 		&& (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN))) {
 		cifs_dbg(FYI,