linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [SMB3.1.1][PATCH] SMB3.1.1: Fix ids returned in POSIX query dir
@ 2020-10-20  7:08 Steve French
  2020-10-20 14:02 ` Aurélien Aptel
  0 siblings, 1 reply; 2+ messages in thread
From: Steve French @ 2020-10-20  7:08 UTC (permalink / raw)
  To: CIFS

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

We were setting the uid/gid to the default in each dir entry
in the parsing of the POSIX query dir response, rather
than attempting to map the user and group SIDs returned by
the server to well known SIDs (or upcall if not found).

I noticed that Samba server (Jeremy's POSIX branch) returns well known sid
for the group but not for the owner (e.g. S-1-22-2-1000 for the group but
a complex SID for the user owner) but at least even if cifs upcall is
not configured
we still get the group owner displayed correctly.



-- 
Thanks,

Steve

[-- Attachment #2: 0001-SMB3.1.1-Fix-ids-returned-in-POSIX-query-dir.patch --]
[-- Type: text/x-patch, Size: 2651 bytes --]

From b9b8a181a05d384ec92bd2ef415dea0665811a8b Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Tue, 20 Oct 2020 02:02:02 -0500
Subject: [PATCH] SMB3.1.1: Fix ids returned in POSIX query dir

We were setting the uid/gid to the default in each dir entry
in the parsing of the POSIX query dir response, rather
than attempting to map the user and group SIDs returned by
the server to well known SIDs (or upcall if not found).

CC: Stable <stable@vger.kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/cifsacl.c   | 5 +++--
 fs/cifs/cifsproto.h | 2 ++
 fs/cifs/readdir.c   | 5 ++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index fcff14ef1c70..23b21e943652 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -338,7 +338,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct cifs_sid *ssid)
 	goto out_key_put;
 }
 
-static int
+int
 sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
 		struct cifs_fattr *fattr, uint sidtype)
 {
@@ -359,7 +359,8 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
 		return -EIO;
 	}
 
-	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) {
+	if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) ||
+	    (cifs_sb_master_tcon(cifs_sb)->posix_extensions)) {
 		uint32_t unix_id;
 		bool is_group;
 
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index bb68cbf81074..24c6f36177ba 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -209,6 +209,8 @@ extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
 extern int cifs_rename_pending_delete(const char *full_path,
 				      struct dentry *dentry,
 				      const unsigned int xid);
+extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
+				struct cifs_fattr *fattr, uint sidtype);
 extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
 			      struct cifs_fattr *fattr, struct inode *inode,
 			      bool get_mode_from_special_sid,
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 31a18aae5e64..5abf1ea21abe 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -267,9 +267,8 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info,
 	if (reparse_file_needs_reval(fattr))
 		fattr->cf_flags |= CIFS_FATTR_NEED_REVAL;
 
-	/* TODO map SIDs */
-	fattr->cf_uid = cifs_sb->mnt_uid;
-	fattr->cf_gid = cifs_sb->mnt_gid;
+	sid_to_id(cifs_sb, &parsed.owner, fattr, SIDOWNER);
+	sid_to_id(cifs_sb, &parsed.group, fattr, SIDGROUP);
 }
 
 static void __dir_info_to_fattr(struct cifs_fattr *fattr, const void *info)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [SMB3.1.1][PATCH] SMB3.1.1: Fix ids returned in POSIX query dir
  2020-10-20  7:08 [SMB3.1.1][PATCH] SMB3.1.1: Fix ids returned in POSIX query dir Steve French
@ 2020-10-20 14:02 ` Aurélien Aptel
  0 siblings, 0 replies; 2+ messages in thread
From: Aurélien Aptel @ 2020-10-20 14:02 UTC (permalink / raw)
  To: Steve French, CIFS


Reviewed-by: Aurelien Aptel <aaptel@suse.com>

-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-20 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-20  7:08 [SMB3.1.1][PATCH] SMB3.1.1: Fix ids returned in POSIX query dir Steve French
2020-10-20 14:02 ` Aurélien Aptel

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).