Changeset 745 for trunk/server/source3/rpc_client/cli_netlogon.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
source3/rpc_client/cli_netlogon.c (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/rpc_client/cli_netlogon.c
r596 r745 22 22 23 23 #include "includes.h" 24 24 25 #include "../libcli/auth/libcli_auth.h" 25 #include "../librpc/gen_ndr/cli_netlogon.h" 26 #include "../librpc/gen_ndr/ndr_netlogon_c.h" 27 #include "rpc_client/cli_netlogon.h" 28 #include "rpc_client/init_netlogon.h" 29 #include "rpc_client/util_netlogon.h" 30 #include "../libcli/security/security.h" 26 31 27 32 /**************************************************************************** … … 40 45 uint32_t *neg_flags_inout) 41 46 { 47 42 48 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 43 49 struct netr_Credential clnt_chal_send; … … 47 53 fstring mach_acct; 48 54 uint32_t neg_flags = *neg_flags_inout; 55 49 56 50 57 if (!ndr_syntax_id_equal(&cli->abstract_syntax, … … 65 72 66 73 /* Get the server challenge. */ 67 result = rpccli_netr_ServerReqChallenge(cli, talloc_tos(),74 , talloc_tos(), 68 75 cli->srv_name_slash, 69 76 clnt_name, 70 77 &clnt_chal_send, 71 &srv_chal_recv); 78 &srv_chal_recv, 79 &result); 80 if (!NT_STATUS_IS_OK(status)) { 81 return status; 82 } 72 83 if (!NT_STATUS_IS_OK(result)) { 73 84 return result; … … 75 86 76 87 /* Calculate the session key and client credentials */ 77 88 78 89 cli->dc = netlogon_creds_client_init(cli, 79 90 mach_acct, … … 93 104 */ 94 105 95 result = rpccli_netr_ServerAuthenticate2(cli, talloc_tos(),106 , talloc_tos(), 96 107 cli->srv_name_slash, 97 108 cli->dc->account_name, … … 100 111 &clnt_chal_send, /* input. */ 101 112 &srv_chal_recv, /* output. */ 102 &neg_flags); 103 113 &neg_flags, 114 &result); 115 if (!NT_STATUS_IS_OK(status)) { 116 return status; 117 } 104 118 /* we might be talking to NT4, so let's downgrade in that case and retry 105 119 * with the returned neg_flags - gd */ … … 149 163 const char *password, 150 164 const char *workstation, 165 151 166 int logon_type) 152 167 { 153 168 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 169 154 170 struct netr_Authenticator clnt_creds; 155 171 struct netr_Authenticator ret_creds; … … 157 173 union netr_Validation validation; 158 174 uint8_t authoritative; 159 int validation_level = 3;160 175 fstring clnt_name_slash; 161 uint8 zeros[16];176 ; 162 177 163 178 ZERO_STRUCT(ret_creds); 164 ZERO_STRUCT(zeros);165 179 166 180 logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); … … 264 278 } 265 279 266 result = rpccli_netr_LogonSamLogon(cli, mem_ctx,280 , mem_ctx, 267 281 cli->srv_name_slash, 268 282 global_myname(), … … 273 287 validation_level, 274 288 &validation, 275 &authoritative); 289 &authoritative, 290 &result); 291 if (!NT_STATUS_IS_OK(status)) { 292 return status; 293 } 276 294 277 295 /* Always check returned credentials */ … … 282 300 283 301 return result; 284 }285 286 #define COPY_LSA_STRING(mem_ctx, in, out, name) do { \287 if (in->name.string) { \288 out->name.string = talloc_strdup(mem_ctx, in->name.string); \289 NT_STATUS_HAVE_NO_MEMORY(out->name.string); \290 } \291 } while (0)292 293 static NTSTATUS copy_netr_SamBaseInfo(TALLOC_CTX *mem_ctx,294 const struct netr_SamBaseInfo *in,295 struct netr_SamBaseInfo *out)296 {297 /* first copy all, then realloc pointers */298 *out = *in;299 300 COPY_LSA_STRING(mem_ctx, in, out, account_name);301 COPY_LSA_STRING(mem_ctx, in, out, full_name);302 COPY_LSA_STRING(mem_ctx, in, out, logon_script);303 COPY_LSA_STRING(mem_ctx, in, out, profile_path);304 COPY_LSA_STRING(mem_ctx, in, out, home_directory);305 COPY_LSA_STRING(mem_ctx, in, out, home_drive);306 307 if (in->groups.count) {308 out->groups.rids = (struct samr_RidWithAttribute *)309 talloc_memdup(mem_ctx, in->groups.rids,310 (sizeof(struct samr_RidWithAttribute) *311 in->groups.count));312 NT_STATUS_HAVE_NO_MEMORY(out->groups.rids);313 }314 315 COPY_LSA_STRING(mem_ctx, in, out, logon_server);316 COPY_LSA_STRING(mem_ctx, in, out, domain);317 318 if (in->domain_sid) {319 out->domain_sid = sid_dup_talloc(mem_ctx, in->domain_sid);320 NT_STATUS_HAVE_NO_MEMORY(out->domain_sid);321 }322 323 return NT_STATUS_OK;324 302 } 325 303 … … 391 369 { 392 370 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 371 393 372 const char *workstation_name_slash; 394 373 const char *server_name_slash; 395 uint8 zeros[16];396 374 struct netr_Authenticator clnt_creds; 397 375 struct netr_Authenticator ret_creds; … … 402 380 struct netr_ChallengeResponse lm; 403 381 struct netr_ChallengeResponse nt; 382 404 383 405 384 *info3 = NULL; 406 385 407 ZERO_STRUCT(zeros);408 386 ZERO_STRUCT(ret_creds); 409 387 … … 462 440 /* Marshall data and send request */ 463 441 464 result = rpccli_netr_LogonSamLogon(cli, mem_ctx,442 , mem_ctx, 465 443 server_name_slash, 466 444 global_myname(), … … 471 449 validation_level, 472 450 &validation, 473 &authoritative); 474 if (!NT_STATUS_IS_OK(result)) { 475 return result; 451 &authoritative, 452 &result); 453 if (!NT_STATUS_IS_OK(status)) { 454 return status; 476 455 } 477 456 … … 480 459 DEBUG(0,("rpccli_netlogon_sam_network_logon: credentials chain check failed\n")); 481 460 return NT_STATUS_ACCESS_DENIED; 461 462 463 464 482 465 } 483 466 … … 506 489 { 507 490 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 491 508 492 const char *workstation_name_slash; 509 493 const char *server_name_slash; 510 uint8 zeros[16];511 494 union netr_LogonLevel *logon = NULL; 512 495 struct netr_NetworkInfo *network_info; … … 516 499 struct netr_ChallengeResponse nt; 517 500 uint32_t flags = 0; 501 518 502 519 503 *info3 = NULL; 520 521 ZERO_STRUCT(zeros);522 504 523 505 ZERO_STRUCT(lm); … … 573 555 /* Marshall data and send request */ 574 556 575 result = rpccli_netr_LogonSamLogonEx(cli, mem_ctx,557 , mem_ctx, 576 558 server_name_slash, 577 559 global_myname(), … … 581 563 &validation, 582 564 &authoritative, 583 &flags); 565 &flags, 566 &result); 567 if (!NT_STATUS_IS_OK(status)) { 568 return status; 569 } 570 584 571 if (!NT_STATUS_IS_OK(result)) { 585 572 return result; … … 613 600 enum netr_SchannelType sec_channel_type) 614 601 { 615 NTSTATUS result ;602 NTSTATUS result; 616 603 struct netr_Authenticator clnt_creds, srv_cred; 604 617 605 618 606 if (!cli->dc) { … … 643 631 &new_password); 644 632 645 result = rpccli_netr_ServerPasswordSet2(cli, mem_ctx,633 , mem_ctx, 646 634 cli->srv_name_slash, 647 635 cli->dc->account_name, … … 650 638 &clnt_creds, 651 639 &srv_cred, 652 &new_password); 653 if (!NT_STATUS_IS_OK(result)) { 654 DEBUG(0,("rpccli_netr_ServerPasswordSet2 failed: %s\n", 655 nt_errstr(result))); 656 return result; 640 &new_password, 641 &result); 642 if (!NT_STATUS_IS_OK(status)) { 643 DEBUG(0,("dcerpc_netr_ServerPasswordSet2 failed: %s\n", 644 nt_errstr(status))); 645 return status; 657 646 } 658 647 } else { … … 662 651 netlogon_creds_des_encrypt(cli->dc, &new_password); 663 652 664 result = rpccli_netr_ServerPasswordSet(cli, mem_ctx,653 , mem_ctx, 665 654 cli->srv_name_slash, 666 655 cli->dc->account_name, … … 669 658 &clnt_creds, 670 659 &srv_cred, 671 &new_password); 672 if (!NT_STATUS_IS_OK(result)) { 673 DEBUG(0,("rpccli_netr_ServerPasswordSet failed: %s\n", 674 nt_errstr(result))); 675 return result; 660 &new_password, 661 &result); 662 if (!NT_STATUS_IS_OK(status)) { 663 DEBUG(0,("dcerpc_netr_ServerPasswordSet failed: %s\n", 664 nt_errstr(status))); 665 return status; 676 666 } 677 667 } … … 683 673 } 684 674 675 676 677 678 679 680 685 681 return result; 686 682 }
Note:
See TracChangeset
for help on using the changeset viewer.
