From 191dff2d279dd8315f093e313d8c149e786eb19f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 23 Nov 2002 14:27:56 +0000 Subject: [merge from APP_HEAD] 90% fix for CR 1076. The password server parameter will no take things like password server = DC1 * which means to contact DC1 first and the go to auto lookup if it fails. jerry (This used to be commit c31a17889e3e4daf7c1e807038efc2c0fba78be3) --- source3/libsmb/namequery.c | 126 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 104 insertions(+), 22 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 5c3d942b90..6190c872ee 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1235,19 +1235,24 @@ BOOL get_pdc_ip(const char *domain, struct in_addr *ip) a domain. *********************************************************/ -BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count) +BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count, int *ordered) { - /* - * If it's our domain then - * use the 'password server' parameter. - */ + + *ordered = False; + + /* If it's our domain then use the 'password server' parameter. */ if (strequal(domain, lp_workgroup())) { - const char *p; - char *pserver = lp_passwordserver(); + char *p; + char *pserver = lp_passwordserver(); /* UNIX charset. */ fstring name; - int num_adresses = 0; + int num_addresses = 0; + int local_count, i, j; struct in_addr *return_iplist = NULL; + struct in_addr *auto_ip_list = NULL; + BOOL done_auto_lookup = False; + int auto_count = 0; + if (!*pserver) return internal_resolve_name( @@ -1255,19 +1260,31 @@ BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count) p = pserver; + /* + * if '*' appears in the "password server" list then add + * an auto lookup to the list of manually configured + * DC's. If any DC is listed by name, then the list should be + * considered to be ordered + */ + while (next_token(&p,name,LIST_SEP,sizeof(name))) { - if (strequal(name, "*")) - return internal_resolve_name( - domain, 0x1C, ip_list, count); - num_adresses++; + if (strequal(name, "*")) { + if ( internal_resolve_name(domain, 0x1C, &auto_ip_list, &auto_count) ) + num_addresses += auto_count; + done_auto_lookup = True; + DEBUG(8,("Adding %d DC's from auto lookup\n", auto_count)); + } + else + num_addresses++; } - if (num_adresses == 0) - return internal_resolve_name( - domain, 0x1C, ip_list, count); + /* if we have no addresses and haven't done the auto lookup, then + just return the list of DC's */ + + if ( (num_addresses == 0) && !done_auto_lookup ) + return internal_resolve_name(domain, 0x1C, ip_list, count); - return_iplist = (struct in_addr *)malloc( - num_adresses * sizeof(struct in_addr)); + return_iplist = (struct in_addr *)malloc(num_addresses * sizeof(struct in_addr)); if (return_iplist == NULL) { DEBUG(3,("get_dc_list: malloc fail !\n")); @@ -1275,19 +1292,84 @@ BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count) } p = pserver; - *count = 0; + local_count = 0; - while (next_token(&p,name,LIST_SEP,sizeof(name))) { + /* fill in the return list now with real IP's */ + + while ( (local_count