Changeset 988 for vendor/current/source3/libsmb/dsgetdcname.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/libsmb/dsgetdcname.c
r860 r988 25 25 #include "../librpc/gen_ndr/ndr_netlogon.h" 26 26 #include "libads/cldap.h" 27 #include " libads/dns.h"27 #include "../lib/addns/dnsquery.h" 28 28 #include "libsmb/clidgram.h" 29 29 … … 33 33 struct ip_service_name { 34 34 struct sockaddr_storage ss; 35 unsigned port;36 35 const char *hostname; 37 36 }; … … 46 45 ****************************************************************/ 47 46 48 void debug_dsdcinfo_flags(int lvl, uint32_t flags)47 static void debug_dsdcinfo_flags(int lvl, uint32_t flags) 49 48 { 50 49 DEBUG(lvl,("debug_dsdcinfo_flags: 0x%08x\n\t", flags)); … … 286 285 uint32_t req_flags) 287 286 { 288 if (re t_flags == 0) {287 if (req_flags == 0) { 289 288 return true; 290 289 } … … 336 335 } 337 336 338 if (!gencache_get_data_blob(key, &blob, NULL, NULL)) {337 if (!gencache_get_data_blob(key, NULL, &blob, NULL, NULL)) { 339 338 return NT_STATUS_NOT_FOUND; 340 339 } 341 340 342 info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo);341 info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo); 343 342 if (!info) { 343 data_blob_free(&blob); 344 344 return NT_STATUS_NO_MEMORY; 345 345 } … … 479 479 struct ip_service_name *dclist = NULL; 480 480 int count; 481 static const char *resolve_order[] = { "lmhosts", "wins", "bcast", NULL }; 481 482 482 483 *returned_dclist = NULL; 483 484 *returned_count = 0; 484 485 485 if (lp_disable_netbios()) {486 return NT_STATUS_NOT_SUPPORTED;487 }488 489 486 if (flags & DS_PDC_REQUIRED) { 490 487 name_type = NBT_NAME_PDC; … … 493 490 status = internal_resolve_name(domain_name, name_type, NULL, 494 491 &iplist, &count, 495 "lmhosts wins bcast");492 resolve_order); 496 493 if (!NT_STATUS_IS_OK(status)) { 497 494 DEBUG(10,("discover_dc_netbios: failed to find DC\n")); … … 499 496 } 500 497 501 dclist = TALLOC_ZERO_ARRAY(mem_ctx, struct ip_service_name, count);498 dclist = talloc_zero_array(mem_ctx, struct ip_service_name, count); 502 499 if (!dclist) { 503 500 SAFE_FREE(iplist); … … 514 511 515 512 r->ss = iplist[i].ss; 516 r->port = iplist[i].port;517 513 r->hostname = talloc_strdup(mem_ctx, addr); 518 514 if (!r->hostname) { … … 550 546 551 547 if (flags & DS_PDC_REQUIRED) { 552 status = ads_dns_query_pdc(mem_ctx, domain_name, 553 &dcs, &numdcs); 548 status = ads_dns_query_pdc(mem_ctx, 549 domain_name, 550 &dcs, 551 &numdcs); 554 552 } else if (flags & DS_GC_SERVER_REQUIRED) { 555 status = ads_dns_query_gcs(mem_ctx, domain_name, site_name, 556 &dcs, &numdcs); 553 status = ads_dns_query_gcs(mem_ctx, 554 domain_name, 555 site_name, 556 &dcs, 557 &numdcs); 557 558 } else if (flags & DS_KDC_REQUIRED) { 558 status = ads_dns_query_kdcs(mem_ctx, domain_name, site_name, 559 &dcs, &numdcs); 559 status = ads_dns_query_kdcs(mem_ctx, 560 domain_name, 561 site_name, 562 &dcs, 563 &numdcs); 560 564 } else if (flags & DS_DIRECTORY_SERVICE_REQUIRED) { 561 status = ads_dns_query_dcs(mem_ctx, domain_name, site_name, 562 &dcs, &numdcs); 565 status = ads_dns_query_dcs(mem_ctx, 566 domain_name, 567 site_name, 568 &dcs, 569 &numdcs); 563 570 } else if (domain_guid) { 564 status = ads_dns_query_dcs_guid(mem_ctx, domain_name, 565 domain_guid, &dcs, &numdcs); 571 struct GUID_txt_buf buf; 572 GUID_buf_string(domain_guid, &buf); 573 574 status = ads_dns_query_dcs_guid(mem_ctx, 575 domain_name, 576 buf.buf, 577 &dcs, 578 &numdcs); 566 579 } else { 567 status = ads_dns_query_dcs(mem_ctx, domain_name, site_name, 568 &dcs, &numdcs); 580 status = ads_dns_query_dcs(mem_ctx, 581 domain_name, 582 site_name, 583 &dcs, 584 &numdcs); 569 585 } 570 586 … … 581 597 } 582 598 583 dclist = TALLOC_ZERO_ARRAY(mem_ctx,599 dclist = talloc_zero_array(mem_ctx, 584 600 struct ip_service_name, 585 601 numaddrs); … … 598 614 struct ip_service_name *r = &dclist[count]; 599 615 600 r->port = dcs[i].port;601 616 r->hostname = dcs[i].hostname; 602 617 … … 609 624 j = 0; 610 625 } else { 611 /* use the IP addresses from the SRV sresponse */626 /* use the IP addresses from the SRV response */ 612 627 613 628 if (j >= dcs[i].num_ips) { … … 623 638 /* make sure it is a valid IP. I considered checking the 624 639 * negative connection cache, but this is the wrong place for 625 * it. Maybe only as a hac .After think about it, if all of626 * the IP addresses retu end from DNS are dead, what hope does a640 * it. Maybe only as a hack. After think about it, if all of 641 * the IP addresses returned from DNS are dead, what hope does a 627 642 * netbios name lookup have? The standard reason for falling 628 643 * back to netbios lookups is that our DNS server doesn't know … … 662 677 struct netr_DsRGetDCNameInfo *info; 663 678 664 info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo);679 info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo); 665 680 NT_STATUS_HAVE_NO_MEMORY(info); 666 681 … … 778 793 dc_address = addr; 779 794 dc_address_type = DS_ADDRESS_TYPE_INET; 780 }781 782 if (!ss && r->sockaddr.pdc_ip) {783 dc_address = r->sockaddr.pdc_ip;784 dc_address_type = DS_ADDRESS_TYPE_INET;785 795 } else { 786 dc_address = r->pdc_name; 787 dc_address_type = DS_ADDRESS_TYPE_NETBIOS; 796 if (r->sockaddr.pdc_ip) { 797 dc_address = r->sockaddr.pdc_ip; 798 dc_address_type = DS_ADDRESS_TYPE_INET; 799 } else { 800 dc_address = r->pdc_name; 801 dc_address_type = DS_ADDRESS_TYPE_NETBIOS; 802 } 788 803 } 789 804 … … 864 879 for (i=0; i<num_dcs; i++) { 865 880 866 DEBUG(10,("LDAP ping to %s\n", dclist[i].hostname)); 867 868 if (ads_cldap_netlogon(mem_ctx, dclist[i].hostname, 881 char addr[INET6_ADDRSTRLEN]; 882 print_sockaddr(addr, sizeof(addr), &dclist[i].ss); 883 884 DEBUG(10,("LDAP ping to %s (%s)\n", dclist[i].hostname, addr)); 885 886 if (ads_cldap_netlogon(mem_ctx, &dclist[i].ss, 869 887 domain_name, 870 888 nt_version, … … 938 956 for (i=0; i<num_dcs; i++) { 939 957 uint16_t val; 940 int dgm_id;941 958 942 959 generate_random_buffer((uint8_t *)&val, 2); 943 dgm_id = val;944 960 945 961 ip_list.ss = dclist[i].ss; … … 967 983 struct NETLOGON_SAM_LOGON_RESPONSE_NT40 logon1; 968 984 969 r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);985 r = talloc_zero(mem_ctx, struct netlogon_samlogon_response); 970 986 NT_STATUS_HAVE_NO_MEMORY(r); 971 987 … … 1023 1039 if (flags & DS_IS_FLAT_NAME) { 1024 1040 1041 if (lp_disable_netbios()) { 1042 return NT_STATUS_NOT_SUPPORTED; 1043 } 1044 1025 1045 status = discover_dc_netbios(mem_ctx, domain_name, flags, 1026 1046 &dclist, &num_dcs); … … 1051 1071 return status; 1052 1072 } 1073 } 1074 1075 if (lp_disable_netbios()) { 1076 return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; 1053 1077 } 1054 1078 … … 1174 1198 1175 1199 if ((site_name == NULL) || (site_name[0] == '\0')) { 1176 ptr_to_free = sitename_fetch( domain_name);1200 ptr_to_free = sitename_fetch(mem_ctx, domain_name); 1177 1201 if (ptr_to_free != NULL) { 1178 1202 retry_query_with_null = true; … … 1191 1215 info); 1192 1216 1193 SAFE_FREE(ptr_to_free);1217 TALLOC_FREE(ptr_to_free); 1194 1218 1195 1219 if (!NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
Note:
See TracChangeset
for help on using the changeset viewer.