From f146325e7df80b26616225017ef6a60ff5f2e349 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Nov 2001 23:00:59 +0000 Subject: W2K doesn't seem to respond to *#0 names in node status. Ensure name lookup uses password server parameter when looking for PDCs. Jeremy. (This used to be commit 54c968913d6553c6d834b068234ab176917075eb) --- source3/libsmb/domain_client_validate.c | 2 +- source3/libsmb/libsmbclient.c | 4 +-- source3/libsmb/namequery.c | 63 ++++++++++++++++++++++++++++----- source3/nsswitch/winbindd.c | 6 ++-- source3/nsswitch/winbindd_util.c | 49 +++++++++++++------------ source3/smbwrapper/smbw.c | 2 +- source3/utils/smbtree.c | 2 +- 7 files changed, 88 insertions(+), 40 deletions(-) diff --git a/source3/libsmb/domain_client_validate.c b/source3/libsmb/domain_client_validate.c index a8c3ff2f6b..2fd17e1fa4 100644 --- a/source3/libsmb/domain_client_validate.c +++ b/source3/libsmb/domain_client_validate.c @@ -53,7 +53,7 @@ static BOOL connect_to_domain_password_server(struct cli_state *pcli, return False; } - if (!name_status_find(0x20, to_ip, remote_machine)) { + if (!name_status_find("*", 0x20, 0x20, to_ip, remote_machine)) { DEBUG(0, ("connect_to_domain_password_server: Can't " "resolve name for IP %s\n", server)); return False; diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index af2daac3fc..ce00548518 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -1602,7 +1602,7 @@ int smbc_opendir(const char *fname) /* find the name of the server ... */ - if (!name_status_find(0, rem_ip, server)) { + if (!name_status_find("*", 0, 0, rem_ip, server)) { DEBUG(0, ("Could not get the name of local master browser for server %s\n", server)); errno = EINVAL; @@ -1671,7 +1671,7 @@ int smbc_opendir(const char *fname) */ - if (!name_status_find(0, rem_ip, buserver)) { + if (!name_status_find("*", 0, 0, rem_ip, buserver)) { DEBUG(0, ("Could not get name of local master browser %s\n", server)); errno = EPERM; /* FIXME, is this correct */ diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 0e696a085b..f8688ddb25 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -160,7 +160,8 @@ find the first type XX name in a node status reply - used for finding a servers name given its IP return the matched name in *name **************************************************************************/ -BOOL name_status_find(int type, struct in_addr to_ip, char *name) + +BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr to_ip, char *name) { struct node_status *status; struct nmb_name nname; @@ -168,17 +169,22 @@ BOOL name_status_find(int type, struct in_addr to_ip, char *name) int sock; sock = open_socket_in(SOCK_DGRAM, 0, 3, interpret_addr(lp_socket_address()), True); - if (sock == -1) return False; + if (sock == -1) + return False; - make_nmb_name(&nname, "*", 0); + /* W2K PDC's seem not to respond to '*'#0. JRA */ + make_nmb_name(&nname, q_name, q_type); status = node_status_query(sock, &nname, to_ip, &count); close(sock); - if (!status) return False; + if (!status) + return False; for (i=0;icli, mem_ctx, - &hnd->pol, 0x05, level5_dom, - &domain_sid); + result = cli_lsa_query_info_policy(hnd->cli, mem_ctx, + &hnd->pol, 0x05, level5_dom, &domain_sid); - if (!NT_STATUS_IS_OK(result)) - goto done; + if (!NT_STATUS_IS_OK(result)) + goto done; add_trusted_domain(lp_workgroup(), &domain_sid); /* Enumerate list of trusted domains */ - if (!(hnd = cm_get_lsa_handle(lp_workgroup()))) - goto done; + if (!(hnd = cm_get_lsa_handle(lp_workgroup()))) + goto done; - result = cli_lsa_enum_trust_dom(hnd->cli, mem_ctx, - &hnd->pol, &enum_ctx, &num_doms, - &domains, &sids); + result = cli_lsa_enum_trust_dom(hnd->cli, mem_ctx, + &hnd->pol, &enum_ctx, &num_doms, &domains, &sids); - if (!NT_STATUS_IS_OK(result)) - goto done; + if (!NT_STATUS_IS_OK(result)) + goto done; - /* Add each domain to the trusted domain list */ + /* Add each domain to the trusted domain list */ for(i = 0; i < num_doms; i++) add_trusted_domain(domains[i], &sids[i]); - rv = True; + rv = True; done: - talloc_destroy(mem_ctx); - return rv; + talloc_destroy(mem_ctx); + + return rv; } /* Free global domain info */ diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c index 24d09e2d42..b4b0b28f36 100644 --- a/source3/smbwrapper/smbw.c +++ b/source3/smbwrapper/smbw.c @@ -273,7 +273,7 @@ static char *smbw_find_workgroup(void) for (i=0;i