diff options
author | Jeremy Allison <jra@samba.org> | 2002-02-28 01:05:15 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-02-28 01:05:15 +0000 |
commit | 8ed49fe0df201833329c17b2afe1e3aa70646558 (patch) | |
tree | 28340dd41a946ca3180cc13798b817b41e14a5b5 /source/nsswitch | |
parent | fe2db3148587937aa7b674c1c99036d42a3776b3 (diff) | |
download | samba-8ed49fe0df201833329c17b2afe1e3aa70646558.tar.gz samba-8ed49fe0df201833329c17b2afe1e3aa70646558.tar.xz samba-8ed49fe0df201833329c17b2afe1e3aa70646558.zip |
Ensure that winbindd and smbd both use identical logic to find dc's.
Fix bug where zeroip addresses were being checked.
Jeremy.
Diffstat (limited to 'source/nsswitch')
-rw-r--r-- | source/nsswitch/winbindd_cm.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/source/nsswitch/winbindd_cm.c b/source/nsswitch/winbindd_cm.c index 3aaaf6b6709..dcbd47303f3 100644 --- a/source/nsswitch/winbindd_cm.c +++ b/source/nsswitch/winbindd_cm.c @@ -148,47 +148,46 @@ static BOOL cm_get_dc_name(const char *domain, fstring srv_name, struct in_addr } /* Pick a nice close server */ - - if (strequal(lp_passwordserver(), "*")) { + /* Look for DC on local net */ + + for (i = 0; i < count; i++) { + if (!is_local_net(ip_list[i])) + continue; - /* Look for DC on local net */ - - for (i = 0; i < count; i++) { - if (is_local_net(ip_list[i]) && - name_status_find(domain, 0x1c, 0x20, - ip_list[i], srv_name)) { - dc_ip = ip_list[i]; - goto done; - } - zero_ip(&ip_list[i]); + if (name_status_find(domain, 0x1c, 0x20, ip_list[i], srv_name)) { + dc_ip = ip_list[i]; + goto done; } + zero_ip(&ip_list[i]); + } - /* Look for other DCs */ - - for (i = 0; i < count; i++) { - if (!is_zero_ip(ip_list[i]) && - name_status_find(domain, 0x1c, 0x20, - ip_list[i], srv_name)) { - dc_ip = ip_list[i]; - goto done; - } - } + /* + * Secondly try and contact a random PDC/BDC. + */ - /* No-one to talk to )-: */ + i = (sys_random() % count); - return False; + if (!is_zero_ip(ip_list[i]) && + name_status_find(domain, 0x1c, 0x20, + ip_list[i], srv_name)) { + dc_ip = ip_list[i]; + goto done; } + zero_ip(&ip_list[i]); /* Tried and failed. */ - /* Return first DC that we can contact */ + /* Finally return first DC that we can contact */ for (i = 0; i < count; i++) { - if (name_status_find(domain, 0x1c, 0x20, ip_list[i], - srv_name)) { + if (is_zero_ip(ip_list[i])) + continue; + + if (name_status_find(domain, 0x1c, 0x20, ip_list[i], srv_name)) { dc_ip = ip_list[i]; goto done; } } + /* No-one to talk to )-: */ return False; /* Boo-hoo */ done: @@ -201,7 +200,7 @@ static BOOL cm_get_dc_name(const char *domain, fstring srv_name, struct in_addr fstrcpy(dcc->srv_name, srv_name); - DEBUG(3, ("Returning DC %s (%s) for domain %s\n", srv_name, + DEBUG(3, ("cm_get_dc_name: Returning DC %s (%s) for domain %s\n", srv_name, inet_ntoa(dc_ip), domain)); *ip_out = dc_ip; |