Re: [PATCH] cifs: move security option parsing to own function
Steven French <[email protected]> Thu, 27 May 2010 09:47:31 -0500
| Newsgroups | gmane.linux.file-systems.cifs |
|---|---|
| Message-ID | <OFBA0193DC.B1422D6A-ON87257730.00512ECD-86257730.0051415C@us.ibm.com> |
This is a multipart message in MIME format. --===============1386339554395247742== Content-Type: multipart/alternative; boundary="=_alternative 0051415886257730_=" This is a multipart message in MIME format. --=_alternative 0051415886257730_= Content-Type: text/plain; charset="US-ASCII" This looks fine as long as it doesn't conflict with one of Jeff's recent patches which hit sec processing. Steve French Senior Software Engineer Linux Technology Center - IBM Austin email: sfrench at-sign us dot ibm dot com Scott Lovenberg <[email protected]> 05/26/2010 07:45 PM To [email protected] cc [email protected], Steven French/Austin/IBM@IBMUS, Scott Lovenberg <[email protected]> Subject [PATCH] cifs: move security option parsing to own function Mount security options are now parsed in their own function. Signed-off-by: Scott Lovenberg <[email protected]> --- fs/cifs/connect.c | 111 +++++++++++++++++++++++++++------------------------- 1 files changed, 58 insertions(+), 53 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index ee78b65..bf7e40c 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -972,6 +972,61 @@ extract_hostname(const char *unc) } static int +cifs_parse_sec_option(char *value, struct smb_vol *vol) +{ + substring_t args[MAX_OPT_ARGS]; + switch (match_token(value, cifs_sec_options, args)) { + case Opt_sec_krb5i: + vol->secFlg |= CIFSSEC_MAY_KRB5 | CIFSSEC_MUST_SIGN; + break; + case Opt_sec_krb5p: + /* vol->secFlg |= CIFSSEC_MUST_SEAL | CIFSSEC_MAY_KRB5; */ + cERROR(1, "Krb5 cifs privacy not supported"); + return 1; + case Opt_sec_krb5: + vol->secFlg |= CIFSSEC_MAY_KRB5; + break; +#ifdef CONFIG_CIFS_EXPERIMENTAL + case Opt_sec_ntlmsspi: + vol->secFlg |= CIFSSEC_MAY_NTLMSSP | CIFSSEC_MUST_SIGN; + break; + case Opt_sec_ntlmssp: + vol->secFlg |= CIFSSEC_MAY_NTLMSSP; + break; +#endif + case Opt_sec_ntlmv2i: + vol->secFlg |= CIFSSEC_MAY_NTLMV2 | CIFSSEC_MUST_SIGN; + break; + case Opt_sec_ntlmv2: + vol->secFlg |= CIFSSEC_MAY_NTLMV2; + break; + case Opt_sec_ntlmi: + vol->secFlg |= CIFSSEC_MAY_NTLM | CIFSSEC_MUST_SIGN; + break; + case Opt_sec_ntlm: + /* ntlm is default so can be turned off too */ + vol->secFlg |= CIFSSEC_MAY_NTLM; + break; + case Opt_sec_nontlm: + /* BB is there a better way to do this? */ + vol->secFlg |= CIFSSEC_MAY_NTLMV2; + break; +#ifdef CONFIG_CIFS_WEAK_PW_HASH + case Opt_sec_lanman: + vol->secFlg |= CIFSSEC_MAY_LANMAN; + break; +#endif + case Opt_sec_none: + vol->nullauth = 1; + break; + default: + cERROR(1, "bad security option: %s", value); + return 1; + } + return 0; +} + +static int cifs_parse_mount_options(char *options, const char *devname, struct smb_vol *vol) { @@ -1158,59 +1213,9 @@ cifs_parse_mount_options(char *options, const char *devname, cERROR(1, "no security value specified"); continue; } - switch (match_token(value, cifs_sec_options, args)) { - case Opt_sec_krb5i: - vol->secFlg |= CIFSSEC_MAY_KRB5 | - CIFSSEC_MUST_SIGN; - break; - case Opt_sec_krb5p: - /* vol->secFlg |= CIFSSEC_MUST_SEAL | - CIFSSEC_MAY_KRB5; */ - cERROR(1, "Krb5 cifs privacy not supported"); - return 1; - case Opt_sec_krb5: - vol->secFlg |= CIFSSEC_MAY_KRB5; - break; -#ifdef CONFIG_CIFS_EXPERIMENTAL - case Opt_sec_ntlmsspi: - vol->secFlg |= CIFSSEC_MAY_NTLMSSP | - CIFSSEC_MUST_SIGN; - break; - case Opt_sec_ntlmssp: - vol->secFlg |= CIFSSEC_MAY_NTLMSSP; - break; -#endif - case Opt_sec_ntlmv2i: - vol->secFlg |= CIFSSEC_MAY_NTLMV2 | - CIFSSEC_MUST_SIGN; - break; - case Opt_sec_ntlmv2: - vol->secFlg |= CIFSSEC_MAY_NTLMV2; - break; - case Opt_sec_ntlmi: - vol->secFlg |= CIFSSEC_MAY_NTLM | - CIFSSEC_MUST_SIGN; - break; - case Opt_sec_ntlm: - /* ntlm is default so can be turned off too */ - vol->secFlg |= CIFSSEC_MAY_NTLM; - break; - case Opt_sec_nontlm: - /* BB is there a better way to do this? */ - vol->secFlg |= CIFSSEC_MAY_NTLMV2; - break; -#ifdef CONFIG_CIFS_WEAK_PW_HASH - case Opt_sec_lanman: - vol->secFlg |= CIFSSEC_MAY_LANMAN; - break; -#endif - case Opt_sec_none: - vol->nullauth = 1; - break; - default: - cERROR(1, "bad security option: %s", value); - return 1; - } + i = cifs_parse_sec_option(value, vol); + if (i) + return i; break; /* unc || target || path */ case Opt_unc: -- 1.6.2.5 --=_alternative 0051415886257730_= Content-Type: text/html; charset="US-ASCII" <font size=2 face="sans-serif">This looks fine as long as it doesn't conflict with one of Jeff's recent patches which hit sec processing.</font> <br><font size=2 face="sans-serif"><br> <br> Steve French<br> Senior Software Engineer<br> Linux Technology Center - IBM Austin<br> email: sfrench at-sign us dot ibm dot com</font> <br> <br> <br> <table width=100%> <tr valign=top> <td width=40%><font size=1 face="sans-serif"><b>Scott Lovenberg <[email protected]></b> </font> <p><font size=1 face="sans-serif">05/26/2010 07:45 PM</font> <td width=59%> <table width=100%> <tr valign=top> <td> <div align=right><font size=1 face="sans-serif">To</font></div> <td><font size=1 face="sans-serif">[email protected]</font> <tr valign=top> <td> <div align=right><font size=1 face="sans-serif">cc</font></div> <td><font size=1 face="sans-serif">[email protected], Steven French/Austin/IBM@IBMUS, Scott Lovenberg <[email protected]></font> <tr valign=top> <td> <div align=right><font size=1 face="sans-serif">Subject</font></div> <td><font size=1 face="sans-serif">[PATCH] cifs: move security option parsing to own function</font></table> <br> <table> <tr valign=top> <td> <td></table> <br></table> <br> <br> <br><tt><font size=2>Mount security options are now parsed in their own function.<br> <br> Signed-off-by: Scott Lovenberg <[email protected]><br> ---<br> fs/cifs/connect.c | 111 +++++++++++++++++++++++++++-------------------------<br> 1 files changed, 58 insertions(+), 53 deletions(-)<br> <br> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c<br> index ee78b65..bf7e40c 100644<br> --- a/fs/cifs/connect.c<br> +++ b/fs/cifs/connect.c<br> @@ -972,6 +972,61 @@ extract_hostname(const char *unc)<br> }<br> <br> static int<br> +cifs_parse_sec_option(char *value, struct smb_vol *vol)<br> +{<br> + substring_t args[MAX_OPT_ARGS];<br> + switch (match_token(value, cifs_sec_options, args)) {<br> + case Opt_sec_krb5i:<br> + vol->secFlg |= CIFSSEC_MAY_KRB5 | CIFSSEC_MUST_SIGN;<br> + break;<br> + case Opt_sec_krb5p:<br> + /* vol->secFlg |= CIFSSEC_MUST_SEAL | CIFSSEC_MAY_KRB5; */<br> + cERROR(1, "Krb5 cifs privacy not supported");<br> + return 1;<br> + case Opt_sec_krb5:<br> + vol->secFlg |= CIFSSEC_MAY_KRB5;<br> + break;<br> +#ifdef CONFIG_CIFS_EXPERIMENTAL<br> + case Opt_sec_ntlmsspi:<br> + vol->secFlg |= CIFSSEC_MAY_NTLMSSP | CIFSSEC_MUST_SIGN;<br> + break;<br> + case Opt_sec_ntlmssp:<br> + vol->secFlg |= CIFSSEC_MAY_NTLMSSP;<br> + break;<br> +#endif<br> + case Opt_sec_ntlmv2i:<br> + vol->secFlg |= CIFSSEC_MAY_NTLMV2 | CIFSSEC_MUST_SIGN;<br> + break;<br> + case Opt_sec_ntlmv2:<br> + vol->secFlg |= CIFSSEC_MAY_NTLMV2;<br> + break;<br> + case Opt_sec_ntlmi:<br> + vol->secFlg |= CIFSSEC_MAY_NTLM | CIFSSEC_MUST_SIGN;<br> + break;<br> + case Opt_sec_ntlm:<br> + /* ntlm is default so can be turned off too */<br> + vol->secFlg |= CIFSSEC_MAY_NTLM;<br> + break;<br> + case Opt_sec_nontlm:<br> + /* BB is there a better way to do this? */<br> + vol->secFlg |= CIFSSEC_MAY_NTLMV2;<br> + break;<br> +#ifdef CONFIG_CIFS_WEAK_PW_HASH<br> + case Opt_sec_lanman:<br> + vol->secFlg |= CIFSSEC_MAY_LANMAN;<br> + break;<br> +#endif<br> + case Opt_sec_none:<br> + vol->nullauth = 1;<br> + break;<br> + default:<br> + cERROR(1, "bad security option: %s", value);<br> + return 1;<br> + }<br> + return 0;<br> +}<br> +<br> +static int<br> cifs_parse_mount_options(char *options, const char *devname,<br> struct smb_vol *vol)<br> {<br> @@ -1158,59 +1213,9 @@ cifs_parse_mount_options(char *options, const char *devname,<br> cERROR(1, "no security value specified");<br> continue;<br> }<br> - switch (match_token(value, cifs_sec_options, args)) {<br> - case Opt_sec_krb5i:<br> - vol->secFlg |= CIFSSEC_MAY_KRB5 |<br> - CIFSSEC_MUST_SIGN;<br> - break;<br> - case Opt_sec_krb5p:<br> - /* vol->secFlg |= CIFSSEC_MUST_SEAL |<br> - CIFSSEC_MAY_KRB5; */<br> - cERROR(1, "Krb5 cifs privacy not supported");<br> - return 1;<br> - case Opt_sec_krb5:<br> - vol->secFlg |= CIFSSEC_MAY_KRB5;<br> - break;<br> -#ifdef CONFIG_CIFS_EXPERIMENTAL<br> - case Opt_sec_ntlmsspi:<br> - vol->secFlg |= CIFSSEC_MAY_NTLMSSP |<br> - CIFSSEC_MUST_SIGN;<br> - break;<br> - case Opt_sec_ntlmssp:<br> - vol->secFlg |= CIFSSEC_MAY_NTLMSSP;<br> - break;<br> -#endif<br> - case Opt_sec_ntlmv2i:<br> - vol->secFlg |= CIFSSEC_MAY_NTLMV2 |<br> - CIFSSEC_MUST_SIGN;<br> - break;<br> - case Opt_sec_ntlmv2:<br> - vol->secFlg |= CIFSSEC_MAY_NTLMV2;<br> - break;<br> - case Opt_sec_ntlmi:<br> - vol->secFlg |= CIFSSEC_MAY_NTLM |<br> - CIFSSEC_MUST_SIGN;<br> - break;<br> - case Opt_sec_ntlm:<br> - /* ntlm is default so can be turned off too */<br> - vol->secFlg |= CIFSSEC_MAY_NTLM;<br> - break;<br> - case Opt_sec_nontlm:<br> - /* BB is there a better way to do this? */<br> - vol->secFlg |= CIFSSEC_MAY_NTLMV2;<br> - break;<br> -#ifdef CONFIG_CIFS_WEAK_PW_HASH<br> - case Opt_sec_lanman:<br> - vol->secFlg |= CIFSSEC_MAY_LANMAN;<br> - break;<br> -#endif<br> - case Opt_sec_none:<br> - vol->nullauth = 1;<br> - break;<br> - default:<br> - cERROR(1, "bad security option: %s", value);<br> - return 1;<br> - }<br> + i = cifs_parse_sec_option(value, vol);<br> + if (i)<br> + return i;<br> break;<br> /* unc || target || path */<br> case Opt_unc:<br> -- <br> 1.6.2.5<br> <br> </font></tt> <br> --=_alternative 0051415886257730_=-- --===============1386339554395247742== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-cifs-client mailing list [email protected] https://lists.samba.org/mailman/listinfo/linux-cifs-client --===============1386339554395247742==--