Skip to content

Commit be786e5

Browse files
paliSteve French
authored andcommitted
cifs: Set default Netbios RFC1001 server name to hostname in UNC
Windows SMB servers (including SMB2+) which are working over RFC1001 require that Netbios server name specified in RFC1001 Session Request packet is same as the UNC host name. Netbios server name can be already specified manually via -o servern= option. With this change the RFC1001 server name is set automatically by extracting the hostname from the mount source. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 4e7f164 commit be786e5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/smb/client/fs_context.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,7 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
11181118
int i, opt;
11191119
bool is_smb3 = !strcmp(fc->fs_type->name, "smb3");
11201120
bool skip_parsing = false;
1121+
char *hostname;
11211122

11221123
cifs_dbg(FYI, "CIFS: parsing cifs mount option '%s'\n", param->key);
11231124

@@ -1443,6 +1444,16 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
14431444
cifs_errorf(fc, "OOM when copying UNC string\n");
14441445
goto cifs_parse_mount_err;
14451446
}
1447+
hostname = extract_hostname(ctx->UNC);
1448+
if (IS_ERR(hostname)) {
1449+
cifs_errorf(fc, "Cannot extract hostname from UNC string\n");
1450+
goto cifs_parse_mount_err;
1451+
}
1452+
/* last byte, type, is 0x20 for servr type */
1453+
memset(ctx->target_rfc1001_name, 0x20, RFC1001_NAME_LEN_WITH_NULL);
1454+
for (i = 0; i < RFC1001_NAME_LEN && hostname[i] != 0; i++)
1455+
ctx->target_rfc1001_name[i] = toupper(hostname[i]);
1456+
kfree(hostname);
14461457
break;
14471458
case Opt_user:
14481459
kfree(ctx->username);

0 commit comments

Comments
 (0)