Skip to content

Commit 5c6e5aa

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: move security mount options into fs_context.ch
This patch moves the parsing of security mount options into fs_context.ch. There are no changes to any logic. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Aurelien Aptel <aaptel@suse.com>
1 parent a6a9cff commit 5c6e5aa

3 files changed

Lines changed: 96 additions & 85 deletions

File tree

fs/cifs/connect.c

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#ifdef CONFIG_CIFS_DFS_UPCALL
6262
#include "dfs_cache.h"
6363
#endif
64+
#include "fs_context.h"
6465

6566
extern mempool_t *cifs_req_poolp;
6667
extern bool disable_legacy_dialects;
@@ -279,33 +280,6 @@ static const match_table_t cifs_mount_option_tokens = {
279280
{ Opt_err, NULL }
280281
};
281282

282-
enum {
283-
Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p,
284-
Opt_sec_ntlmsspi, Opt_sec_ntlmssp,
285-
Opt_ntlm, Opt_sec_ntlmi, Opt_sec_ntlmv2,
286-
Opt_sec_ntlmv2i, Opt_sec_lanman,
287-
Opt_sec_none,
288-
289-
Opt_sec_err
290-
};
291-
292-
static const match_table_t cifs_secflavor_tokens = {
293-
{ Opt_sec_krb5, "krb5" },
294-
{ Opt_sec_krb5i, "krb5i" },
295-
{ Opt_sec_krb5p, "krb5p" },
296-
{ Opt_sec_ntlmsspi, "ntlmsspi" },
297-
{ Opt_sec_ntlmssp, "ntlmssp" },
298-
{ Opt_ntlm, "ntlm" },
299-
{ Opt_sec_ntlmi, "ntlmi" },
300-
{ Opt_sec_ntlmv2, "nontlm" },
301-
{ Opt_sec_ntlmv2, "ntlmv2" },
302-
{ Opt_sec_ntlmv2i, "ntlmv2i" },
303-
{ Opt_sec_lanman, "lanman" },
304-
{ Opt_sec_none, "none" },
305-
306-
{ Opt_sec_err, NULL }
307-
};
308-
309283
/* cache flavors */
310284
enum {
311285
Opt_cache_loose,
@@ -1372,63 +1346,6 @@ static int get_option_gid(substring_t args[], kgid_t *result)
13721346
return 0;
13731347
}
13741348

