W2K doesn't seem to respond to *#0 names in node status. Ensure name
authorJeremy Allison <jra@samba.org>
Wed, 21 Nov 2001 23:00:59 +0000 (23:00 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 21 Nov 2001 23:00:59 +0000 (23:00 +0000)
lookup uses password server parameter when looking for PDCs.
Jeremy.
(This used to be commit 54c968913d6553c6d834b068234ab176917075eb)

source3/libsmb/domain_client_validate.c
source3/libsmb/libsmbclient.c
source3/libsmb/namequery.c
source3/nsswitch/winbindd.c
source3/nsswitch/winbindd_util.c
source3/smbwrapper/smbw.c
source3/utils/smbtree.c

index a8c3ff2f6b4cba00693ca2c2d8398a70537f84e2..2fd17e1fa4abecad437fa018f3695b952562ea36 100644 (file)
@@ -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;
index af2daac3fcd41ecedf62afa37e25589668fbd996..ce00548518f9f19870ea156cbe9f4230a0fd1dd7 100644 (file)
@@ -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 */
index 0e696a085b92fd13761ce89b41e890cee67495ff..f8688ddb25d69e39d031e9de18fce18168f17d01 100644 (file)
@@ -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;i<count;i++) {
-               if (status[i].type == type) break;
+               if (status[i].type == type)
+                       break;
        }
-       if (i == count) return False;
+       if (i == count)
+               return False;
 
        pull_ascii(name, status[i].name, 15, 0, STR_TERMINATE);
 
@@ -980,7 +986,7 @@ BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pd
 
   *pdc_name = '\0';
 
-  ret = name_status_find(0x20,*pdc_ip,pdc_name);
+  ret = name_status_find(domain, 0x1b, 0x20,*pdc_ip,pdc_name);
 
   if(ret && *pdc_name) {
     fstrcpy(ret_name, pdc_name);
@@ -1172,9 +1178,50 @@ NT GETDC call, UNICODE, NT domain SID and uncle tom cobbley and all...
 /********************************************************
  Get the IP address list of the PDC/BDC's of a Domain.
 *********************************************************/
+
 BOOL get_dc_list(BOOL pdc_only, char *group, struct in_addr **ip_list, int *count)
 {
-       return internal_resolve_name(group, pdc_only ? 0x1B : 0x1C, ip_list, count);
+       /*
+        * If we're looking for a PDC and it's our domain then
+        * use the 'password server' parameter.
+        */
+
+       if (pdc_only && strequal(group, lp_workgroup())) {
+               char *p;
+               char *pserver = lp_passwordserver();
+               fstring name;
+               int num_adresses = 0;
+               struct in_addr *return_iplist = NULL;
+
+               if (! *pserver)
+                       return internal_resolve_name(group, 0x1B, ip_list, count);
+
+               p = pserver;
+               while (next_token(&p,name,LIST_SEP,sizeof(name))) {
+                       if (strequal(name, "*"))
+                               return internal_resolve_name(group, 0x1B, ip_list, count);
+                       num_adresses++;
+               }
+               if (num_adresses == 0)
+                       return internal_resolve_name(group, 0x1B, ip_list, count);
+
+               return_iplist = (struct in_addr *)malloc(num_adresses * sizeof(struct in_addr));
+               if(return_iplist == NULL) {
+                       DEBUG(3,("get_dc_list: malloc fail !\n"));
+                       return False;
+               }
+               p = pserver;
+               *count = 0;
+               while (next_token(&p,name,LIST_SEP,sizeof(name))) {
+                       struct in_addr name_ip;
+                       if (resolve_name( name, &name_ip, 0x20) == False)
+                               continue;
+                       return_iplist[*count++] = name_ip;
+               }
+               *ip_list = return_iplist;
+               return (*count != 0);
+       } else
+               return internal_resolve_name(group, pdc_only ? 0x1B : 0x1C, ip_list, count);
 }
 
 /********************************************************
index 56ed17464bbd59fa5bf5e628009b8cecf3edf2be..9c8b022f53175ffa69f4c1cd9004135f244b7836 100644 (file)
@@ -677,11 +677,13 @@ int main(int argc, char **argv)
        BOOL interactive = False;
        int opt, new_debuglevel = -1;
 
-        /* glibc (?) likes to print "User defined signal 1" and exit if a
-           SIGUSR1 is received before a handler is installed */
+       /* glibc (?) likes to print "User defined signal 1" and exit if a
+               SIGUSR1 is received before a handler is installed */
 
        CatchSignal(SIGUSR1, SIG_IGN);
 
+       snprintf(debugf, sizeof(debugf), "%s/log.winbindd", dyn_LOGFILEBASE);
+
        /* Initialise for running in non-root mode */
 
        sec_init();
index 90292ec2d2895c3d9dd5933b0cd9269bfaaf5933..cf7a04e8ff7d6221ce9d752068ea8e816ba4e352 100644 (file)
@@ -114,55 +114,54 @@ BOOL get_domain_info(void)
        uint32 enum_ctx = 0, num_doms = 0;
        char **domains = NULL;
        DOM_SID *sids = NULL, domain_sid;
-        NTSTATUS result;
-        CLI_POLICY_HND *hnd;
+       NTSTATUS result;
+       CLI_POLICY_HND *hnd;
        int i;
-        fstring level5_dom;
-        BOOL rv = False;
-        TALLOC_CTX *mem_ctx;
+       fstring level5_dom;
+       BOOL rv = False;
+       TALLOC_CTX *mem_ctx;
        
        DEBUG(1, ("getting trusted domain list\n"));
 
-        if (!(mem_ctx = talloc_init()))
-                return False;
+       if (!(mem_ctx = talloc_init()))
+               return False;
 
        /* Add our workgroup - keep handle to look up 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_query_info_policy(hnd->cli, 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 */
index 24d09e2d423dc9e3182d1087dae7ebfd99b15718..b4b0b28f3682f5c5e09c3c6f85a21c8337c9a1f5 100644 (file)
@@ -273,7 +273,7 @@ static char *smbw_find_workgroup(void)
 
        for (i=0;i<count;i++) {
                static fstring name;
-               if (name_status_find(0x1d, ip_list[i], name)) {
+               if (name_status_find("*", 0, 0x1d, ip_list[i], name)) {
                        slprintf(server, sizeof(server), "%s#1D", name);
                        if (smbw_server(server, "IPC$")) {
                                smbw_setshared("WORKGROUP", name);
index 857b858beca4a90b69fbce8f990bfa0f0f25b79e..9ce8120bbadcb44e1af2d9d177dd7bf89bc654a3 100644 (file)
@@ -182,7 +182,7 @@ static BOOL find_master_ip_bcast(pstring workgroup, struct in_addr *server_ip)
        for (i = 0; i < count; i++) {
                static fstring name;
 
-               if (!name_status_find(0x1d, ip_list[i], name))
+               if (!name_status_find("*", 0, 0x1d, ip_list[i], name))
                        continue;
 
                 if (!find_master_ip(name, server_ip))