Changeset 740 for vendor/current/source3/libsmb/dsgetdcname.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/libsmb/dsgetdcname.c
r414 r740 22 22 23 23 #include "includes.h" 24 25 #define DSGETDCNAME_FMT "DSGETDCNAME/DOMAIN/%s" 24 #include "libads/sitename_cache.h" 25 #include "../librpc/gen_ndr/ndr_netlogon.h" 26 #include "libads/cldap.h" 27 #include "libads/dns.h" 28 #include "libsmb/clidgram.h" 29 26 30 /* 15 minutes */ 27 31 #define DSGETDCNAME_CACHE_TTL 60*15 … … 123 127 } 124 128 125 return talloc_asprintf_strupper_m(mem_ctx, DSGETDCNAME_FMT, domain); 129 return talloc_asprintf_strupper_m(mem_ctx, "DSGETDCNAME/DOMAIN/%s", 130 domain); 126 131 } 127 132 … … 190 195 r->sockaddr.pdc_ip = talloc_strdup(mem_ctx, addr); 191 196 192 ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL,r,197 ndr_err = ndr_push_struct_blob(&blob, mem_ctx, r, 193 198 (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX); 194 199 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 196 201 } 197 202 198 if (r->domain ) {199 status = dsgetdcname_cache_store(mem_ctx, r->domain , &blob);203 if (r->domain_name) { 204 status = dsgetdcname_cache_store(mem_ctx, r->domain_name, &blob); 200 205 if (!NT_STATUS_IS_OK(status)) { 201 206 goto done; 202 207 } 203 208 if (r->client_site) { 204 sitename_store(r->domain , r->client_site);209 sitename_store(r->domain_name, r->client_site); 205 210 } 206 211 } … … 341 346 } 342 347 343 ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL,&r,348 ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, 344 349 (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX); 345 350 … … 497 502 dclist = TALLOC_ZERO_ARRAY(mem_ctx, struct ip_service_name, count); 498 503 if (!dclist) { 504 SAFE_FREE(iplist); 499 505 return NT_STATUS_NO_MEMORY; 500 506 } … … 512 518 r->hostname = talloc_strdup(mem_ctx, addr); 513 519 if (!r->hostname) { 520 SAFE_FREE(iplist); 514 521 return NT_STATUS_NO_MEMORY; 515 522 } … … 519 526 *returned_dclist = dclist; 520 527 *returned_count = count; 528 SAFE_FREE(iplist); 521 529 522 530 return NT_STATUS_OK; … … 622 630 * anything about the DC's -- jerry */ 623 631 624 if (!is_zero_addr( (struct sockaddr *)(void *)&r->ss)) {632 if (!is_zero_addr(&r->ss)) { 625 633 count++; 626 634 continue; … … 687 695 info->forest_name = talloc_strdup(mem_ctx, forest_name); 688 696 NT_STATUS_HAVE_NO_MEMORY(info->forest_name); 689 flags |= DS_DNS_FOREST ;697 flags |= DS_DNS_FOREST_ROOT; 690 698 } 691 699 … … 783 791 map_dc_and_domain_names(flags, 784 792 r->pdc_name, 785 r->domain ,793 r->domain_name, 786 794 r->pdc_dns_name, 787 795 r->dns_domain, … … 892 900 /**************************************************************** 893 901 ****************************************************************/ 894 895 static struct event_context *ev_context(void)896 {897 static struct event_context *ctx;898 899 if (!ctx && !(ctx = event_context_init(NULL))) {900 smb_panic("Could not init event context");901 }902 return ctx;903 }904 905 /****************************************************************906 ****************************************************************/907 908 static struct messaging_context *msg_context(TALLOC_CTX *mem_ctx)909 {910 static struct messaging_context *ctx;911 912 if (!ctx && !(ctx = messaging_init(mem_ctx, server_id_self(),913 ev_context()))) {914 smb_panic("Could not init messaging context");915 }916 return ctx;917 }918 902 919 903 /**************************************************************** … … 941 925 NETLOGON_NT_VERSION_5EX_WITH_IP; 942 926 943 if ( !msg_ctx) {944 msg_ctx = msg_context(mem_ctx);927 if (msg_ctx == NULL) { 928 return NT_STATUS_INVALID_PARAMETER; 945 929 } 946 930 … … 954 938 955 939 for (i=0; i<num_dcs; i++) { 940 uint16_t val; 941 int dgm_id; 942 943 generate_random_buffer((uint8_t *)&val, 2); 944 dgm_id = val; 956 945 957 946 ip_list.ss = dclist[i].ss; … … 962 951 } 963 952 964 if (send_getdc_request(mem_ctx, msg_ctx, 965 &dclist[i].ss, domain_name, 966 NULL, nt_version)) 967 { 968 int k; 969 smb_msleep(300); 970 for (k=0; k<5; k++) { 971 if (receive_getdc_response(mem_ctx, 972 &dclist[i].ss, 973 domain_name, 974 &nt_version, 975 &dc_name, 976 &r)) { 977 store_cache = true; 978 namecache_store(dc_name, NBT_NAME_SERVER, 1, &ip_list); 979 goto make_reply; 980 } 981 smb_msleep(1500); 982 } 953 status = nbt_getdc(msg_ctx, &dclist[i].ss, domain_name, 954 NULL, nt_version, 955 mem_ctx, &nt_version, &dc_name, &r); 956 if (NT_STATUS_IS_OK(status)) { 957 store_cache = true; 958 namecache_store(dc_name, NBT_NAME_SERVER, 1, &ip_list); 959 goto make_reply; 983 960 } 984 961 … … 999 976 1000 977 logon1.nt_version = nt_version; 1001 logon1. server= tmp_dc_name;1002 logon1.domain = talloc_strdup_upper(mem_ctx, domain_name);1003 NT_STATUS_HAVE_NO_MEMORY(logon1.domain );978 logon1.pdc_name = tmp_dc_name; 979 logon1.domain_name = talloc_strdup_upper(mem_ctx, domain_name); 980 NT_STATUS_HAVE_NO_MEMORY(logon1.domain_name); 1004 981 1005 982 r->data.nt4 = logon1;
Note:
See TracChangeset
for help on using the changeset viewer.