aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2006-06-01 15:20:10 -0400
committerSteve French <sfrench@us.ibm.com>2006-06-01 15:20:10 -0400
commit7c7b25bc8e392aea781324efa771bc191377b876 (patch)
treeddad1a91f948746dbef140994c615253a7f42e65 /fs/cifs/connect.c
parent9c53588ec96d85f82e9bf3fb1af7cca31056e940 (diff)
[CIFS] Support for setting up SMB sessions to legacy lanman servers part 2
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 7ffb8f244f6a..e6f3d2fff6c0 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1990,7 +1990,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1990 1990
1991static int 1991static int
1992CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, 1992CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1993 char session_key[CIFS_SESSION_KEY_SIZE], 1993 char session_key[CIFS_SESS_KEY_SIZE],
1994 const struct nls_table *nls_codepage) 1994 const struct nls_table *nls_codepage)
1995{ 1995{
1996 struct smb_hdr *smb_buffer; 1996 struct smb_hdr *smb_buffer;
@@ -2048,15 +2048,15 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2048 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); 2048 pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
2049 2049
2050 pSMB->req_no_secext.CaseInsensitivePasswordLength = 2050 pSMB->req_no_secext.CaseInsensitivePasswordLength =
2051 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 2051 cpu_to_le16(CIFS_SESS_KEY_SIZE);
2052 2052
2053 pSMB->req_no_secext.CaseSensitivePasswordLength = 2053 pSMB->req_no_secext.CaseSensitivePasswordLength =
2054 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 2054 cpu_to_le16(CIFS_SESS_KEY_SIZE);
2055 bcc_ptr = pByteArea(smb_buffer); 2055 bcc_ptr = pByteArea(smb_buffer);
2056 memcpy(bcc_ptr, (char *) session_key, CIFS_SESSION_KEY_SIZE); 2056 memcpy(bcc_ptr, (char *) session_key, CIFS_SESS_KEY_SIZE);
2057 bcc_ptr += CIFS_SESSION_KEY_SIZE; 2057 bcc_ptr += CIFS_SESS_KEY_SIZE;
2058 memcpy(bcc_ptr, (char *) session_key, CIFS_SESSION_KEY_SIZE); 2058 memcpy(bcc_ptr, (char *) session_key, CIFS_SESS_KEY_SIZE);
2059 bcc_ptr += CIFS_SESSION_KEY_SIZE; 2059 bcc_ptr += CIFS_SESS_KEY_SIZE;
2060 2060
2061 if (ses->capabilities & CAP_UNICODE) { 2061 if (ses->capabilities & CAP_UNICODE) {
2062 if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode */ 2062 if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode */
@@ -3004,14 +3004,14 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3004 SecurityBlob->LmChallengeResponse.Buffer = 0; 3004 SecurityBlob->LmChallengeResponse.Buffer = 0;
3005 3005
3006 SecurityBlob->NtChallengeResponse.Length = 3006 SecurityBlob->NtChallengeResponse.Length =
3007 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 3007 cpu_to_le16(CIFS_SESS_KEY_SIZE);
3008 SecurityBlob->NtChallengeResponse.MaximumLength = 3008 SecurityBlob->NtChallengeResponse.MaximumLength =
3009 cpu_to_le16(CIFS_SESSION_KEY_SIZE); 3009 cpu_to_le16(CIFS_SESS_KEY_SIZE);
3010 memcpy(bcc_ptr, ntlm_session_key, CIFS_SESSION_KEY_SIZE); 3010 memcpy(bcc_ptr, ntlm_session_key, CIFS_SESS_KEY_SIZE);
3011 SecurityBlob->NtChallengeResponse.Buffer = 3011 SecurityBlob->NtChallengeResponse.Buffer =
3012 cpu_to_le32(SecurityBlobLength); 3012 cpu_to_le32(SecurityBlobLength);
3013 SecurityBlobLength += CIFS_SESSION_KEY_SIZE; 3013 SecurityBlobLength += CIFS_SESS_KEY_SIZE;
3014 bcc_ptr += CIFS_SESSION_KEY_SIZE; 3014 bcc_ptr += CIFS_SESS_KEY_SIZE;
3015 3015
3016 if (ses->capabilities & CAP_UNICODE) { 3016 if (ses->capabilities & CAP_UNICODE) {
3017 if (domain == NULL) { 3017 if (domain == NULL) {
@@ -3350,22 +3350,33 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3350 bcc_ptr = &pSMB->Password[0]; 3350 bcc_ptr = &pSMB->Password[0];
3351 if((ses->server->secMode) & SECMODE_USER) { 3351 if((ses->server->secMode) & SECMODE_USER) {
3352 pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ 3352 pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
3353 *bcc_ptr = 0; /* password is null byte */
3353 bcc_ptr++; /* skip password */ 3354 bcc_ptr++; /* skip password */
3355 /* already aligned so no need to do it below */
3354 } else { 3356 } else {
3355 pSMB->PasswordLength = cpu_to_le16(CIFS_SESSION_KEY_SIZE); 3357 pSMB->PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
3356 /* BB FIXME add code to fail this if NTLMv2 or Kerberos 3358 /* BB FIXME add code to fail this if NTLMv2 or Kerberos
3357 specified as required (when that support is added to 3359 specified as required (when that support is added to
3358 the vfs in the future) as only NTLM or the much 3360 the vfs in the future) as only NTLM or the much
3359 weaker LANMAN (which we do not send) is accepted 3361 weaker LANMAN (which we do not send by default) is accepted
3360 by Samba (not sure whether other servers allow 3362 by Samba (not sure whether other servers allow
3361 NTLMv2 password here) */ 3363 NTLMv2 password here) */
3364#ifdef CONFIG_CIFS_WEAK_PW_HASH
3365 if((extended_security & CIFSSEC_MAY_LANMAN) &&
3366 (ses->server->secType == LANMAN))
3367 calc_lanman_hash(ses, bcc_ptr);
3368 else
3369#endif /* CIFS_WEAK_PW_HASH */
3362 SMBNTencrypt(ses->password, 3370 SMBNTencrypt(ses->password,
3363 ses->server->cryptKey, 3371 ses->server->cryptKey,
3364 bcc_ptr); 3372 bcc_ptr);
3365 3373
3366 bcc_ptr += CIFS_SESSION_KEY_SIZE; 3374 bcc_ptr += CIFS_SESS_KEY_SIZE;
3367 *bcc_ptr = 0; 3375 if(ses->capabilities & CAP_UNICODE) {
3368 bcc_ptr++; /* align */ 3376 /* must align unicode strings */
3377 *bcc_ptr = 0; /* null byte password */
3378 bcc_ptr++;
3379 }
3369 } 3380 }
3370 3381
3371 if(ses->server->secMode & 3382 if(ses->server->secMode &
@@ -3507,7 +3518,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3507 struct nls_table * nls_info) 3518 struct nls_table * nls_info)
3508{ 3519{
3509 int rc = 0; 3520 int rc = 0;
3510 char ntlm_session_key[CIFS_SESSION_KEY_SIZE]; 3521 char ntlm_session_key[CIFS_SESS_KEY_SIZE];
3511 int ntlmv2_flag = FALSE; 3522 int ntlmv2_flag = FALSE;
3512 int first_time = 0; 3523 int first_time = 0;
3513 3524