1375-
static int cifs_parse_security_flavors(char *value,
1376-
struct smb_vol *vol)
1377-
{
1378-
1379-
substring_t args[MAX_OPT_ARGS];
1380-
1381-
/*
1382-
* With mount options, the last one should win. Reset any existing
1383-
* settings back to default.
1384-
*/
1385-
vol->sectype = Unspecified;
1386-
vol->sign = false;
1387-
1388-
switch (match_token(value, cifs_secflavor_tokens, args)) {
1389-
case Opt_sec_krb5p:
1390-
cifs_dbg(VFS, "sec=krb5p is not supported!\n");
1391-
return 1;
1392-
case Opt_sec_krb5i:
1393-
vol->sign = true;
1394-
fallthrough;
1395-
case Opt_sec_krb5:
1396-
vol->sectype = Kerberos;
1397-
break;
1398-
case Opt_sec_ntlmsspi:
1399-
vol->sign = true;
1400-
fallthrough;
1401-
case Opt_sec_ntlmssp:
1402-
vol->sectype = RawNTLMSSP;
1403-
break;
1404-
case Opt_sec_ntlmi:
1405-
vol->sign = true;
1406-
fallthrough;
1407-
case Opt_ntlm:
1408-
vol->sectype = NTLM;
1409-
break;
1410-
case Opt_sec_ntlmv2i:
1411-
vol->sign = true;
1412-
fallthrough;
1413-
case Opt_sec_ntlmv2:
1414-
vol->sectype = NTLMv2;
1415-
break;
1416-
#ifdef CONFIG_CIFS_WEAK_PW_HASH
1417-
case Opt_sec_lanman:
1418-
vol->sectype = LANMAN;
1419-
break;
1420-
#endif
1421-
case Opt_sec_none:
1422-
vol->nullauth = 1;
1423-
break;
1424-
default:
1425-
cifs_dbg(VFS, "bad security option: %s\n", value);
1426-
return 1;
1427-
}
1428-
1429-
return 0;
1430-
}
1431-
14321349
static int
14331350
cifs_parse_cache_flavor(char *value, struct smb_vol *vol)
14341351
{

fs/cifs/fs_context.c

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,79 @@
66
* David Howells <dhowells@redhat.com>
77
*/
88

9+
#include "cifsglob.h"
10+
#include "cifs_debug.h"
11+
#include "fs_context.h"
12+
13+
static const match_table_t cifs_secflavor_tokens = {
14+
{ Opt_sec_krb5, "krb5" },
15+
{ Opt_sec_krb5i, "krb5i" },
16+
{ Opt_sec_krb5p, "krb5p" },
17+
{ Opt_sec_ntlmsspi, "ntlmsspi" },
18+
{ Opt_sec_ntlmssp, "ntlmssp" },
19+
{ Opt_ntlm, "ntlm" },
20+
{ Opt_sec_ntlmi, "ntlmi" },
21+
{ Opt_sec_ntlmv2, "nontlm" },
22+
{ Opt_sec_ntlmv2, "ntlmv2" },
23+
{ Opt_sec_ntlmv2i, "ntlmv2i" },
24+
{ Opt_sec_lanman, "lanman" },
25+
{ Opt_sec_none, "none" },
26+
27+
{ Opt_sec_err, NULL }
28+
};
29+
30+
int cifs_parse_security_flavors(char *value, struct smb_vol *vol)
31+
{
32+
33+
substring_t args[MAX_OPT_ARGS];
34+
35+
/*
36+
* With mount options, the last one should win. Reset any existing
37+
* settings back to default.
38+
*/
39+
vol->sectype = Unspecified;
40+
vol->sign = false;
41+
42+
switch (match_token(value, cifs_secflavor_tokens, args)) {
43+
case Opt_sec_krb5p:
44+
cifs_dbg(VFS, "sec=krb5p is not supported!\n");
45+
return 1;
46+
case Opt_sec_krb5i:
47+
vol->sign = true;
48+
fallthrough;
49+
case Opt_sec_krb5:
50+
vol->sectype = Kerberos;
51+
break;
52+
case Opt_sec_ntlmsspi:
53+
vol->sign = true;
54+
fallthrough;
55+
case Opt_sec_ntlmssp:
56+
vol->sectype = RawNTLMSSP;
57+
break;
58+
case Opt_sec_ntlmi:
59+
vol->sign = true;
60+
fallthrough;
61+
case Opt_ntlm:
62+
vol->sectype = NTLM;
63+
break;
64+
case Opt_sec_ntlmv2i:
65+
vol->sign = true;
66+
fallthrough;
67+
case Opt_sec_ntlmv2:
68+
vol->sectype = NTLMv2;
69+
break;
70+
#ifdef CONFIG_CIFS_WEAK_PW_HASH
71+
case Opt_sec_lanman:
72+
vol->sectype = LANMAN;
73+
break;
74+
#endif
75+
case Opt_sec_none:
76+
vol->nullauth = 1;
77+
break;
78+
default:
79+
cifs_dbg(VFS, "bad security option: %s\n", value);
80+
return 1;
81+
}
82+
83+
return 0;
84+
}

fs/cifs/fs_context.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@
99
#ifndef _FS_CONTEXT_H
1010
#define _FS_CONTEXT_H
1111

12+
#include <linux/parser.h>
13+
#include "cifsglob.h"
1214

15+
enum cifs_sec_param {
16+
Opt_sec_krb5,
17+
Opt_sec_krb5i,
18+
Opt_sec_krb5p,
19+
Opt_sec_ntlmsspi,
20+
Opt_sec_ntlmssp,
21+
Opt_ntlm,
22+
Opt_sec_ntlmi,
23+
Opt_sec_ntlmv2,
24+
Opt_sec_ntlmv2i,
25+
Opt_sec_lanman,
26+
Opt_sec_none,
1327

14-
#endif
28+
Opt_sec_err
29+
};
30+
31+
int cifs_parse_security_flavors(char *value, struct smb_vol *vol);
1532

33+
#endif

0 commit comments

Comments
 (0)