Skip to content

Commit 77d8aa7

Browse files
takayuki-nagatasmfrench
authored andcommitted
cifs: reinstate original behavior again for forceuid/forcegid
forceuid/forcegid should be enabled by default when uid=/gid= options are specified, but commit 24e0a1e ("cifs: switch to new mount api") changed the behavior. Due to the change, a mounted share does not show intentional uid/gid for files and directories even though uid=/gid= options are specified since forceuid/forcegid are not enabled. This patch reinstates original behavior that overrides uid/gid with specified uid/gid by the options. Fixes: 24e0a1e ("cifs: switch to new mount api") Signed-off-by: Takayuki Nagata <[email protected]> Acked-by: Paulo Alcantara (Red Hat) <[email protected]> Acked-by: Ronnie Sahlberg <[email protected]> Acked-by: Tom Talpey <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 18d8696 commit 77d8aa7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

fs/smb/client/fs_context.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,16 @@ static int smb3_fs_context_validate(struct fs_context *fc)
748748
/* set the port that we got earlier */
749749
cifs_set_port((struct sockaddr *)&ctx->dstaddr, ctx->port);
750750

751+
if (ctx->uid_specified && !ctx->forceuid_specified) {
752+
ctx->override_uid = 1;
753+
pr_notice("enabling forceuid mount option implicitly because uid= option is specified\n");
754+
}
755+
756+
if (ctx->gid_specified && !ctx->forcegid_specified) {
757+
ctx->override_gid = 1;
758+
pr_notice("enabling forcegid mount option implicitly because gid= option is specified\n");
759+
}
760+
751761
if (ctx->override_uid && !ctx->uid_specified) {
752762
ctx->override_uid = 0;
753763
pr_notice("ignoring forceuid mount option specified with no uid= option\n");
@@ -1019,12 +1029,14 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
10191029
ctx->override_uid = 0;
10201030
else
10211031
ctx->override_uid = 1;
1032+
ctx->forceuid_specified = true;
10221033
break;
10231034
case Opt_forcegid:
10241035
if (result.negated)
10251036
ctx->override_gid = 0;
10261037
else
10271038
ctx->override_gid = 1;
1039+
ctx->forcegid_specified = true;
10281040
break;
10291041
case Opt_perm:
10301042
if (result.negated)

fs/smb/client/fs_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ enum cifs_param {
165165
};
166166

167167
struct smb3_fs_context {
168+
bool forceuid_specified;
169+
bool forcegid_specified;
168170
bool uid_specified;
169171
bool cruid_specified;
170172
bool gid_specified;

0 commit comments

Comments
 (0)