From ea24bb2da8f643e043dc3af3ed3f16388878b57b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 6 Nov 2002 01:29:07 +0000 Subject: Merge of get_dc_list() api change. This was slightly more intrusive than the version in APPLIANCE so watch out for boogs. (This used to be commit 1e054e3db654801fbb5580211529cdfdea9ed686) --- source3/utils/net.c | 25 ++++++------------------- source3/utils/net_lookup.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 27 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net.c b/source3/utils/net.c index 704b886d72..607e47cf71 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -180,20 +180,15 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na return False; } } else if (flags & NET_FLAGS_PDC) { - struct in_addr *ip_list; - int addr_count; - if (get_dc_list(True /* PDC only*/, opt_target_workgroup, &ip_list, &addr_count)) { + struct in_addr pdc_ip; + + if (get_pdc_ip(opt_target_workgroup, &pdc_ip)) { fstring dc_name; - if (addr_count < 1) { - return False; - } - - *server_ip = *ip_list; - if (is_zero_ip(*server_ip)) + if (is_zero_ip(pdc_ip)) return False; - if (!lookup_dc_name(global_myname, opt_target_workgroup, server_ip, dc_name)) + if (!lookup_dc_name(global_myname, opt_target_workgroup, &pdc_ip, dc_name)) return False; *server_name = strdup(dc_name); @@ -236,17 +231,9 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na BOOL net_find_dc(struct in_addr *server_ip, fstring server_name, const char *domain_name) { - struct in_addr *ip_list; - int addr_count; - - if (get_dc_list(True /* PDC only*/, domain_name, &ip_list, &addr_count)) { + if (get_pdc_ip(domain_name, server_ip)) { fstring dc_name; - if (addr_count < 1) { - return False; - } - *server_ip = *ip_list; - if (is_zero_ip(*server_ip)) return False; diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index f76b186251..32921de620 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -79,8 +79,8 @@ static int net_lookup_ldap(int argc, const char **argv) #ifdef HAVE_LDAP char *srvlist; const char *domain; - int rc, count; - struct in_addr *addr; + int rc; + struct in_addr addr; struct hostent *hostent; if (argc > 0) @@ -96,10 +96,10 @@ static int net_lookup_ldap(int argc, const char **argv) } DEBUG(9, ("Looking up DC for domain %s\n", domain)); - if (!get_dc_list(True, domain, &addr, &count)) + if (!get_pdc_ip(domain, &addr)) return -1; - hostent = gethostbyaddr((char *) &addr->s_addr, sizeof(addr->s_addr), + hostent = gethostbyaddr((char *) &addr.s_addr, sizeof(addr.s_addr), AF_INET); if (!hostent) return -1; @@ -124,7 +124,7 @@ static int net_lookup_ldap(int argc, const char **argv) static int net_lookup_dc(int argc, const char **argv) { - struct in_addr *ip_list; + struct in_addr *ip_list, addr; char *pdc_str = NULL; const char *domain=opt_target_workgroup; int count, i; @@ -133,13 +133,13 @@ static int net_lookup_dc(int argc, const char **argv) domain=argv[0]; /* first get PDC */ - if (!get_dc_list(True, domain, &ip_list, &count)) + if (!get_pdc_ip(domain, &addr)) return -1; - asprintf(&pdc_str, "%s", inet_ntoa(*ip_list)); + asprintf(&pdc_str, "%s", inet_ntoa(addr)); d_printf("%s\n", pdc_str); - if (!get_dc_list(False, domain, &ip_list, &count)) { + if (!get_dc_list(domain, &ip_list, &count)) { SAFE_FREE(pdc_str); return 0; } -- cgit