r3143: Allow for multiple DC's to be named as #1c names in lmhosts.
authorVolker Lendecke <vlendec@samba.org>
Sat, 23 Oct 2004 09:20:02 +0000 (09:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:53:02 +0000 (10:53 -0500)
Volker
(This used to be commit 2af98ec054508055a63552cfdb48cfaf43f76b62)

source3/libsmb/namequery.c

index cee0015e25795daadcf709c2ac83f1d8c5dd4ee9..2e6842088a43ada35b8c3fe73ce5f9d22f1e29af 100644 (file)
@@ -855,22 +855,35 @@ static BOOL resolve_lmhosts(const char *name, int name_type,
 
        fp = startlmhosts(dyn_LMHOSTSFILE);
        if(fp) {
-               while (getlmhostsent(fp, lmhost_name, &name_type2, &return_ip)) {
-                       if (strequal(name, lmhost_name) && 
-                ((name_type2 == -1) || (name_type == name_type2))
-               ) {
-                               endlmhosts(fp);
-                               if ( (*return_iplist = (struct ip_service *)malloc(sizeof(struct ip_service))) == NULL ) {
-                                       DEBUG(3,("resolve_lmhosts: malloc fail !\n"));
-                                       return False;
-                               }
-                               (*return_iplist)[0].ip   = return_ip;
-                               (*return_iplist)[0].port = PORT_NONE;
-                               *return_count = 1;
-                               return True; 
+               while (getlmhostsent(fp, lmhost_name, &name_type2,
+                                    &return_ip)) {
+
+                       if (!strequal(name, lmhost_name))
+                               continue;
+
+                       if ((name_type2 != -1) && (name_type != name_type2))
+                               continue;
+
+                       *return_iplist = (struct ip_service *)
+                               realloc((*return_iplist),
+                                       sizeof(struct ip_service) *
+                                       ((*return_count)+1));
+
+                       if ((*return_iplist) == NULL) {
+                               DEBUG(3,("resolve_lmhosts: malloc fail !\n"));
+                               return False;
                        }
+
+                       (*return_iplist)[*return_count].ip   = return_ip;
+                       (*return_iplist)[*return_count].port = PORT_NONE;
+                       *return_count += 1;
+
+                       /* Multiple names only for DC lookup */
+                       if (name_type != 0x1c)
+                               break;
                }
                endlmhosts(fp);
+               return True;
        }
        return False;
 }