]>
Commit | Line | Data |
---|---|---|
a6a9cffa RS |
1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | /* | |
3 | * Copyright (C) 2020, Microsoft Corporation. | |
4 | * | |
5 | * Author(s): Steve French <stfrench@microsoft.com> | |
6 | * David Howells <dhowells@redhat.com> | |
7 | */ | |
8 | ||
5c6e5aa4 RS |
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 | } |