diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2003-04-02 14:11:51 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2003-04-02 14:11:51 +0000 |
commit | 22c6b5be5ac67219694ad90b20aaf2f56dd4ed01 (patch) | |
tree | 5894db3e927be715634a507eb216b84e00c3dc9f /source3/utils | |
parent | f1c4fb5cf5e425e5a07348ed174f7ed4f5b315c9 (diff) | |
download | samba-22c6b5be5ac67219694ad90b20aaf2f56dd4ed01.tar.gz samba-22c6b5be5ac67219694ad90b20aaf2f56dd4ed01.tar.bz2 samba-22c6b5be5ac67219694ad90b20aaf2f56dd4ed01.zip |
Fix searching master ip by bcast when old master has gone away (based on patch by Stephan Kulow <coolo@kde.org>)
(This used to be commit 5c0e4b4dc630bd304f53c37f2340f954190b7aef)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/smbtree.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 52de5ab467..d245c324dd 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -90,10 +90,12 @@ static struct cli_state *get_ipc_connect(char *server, struct in_addr *server_ip /* Return the IP address and workgroup of a master browser on the network. */ -static BOOL find_master_ip_bcast(pstring workgroup, struct in_addr *server_ip) +static struct cli_state *get_ipc_connect_master_ip_bcast(pstring workgroup, struct user_auth_info *user_info) { struct in_addr *ip_list; + struct cli_state *cli; int i, count; + struct in_addr server_ip; /* Go looking for workgroups by broadcasting on the local network */ @@ -107,7 +109,7 @@ static BOOL find_master_ip_bcast(pstring workgroup, struct in_addr *server_ip) if (!name_status_find("*", 0, 0x1d, ip_list[i], name)) continue; - if (!find_master_ip(name, server_ip)) + if (!find_master_ip(name, &server_ip)) continue; pstrcpy(workgroup, name); @@ -115,10 +117,13 @@ static BOOL find_master_ip_bcast(pstring workgroup, struct in_addr *server_ip) DEBUG(4, ("found master browser %s, %s\n", name, inet_ntoa(ip_list[i]))); - return True; + if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info))) + continue; + + return cli; } - return False; + return NULL; } /**************************************************************************** @@ -136,19 +141,21 @@ static BOOL get_workgroups(struct user_auth_info *user_info) pstrcpy(master_workgroup, lp_workgroup()); - if (use_bcast || !find_master_ip(lp_workgroup(), &server_ip)) { - DEBUG(4, ("Unable to find master browser for workgroup %s\n", + if (!use_bcast && !find_master_ip(lp_workgroup(), &server_ip)) { + DEBUG(4, ("Unable to find master browser for workgroup %s, falling back to broadcast\n", master_workgroup)); - if (!find_master_ip_bcast(master_workgroup, &server_ip)) { + use_bcast = True; + } else if(!use_bcast) { + if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info))) + return False; + } + + if (!(cli = get_ipc_connect_master_ip_bcast(master_workgroup, user_info))) { DEBUG(4, ("Unable to find master browser by " "broadcast\n")); return False; - } } - if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info))) - return False; - if (!cli_NetServerEnum(cli, master_workgroup, SV_TYPE_DOMAIN_ENUM, add_name, &workgroups)) return False; |