Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/libsmb/dsgetdcname.c

    r860 r988  
    2525#include "../librpc/gen_ndr/ndr_netlogon.h"
    2626#include "libads/cldap.h"
    27 #include "libads/dns.h"
     27#include "../lib/addns/dnsquery.h"
    2828#include "libsmb/clidgram.h"
    2929
     
    3333struct ip_service_name {
    3434        struct sockaddr_storage ss;
    35         unsigned port;
    3635        const char *hostname;
    3736};
     
    4645****************************************************************/
    4746
    48 void debug_dsdcinfo_flags(int lvl, uint32_t flags)
     47static void debug_dsdcinfo_flags(int lvl, uint32_t flags)
    4948{
    5049        DEBUG(lvl,("debug_dsdcinfo_flags: 0x%08x\n\t", flags));
     
    286285                                             uint32_t req_flags)
    287286{
    288         if (ret_flags == 0) {
     287        if (req_flags == 0) {
    289288                return true;
    290289        }
     
    336335        }
    337336
    338         if (!gencache_get_data_blob(key, &blob, NULL, NULL)) {
     337        if (!gencache_get_data_blob(key, NULL, &blob, NULL, NULL)) {
    339338                return NT_STATUS_NOT_FOUND;
    340339        }
    341340
    342         info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo);
     341        info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo);
    343342        if (!info) {
     343                data_blob_free(&blob);
    344344                return NT_STATUS_NO_MEMORY;
    345345        }
     
    479479        struct ip_service_name *dclist = NULL;
    480480        int count;
     481        static const char *resolve_order[] = { "lmhosts", "wins", "bcast", NULL };
    481482
    482483        *returned_dclist = NULL;
    483484        *returned_count = 0;
    484485
    485         if (lp_disable_netbios()) {
    486                 return NT_STATUS_NOT_SUPPORTED;
    487         }
    488 
    489486        if (flags & DS_PDC_REQUIRED) {
    490487                name_type = NBT_NAME_PDC;
     
    493490        status = internal_resolve_name(domain_name, name_type, NULL,
    494491                                       &iplist, &count,
    495                                        "lmhosts wins bcast");
     492                                       resolve_order);
    496493        if (!NT_STATUS_IS_OK(status)) {
    497494                DEBUG(10,("discover_dc_netbios: failed to find DC\n"));
     
    499496        }
    500497
    501         dclist = TALLOC_ZERO_ARRAY(mem_ctx, struct ip_service_name, count);
     498        dclist = talloc_zero_array(mem_ctx, struct ip_service_name, count);
    502499        if (!dclist) {
    503500                SAFE_FREE(iplist);
     
    514511
    515512                r->ss   = iplist[i].ss;
    516                 r->port = iplist[i].port;
    517513                r->hostname = talloc_strdup(mem_ctx, addr);
    518514                if (!r->hostname) {
     
    550546
    551547        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);
    554552        } 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);
    557558        } 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);
    560564        } 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);
    563570        } 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);
    566579        } 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);
    569585        }
    570586
     
    581597        }
    582598
    583         dclist = TALLOC_ZERO_ARRAY(mem_ctx,
     599        dclist = talloc_zero_array(mem_ctx,
    584600                                   struct ip_service_name,
    585601                                   numaddrs);
     
    598614                struct ip_service_name *r = &dclist[count];
    599615
    600                 r->port = dcs[i].port;
    601616                r->hostname = dcs[i].hostname;
    602617
     
    609624                        j = 0;
    610625                } else {
    611                         /* use the IP addresses from the SRV sresponse */
     626                        /* use the IP addresses from the SRV response */
    612627
    613628                        if (j >= dcs[i].num_ips) {
     
    623638                /* make sure it is a valid IP.  I considered checking the
    624639                 * negative connection cache, but this is the wrong place for
    625                  * it.  Maybe only as a hac. After think about it, if all of
    626                  * the IP addresses retuend from DNS are dead, what hope does a
     640                 * 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
    627642                 * netbios name lookup have?  The standard reason for falling
    628643                 * back to netbios lookups is that our DNS server doesn't know
     
    662677        struct netr_DsRGetDCNameInfo *info;
    663678
    664         info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo);
     679        info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo);
    665680        NT_STATUS_HAVE_NO_MEMORY(info);
    666681
     
    778793                dc_address = addr;
    779794                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;
    785795        } 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                }
    788803        }
    789804
     
    864879        for (i=0; i<num_dcs; i++) {
    865880
    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,
    869887                                        domain_name,
    870888                                        nt_version,
     
    938956        for (i=0; i<num_dcs; i++) {
    939957                uint16_t val;
    940                 int dgm_id;
    941958
    942959                generate_random_buffer((uint8_t *)&val, 2);
    943                 dgm_id = val;
    944960
    945961                ip_list.ss = dclist[i].ss;
     
    967983                        struct NETLOGON_SAM_LOGON_RESPONSE_NT40 logon1;
    968984
    969                         r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);
     985                        r = talloc_zero(mem_ctx, struct netlogon_samlogon_response);
    970986                        NT_STATUS_HAVE_NO_MEMORY(r);
    971987
     
    10231039        if (flags & DS_IS_FLAT_NAME) {
    10241040
     1041                if (lp_disable_netbios()) {
     1042                        return NT_STATUS_NOT_SUPPORTED;
     1043                }
     1044
    10251045                status = discover_dc_netbios(mem_ctx, domain_name, flags,
    10261046                                             &dclist, &num_dcs);
     
    10511071                        return status;
    10521072                }
     1073        }
     1074
     1075        if (lp_disable_netbios()) {
     1076                return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
    10531077        }
    10541078
     
    11741198
    11751199        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);
    11771201                if (ptr_to_free != NULL) {
    11781202                        retry_query_with_null = true;
     
    11911215                                info);
    11921216
    1193         SAFE_FREE(ptr_to_free);
     1217        TALLOC_FREE(ptr_to_free);
    11941218
    11951219        if (!NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
Note: See TracChangeset for help on using the changeset viewer.