From patchwork Thu May 27 00:45:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Lovenberg X-Patchwork-Id: 102543 Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4R0jgY7026999 for ; Thu, 27 May 2010 00:46:17 GMT Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 157064658A; Wed, 26 May 2010 18:45:44 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.8 tests=AWL, BAYES_00, NO_MORE_FUNN, SPF_PASS autolearn=no version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mail-qy0-f200.google.com (mail-qy0-f200.google.com [209.85.221.200]) by lists.samba.org (Postfix) with ESMTP id F3D24AD320 for ; Wed, 26 May 2010 18:45:38 -0600 (MDT) Received: by qyk38 with SMTP id 38so867717qyk.17 for ; Wed, 26 May 2010 17:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:content-type :content-transfer-encoding; bh=9QozvgrhjZ9s+M/mDjJjWAqSCsHPZYkFjMmBc6auqe4=; b=nRIceOBkNGV954QFAR8/taqHX3rm3IwHCK5RvNV6r22mEylNDbx/EXdIcTmLcCUeMC dV16sXR5JCJBjtg/K1WrNPjz3vuDHJk/scHFuhA1dM/hiKiadxAgsAhlaKEVp4+kv4Dx QePIY1W13K58SJvmEEsGJwE2OgCLa0G6mGoX4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :content-type:content-transfer-encoding; b=XaL9+SxPQgMRnFBnzIL3/tZCrvoY/tCEw60pvfJfwSqCMCXvL3QPnK6c5qk9aT85Yn 7xjaL2tE1GL7x/YluIgoWANaY0XVfKkClhDoJqf/z0vhBHofCXGCfoULTv3Fz3zNjXDn zZt4hWxjDcBxbgHD0ynGGhnD7yHqd7J2dcISk= Received: by 10.224.72.32 with SMTP id k32mr5317458qaj.167.1274921136126; Wed, 26 May 2010 17:45:36 -0700 (PDT) Received: from localhost.localdomain (24.115.161.116.res-cmts.flt.ptd.net [24.115.161.116]) by mx.google.com with ESMTPS id 23sm362876qyk.15.2010.05.26.17.45.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 26 May 2010 17:45:35 -0700 (PDT) From: Scott Lovenberg To: linux-cifs-client@lists.samba.org Date: Wed, 26 May 2010 20:45:32 -0400 Message-Id: <1274921132-21335-1-git-send-email-scott.lovenberg@gmail.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: References: Cc: jlayton@samba.org Subject: [linux-cifs-client] [PATCH] cifs: move security option parsing to own function X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 27 May 2010 00:46:18 +0000 (UTC) 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: