I think the lookup_pdc_name() should be called lookup_dc_name() and the
authorTim Potter <tpot@samba.org>
Thu, 29 Nov 2001 05:50:32 +0000 (05:50 +0000)
committerTim Potter <tpot@samba.org>
Thu, 29 Nov 2001 05:50:32 +0000 (05:50 +0000)
name_status_find() call here should look up a #1c name instead of #1d.
This fixes some bugs currently with BDC authentication in winbindd and in
smbd as you can't query the #1d name with the ip address of a BDC.

Who is Uncle Tom Cobbley anyway?
(This used to be commit 4215048f7b20a8f9e5877bdbb2f54841b2f7fa64)

source3/auth/auth_domain.c
source3/libsmb/namequery.c
source3/nsswitch/winbindd_cm.c
source3/rpc_client/cli_trust.c

index a779a7e9c0df0be561985d4fe22b3b410e617b86..125b3aa0297f3a453abafcc8f77f3e0b93fb0678 100644 (file)
@@ -184,7 +184,7 @@ static BOOL attempt_connect_to_dc(struct cli_state *pcli, struct in_addr *ip,
        if (is_zero_ip(*ip))
                return False;
 
-       if (!lookup_pdc_name(global_myname, lp_workgroup(), ip, dc_name))
+       if (!lookup_dc_name(global_myname, lp_workgroup(), ip, dc_name))
                return False;
 
        return connect_to_domain_password_server(pcli, dc_name, trust_passwd);
index a181e3183f4746649106dfca1c4ca73dcd711df5..8d00c50914eee45c5d207d5d9029d8d79d2548a0 100644 (file)
@@ -927,7 +927,7 @@ BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
         if (strcmp(dest_host,"*") == 0) {
                 extern pstring global_myname;
                 ret = resolve_name(lp_workgroup(), ip, 0x1B);
-                lookup_pdc_name(global_myname, lp_workgroup(), ip, dest_host);
+                lookup_dc_name(global_myname, lp_workgroup(), ip, dest_host);
         } else {
                 ret = resolve_name(dest_host, ip, 0x20);
         }
@@ -966,31 +966,32 @@ BOOL find_master_ip(char *group, struct in_addr *master_ip)
 }
 
 /********************************************************
- Lookup a PDC name given a Domain name and IP address.
+ Lookup a DC name given a Domain name and IP address.
 *********************************************************/
 
-BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name)
+BOOL lookup_dc_name(const char *srcname, const char *domain, 
+                   struct in_addr *dc_ip, char *ret_name)
 {
 #if !defined(I_HATE_WINDOWS_REPLY_CODE)
+       
+       fstring dc_name;
+       BOOL ret;
+       
+       /*
+        * Due to the fact win WinNT *sucks* we must do a node status
+        * query here... JRA.
+        */
+       
+       *dc_name = '\0';
+       
+       ret = name_status_find(domain, 0x1c, 0x20, *dc_ip, dc_name);
 
-  fstring pdc_name;
-  BOOL ret;
-
-  /*
-   * Due to the fact win WinNT *sucks* we must do a node status
-   * query here... JRA.
-   */
-
-  *pdc_name = '\0';
-
-  ret = name_status_find(domain, 0x1b, 0x20,*pdc_ip,pdc_name);
-
-  if(ret && *pdc_name) {
-    fstrcpy(ret_name, pdc_name);
-    return True;
-  }
-
-  return False;
+       if(ret && *dc_name) {
+               fstrcpy(ret_name, dc_name);
+               return True;
+       }
+       
+       return False;
 
 #else /* defined(I_HATE_WINDOWS_REPLY_CODE) */
 
index db5c51404ae129cad684e193a75588739242b22c..f11d86d4c1b318fb5bfa39e61d721f07fbe71e9c 100644 (file)
@@ -92,7 +92,6 @@ static BOOL cm_get_dc_name(char *domain, fstring srv_name)
        static struct get_dc_name_cache *get_dc_name_cache;
        struct get_dc_name_cache *dcc;
        struct in_addr *ip_list, dc_ip;
-       extern pstring global_myname;
        int count, i;
 
        /* Check the cache for previous lookups */
@@ -144,8 +143,10 @@ static BOOL cm_get_dc_name(char *domain, fstring srv_name)
 
        /* Lookup domain controller name */
                
-       if (!get_dc_list(False, domain, &ip_list, &count))
+       if (!get_dc_list(False, domain, &ip_list, &count)) {
+               DEBUG(3, ("Could not look up dc's for domain %s\n", domain));
                return False;
+       }
                
        /* Firstly choose a PDC/BDC who has the same network address as any
           of our interfaces. */
@@ -155,7 +156,10 @@ static BOOL cm_get_dc_name(char *domain, fstring srv_name)
                        goto got_ip;
        }
 
-       if (count == 0) return False;
+       if (count == 0) {
+               DEBUG(3, ("No domain controllers for domain %s\n", domain));
+               return False;
+       }
        
        i = (sys_random() % count);
        
@@ -163,8 +167,13 @@ static BOOL cm_get_dc_name(char *domain, fstring srv_name)
        dc_ip = ip_list[i];
        SAFE_FREE(ip_list);
                
-       if (!lookup_pdc_name(global_myname, domain, &dc_ip, srv_name))
+       /* We really should be doing a GETDC call here rather than a node
+          status lookup. */
+
+       if (!name_status_find(domain, 0x1c, 0x20, dc_ip, srv_name)) {
+               DEBUG(3, ("Error looking up DC name for %s in domain %s\n", inet_ntoa(dc_ip), domain));
                return False;
+       }
 
        /* We have a name so make the cache entry positive now */
 
index a12f4035eedc46aa207eaed9d93ec0845a322cfc..c910e2f334a62d1eaa87669b7ba03d9b9216dd9d 100644 (file)
@@ -213,7 +213,7 @@ account password for domain %s.\n", domain));
 
       for(i = 0; i < count; i++) {
         fstring dc_name;
-        if(!lookup_pdc_name(global_myname, domain, &ip_list[i], dc_name))
+        if(!lookup_dc_name(global_myname, domain, &ip_list[i], dc_name))
           continue;
         if((res = modify_trust_password( domain, dc_name,
                                          old_trust_passwd_hash, new_trust_passwd_hash)))