Changeset 920 for trunk/server/source3/libsmb/ntlmssp.c
- Timestamp:
- Jun 9, 2016, 2:23:12 PM (9 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 919
- Property svn:mergeinfo changed
-
trunk/server/source3/libsmb/ntlmssp.c
r918 r920 163 163 } 164 164 165 bool ntlmssp_have_feature(struct ntlmssp_state *ntlmssp_state, 166 uint32_t feature) 167 { 168 if (feature & NTLMSSP_FEATURE_SIGN) { 169 if (ntlmssp_state->session_key.length == 0) { 170 return false; 171 } 172 if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN) { 173 return true; 174 } 175 } 176 177 if (feature & NTLMSSP_FEATURE_SEAL) { 178 if (ntlmssp_state->session_key.length == 0) { 179 return false; 180 } 181 if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL) { 182 return true; 183 } 184 } 185 186 if (feature & NTLMSSP_FEATURE_SESSION_KEY) { 187 if (ntlmssp_state->session_key.length > 0) { 188 return true; 189 } 190 } 191 192 return false; 193 } 194 165 195 /** 166 196 * Request features for the NTLMSSP negotiation … … 177 207 */ 178 208 if (in_list("NTLMSSP_FEATURE_SESSION_KEY", feature_list, True)) { 179 ntlmssp_state-> neg_flags |= NTLMSSP_NEGOTIATE_SIGN;209 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; 180 210 } 181 211 if (in_list("NTLMSSP_FEATURE_SIGN", feature_list, True)) { 182 ntlmssp_state-> neg_flags |= NTLMSSP_NEGOTIATE_SIGN;212 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; 183 213 } 184 214 if(in_list("NTLMSSP_FEATURE_SEAL", feature_list, True)) { 185 ntlmssp_state-> neg_flags |= NTLMSSP_NEGOTIATE_SEAL;215 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SEAL; 186 216 } 187 217 if (in_list("NTLMSSP_FEATURE_CCACHE", feature_list, true)) { 188 218 ntlmssp_state->use_ccache = true; 189 219 } 220 221 ntlmssp_state->neg_flags |= ntlmssp_state->required_flags; 190 222 } 191 223 … … 200 232 /* As per JRA's comment above */ 201 233 if (feature & NTLMSSP_FEATURE_SESSION_KEY) { 202 ntlmssp_state-> neg_flags |= NTLMSSP_NEGOTIATE_SIGN;234 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; 203 235 } 204 236 if (feature & NTLMSSP_FEATURE_SIGN) { 205 ntlmssp_state-> neg_flags |= NTLMSSP_NEGOTIATE_SIGN;237 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; 206 238 } 207 239 if (feature & NTLMSSP_FEATURE_SEAL) { 208 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL; 240 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; 241 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SEAL; 209 242 } 210 243 if (feature & NTLMSSP_FEATURE_CCACHE) { 211 244 ntlmssp_state->use_ccache = true; 212 245 } 246 247 ntlmssp_state->neg_flags |= ntlmssp_state->required_flags; 213 248 } 214 249 … … 388 423 389 424 if (ntlmssp_state->use_ntlmv2) { 390 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_NTLM2; 425 ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_NTLM2; 426 ntlmssp_state->allow_lm_key = false; 427 } 428 429 if (ntlmssp_state->allow_lm_key) { 430 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_LM_KEY; 391 431 } 392 432 … … 421 461 422 462 return NT_STATUS_MORE_PROCESSING_REQUIRED; 463 } 464 465 static NTSTATUS ntlmssp3_handle_neg_flags(struct ntlmssp_state *ntlmssp_state, 466 uint32_t flags) 467 { 468 uint32_t missing_flags = ntlmssp_state->required_flags; 469 470 if (flags & NTLMSSP_NEGOTIATE_UNICODE) { 471 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE; 472 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_OEM; 473 ntlmssp_state->unicode = true; 474 } else { 475 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_UNICODE; 476 ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_OEM; 477 ntlmssp_state->unicode = false; 478 } 479 480 /* 481 * NTLMSSP_NEGOTIATE_NTLM2 (NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY) 482 * has priority over NTLMSSP_NEGOTIATE_LM_KEY 483 */ 484 if (!(flags & NTLMSSP_NEGOTIATE_NTLM2)) { 485 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_NTLM2; 486 } 487 488 if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) { 489 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_LM_KEY; 490 } 491 492 if (!(flags & NTLMSSP_NEGOTIATE_LM_KEY)) { 493 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_LM_KEY; 494 } 495 496 if (!(flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) { 497 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_ALWAYS_SIGN; 498 } 499 500 if (!(flags & NTLMSSP_NEGOTIATE_128)) { 501 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_128; 502 } 503 504 if (!(flags & NTLMSSP_NEGOTIATE_56)) { 505 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_56; 506 } 507 508 if (!(flags & NTLMSSP_NEGOTIATE_KEY_EXCH)) { 509 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_KEY_EXCH; 510 } 511 512 if (!(flags & NTLMSSP_NEGOTIATE_SIGN)) { 513 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SIGN; 514 } 515 516 if (!(flags & NTLMSSP_NEGOTIATE_SEAL)) { 517 ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SEAL; 518 } 519 520 if ((flags & NTLMSSP_REQUEST_TARGET)) { 521 ntlmssp_state->neg_flags |= NTLMSSP_REQUEST_TARGET; 522 } 523 524 missing_flags &= ~ntlmssp_state->neg_flags; 525 if (missing_flags != 0) { 526 NTSTATUS status = NT_STATUS_RPC_SEC_PKG_ERROR; 527 DEBUG(1, ("%s: Got challenge flags[0x%08x] " 528 "- possible downgrade detected! " 529 "missing_flags[0x%08x] - %s\n", 530 __func__, 531 (unsigned)flags, 532 (unsigned)missing_flags, 533 nt_errstr(status))); 534 debug_ntlmssp_flags(missing_flags); 535 DEBUGADD(4, ("neg_flags[0x%08x]\n", 536 (unsigned)ntlmssp_state->neg_flags)); 537 debug_ntlmssp_flags(ntlmssp_state->neg_flags); 538 539 return status; 540 } 541 542 return NT_STATUS_OK; 423 543 } 424 544 … … 449 569 NTSTATUS nt_status = NT_STATUS_OK; 450 570 571 if (!msrpc_parse(ntlmssp_state, &reply, "CdBd", 572 "NTLMSSP", 573 &ntlmssp_command, 574 &server_domain_blob, 575 &chal_flags)) { 576 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n")); 577 dump_data(2, reply.data, reply.length); 578 579 return NT_STATUS_INVALID_PARAMETER; 580 } 581 data_blob_free(&server_domain_blob); 582 583 DEBUG(3, ("Got challenge flags:\n")); 584 debug_ntlmssp_flags(chal_flags); 585 586 nt_status = ntlmssp3_handle_neg_flags(ntlmssp_state, chal_flags); 587 if (!NT_STATUS_IS_OK(nt_status)) { 588 return nt_status; 589 } 590 451 591 if (ntlmssp_state->use_ccache) { 452 592 struct wbcCredentialCacheParams params; … … 498 638 499 639 noccache: 500 501 if (!msrpc_parse(ntlmssp_state, &reply, "CdBd",502 "NTLMSSP",503 &ntlmssp_command,504 &server_domain_blob,505 &chal_flags)) {506 DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n"));507 dump_data(2, reply.data, reply.length);508 509 return NT_STATUS_INVALID_PARAMETER;510 }511 640 512 641 if (DEBUGLEVEL >= 10) { … … 525 654 } 526 655 } 527 528 data_blob_free(&server_domain_blob);529 530 DEBUG(3, ("Got challenge flags:\n"));531 debug_ntlmssp_flags(chal_flags);532 533 ntlmssp_handle_neg_flags(ntlmssp_state, chal_flags, lp_client_lanman_auth());534 656 535 657 if (ntlmssp_state->unicode) { … … 770 892 771 893 ntlmssp_state->use_ntlmv2 = use_ntlmv2; 894 ntlmssp_state->allow_lm_key = lp_client_lanman_auth(); 772 895 773 896 ntlmssp_state->expected_state = NTLMSSP_INITIAL; … … 781 904 NTLMSSP_REQUEST_TARGET; 782 905 906 if (ntlmssp_state->use_ntlmv2) { 907 ntlmssp_state->allow_lm_key = false; 908 } 909 783 910 ntlmssp_state->client.netbios_name = talloc_strdup(ntlmssp_state, netbios_name); 784 911 if (!ntlmssp_state->client.netbios_name) {
Note:
See TracChangeset
for help on using the changeset viewer.