smb: client: set correct id, uid and cruid for multiuser automounts
Subsystems (2)
PATCH 1/2 smb: client: set correct id, uid and cruid for multiuser automounts
When uid, gid and cruid are not specified, we need to set dynamically set them into the filesystem context used for automounting otherwise they'll end up reusing the values from the parent mount.
--- fs/smb/client/namespace.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/smb/client/namespace.c +16 -0
@@ -168,6 +168,21 @@ static char *automount_fullpath(struct dentry *dentry, void *page)return s; } +static void fs_context_set_ids (struct smb3_fs_context *ctx) +{ +kuid_t uid =current_fsuid (); +kgid_t gid =current_fsgid (); + +if (ctx->multiuser) { +if (!ctx->uid_specified) + ctx->linux_uid = uid; +if (!ctx->gid_specified) + ctx->linux_gid = gid; + } +if (!ctx->cruid_specified) + ctx->cred_uid = uid; +} +/* * Create a vfsmount that we can automount */
@@ -205,6 +220,7 @@ static struct vfsmount *cifs_do_automount(struct path *path) tmp.leaf_fullpath =NULL ; tmp.UNC = tmp.prepath =NULL ; tmp.dfs_root_ses =NULL ; +fs_context_set_ids (&tmp); rc =smb3_fs_context_dup (ctx, &tmp);if (rc) {
Signature · 1 line
2.43.0
PATCH 2/2 smb: client: handle path separator of created SMB symlinks
Convert path separator to CIFS_DIR_SEP(cifs_sb) from symlink target before sending it over the wire otherwise the created SMB symlink may become innaccesible from server side.
--- fs/smb/client/smb2ops.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/smb/client/smb2ops.c +6 -2
@@ -5217,7 +5217,7 @@ static int smb2_create_reparse_symlink(const unsigned int xid,struct inode *new;struct kvec iov;__le16 *path; -char *sym; +char *sym, sep =CIFS_DIR_SEP (cifs_sb);u16 len, plen;int rc =0 ;
@@ -5231,7 +5231,8 @@ static int smb2_create_reparse_symlink(const unsigned int xid, .symlink_target = sym, }; - path =cifs_convert_path_to_utf16 (symname, cifs_sb); +convert_delimiter (sym, sep); + path =cifs_convert_path_to_utf16 (sym, cifs_sb);if (!path) { rc = -ENOMEM ; goto out;
@@ -5254,7 +5255,10 @@ static int smb2_create_reparse_symlink(const unsigned int xid, buf->PrintNameLength =cpu_to_le16 (plen);memcpy (buf->PathBuffer, path, plen); buf->Flags =cpu_to_le32 (*symname !='/' ?SYMLINK_FLAG_RELATIVE :0 ); +if (*sym != sep) + buf->Flags =cpu_to_le32 (SYMLINK_FLAG_RELATIVE ); +convert_delimiter (sym,'/' ); iov.iov_base = buf; iov.iov_len = len; new = smb2_get_reparse_inode(&data, inode->i_sb, xid,
Signature · 1 line
2.43.0
tentatively merged these two into cifs-2.6.git for-next pending review and testing
Quoted 50 lines · Paulo Alcantara
When uid, gid and cruid are not specified, we need to set dynamically set them into the filesystem context used for automounting otherwise they'll end up reusing the values from the parent mount.
Fixes 9fd29a5bae6e ("cifs: use fs_context for automounts")Reported-by Shane Nehring <[email protected]>Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>--- fs/smb/client/namespace.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)fs/smb/client/namespace.c +16
-1@@ -168,6 +168,21 @@ static char *automount_fullpath(struct dentry *dentry, void *page)return s; } +static void fs_context_set_ids (struct smb3_fs_context *ctx) +{ +kuid_t uid =current_fsuid (); +kgid_t gid =current_fsgid (); + +if (ctx->multiuser) { +if (!ctx->uid_specified) + ctx->linux_uid = uid; +if (!ctx->gid_specified) + ctx->linux_gid = gid; + } +if (!ctx->cruid_specified) + ctx->cred_uid = uid; +} +/* * Create a vfsmount that we can automount */ @@ -205,6 +220,7 @@ static struct vfsmount *cifs_do_automount(struct path *path) tmp.leaf_fullpath =NULL ; tmp.UNC = tmp.prepath =NULL ; tmp.dfs_root_ses =NULL ; +fs_context_set_ids (&tmp); rc =smb3_fs_context_dup (ctx, &tmp);if (rc) { --2.43.0
Signature · 3 lines
Thanks, Steve