From patchwork Thu May 23 15:05:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2607521 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 10606DFF68 for ; Thu, 23 May 2013 15:06:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758797Ab3EWPGW (ORCPT ); Thu, 23 May 2013 11:06:22 -0400 Received: from mail-qc0-f182.google.com ([209.85.216.182]:48797 "EHLO mail-qc0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759358Ab3EWPGV (ORCPT ); Thu, 23 May 2013 11:06:21 -0400 Received: by mail-qc0-f182.google.com with SMTP id n1so1817100qcw.13 for ; Thu, 23 May 2013 08:06:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=wc5wXGNhcDLZuCriTgWEQVZUssg6+UnwhLQdX7if5lw=; b=ZVyn77oToyMpG8JsSNmqmU/AnScCZdt48Qly96x/GTqitn1mXHd7gtACnzeRUi6/PA aTp+RRXoI2dTusGZCRR59dL5jlgvimYBIZXpuZWbo7HtrK9TXX8YgPUdsx6/ikdt0Aff szHpk22Vj/hKW5D3os9Me9mvQcfLypSZmQP8UPUta8Kfd53xwjDQsYCfOZgd/t6V6OaY 5GH1BIC6CD4SRiNJE3/5VyzTp1kq47tLMrIBmxpmmTVTtWQQoEIzi6tKP/KEsqEA7XIB nRtewvr08ZzDv57i/35NLtJ6HQ/hlVM6rMRNNggbSlcv+MOv8YvNaY/U3f/V2/etOYc2 +F/w== X-Received: by 10.224.79.138 with SMTP id p10mr12195836qak.13.1369321580380; Thu, 23 May 2013 08:06:20 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPSA id y1sm12688520qad.5.2013.05.23.08.06.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 23 May 2013 08:06:19 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, idra@samba.org Subject: [PATCH 10/19] cifs: factor out check for extended security bit into separate function Date: Thu, 23 May 2013 11:05:54 -0400 Message-Id: <1369321563-16893-11-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1369321563-16893-1-git-send-email-jlayton@redhat.com> References: <1369321563-16893-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQmszPmtlGFF5pqkcEAEVIJUIFPG/ikkEBTV1N1UjaSFd9znU7nph3B+VGsqCe9SVIa1WrrK Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Signed-off-by: Jeff Layton Reviewed-by: Pavel Shilovsky --- fs/cifs/cifssmb.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 5b191f7..e7184b9 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -539,6 +539,20 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, NEGOTIATE_RSP *pSMBr, } #endif +static bool +should_set_ext_sec_flag(unsigned int secFlags) +{ + if ((secFlags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5) + return true; + else if ((secFlags & CIFSSEC_AUTH_MASK) == CIFSSEC_MAY_KRB5) + return true; + else if ((secFlags & CIFSSEC_MUST_NTLMSSP) == CIFSSEC_MUST_NTLMSSP) + return true; + else if ((secFlags & CIFSSEC_AUTH_MASK) == CIFSSEC_MAY_NTLMSSP) + return true; + return false; +} + int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses) { @@ -572,15 +586,8 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses) pSMB->hdr.Mid = get_next_mid(server); pSMB->hdr.Flags2 |= (SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS); - if ((secFlags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5) - pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; - else if ((secFlags & CIFSSEC_AUTH_MASK) == CIFSSEC_MAY_KRB5) { - cifs_dbg(FYI, "Kerberos only mechanism, enable extended security\n"); - pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; - } else if ((secFlags & CIFSSEC_MUST_NTLMSSP) == CIFSSEC_MUST_NTLMSSP) - pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; - else if ((secFlags & CIFSSEC_AUTH_MASK) == CIFSSEC_MAY_NTLMSSP) { - cifs_dbg(FYI, "NTLMSSP only mechanism, enable extended security\n"); + if (should_set_ext_sec_flag(secFlags)) { + cifs_dbg(FYI, "Requesting extended security."); pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; }