local.h: Fix spelling mistake :-).
[kai/samba.git] / source3 / namedbsubnet.c
index ab1f133dd4b92b50d4c7fcef1bf8eac3b7e56072..c6663d71fd472077ad724a2a34260e5bb81bbc5b 100644 (file)
@@ -41,6 +41,7 @@ extern struct in_addr ipzero;
 
 extern pstring myname;
 extern fstring myworkgroup;
+extern char **my_netbios_names;
 
 BOOL updatedlists = True;
 int updatecount = 0;
@@ -211,18 +212,35 @@ void add_workgroup_to_subnet( struct subnet_record *d, char *group)
 
   /* add WORKGROUP(00) entries into name database
      or register with WINS server, if it's our workgroup.
-     Don't register WORKGROUP(0x1e) on the WINS subnet - this is a broadcast
-     only name.
    */
   if (strequal(myworkgroup, group))
   {
-    add_my_name_entry(d,group,0x0 ,nb_type|NB_ACTIVE|NB_GROUP,False);
-    if((d != wins_subnet))
-      add_my_name_entry(d,group,0x1e,nb_type|NB_ACTIVE|NB_GROUP,False);
-    /* add samba server name to workgroup list. */
-    add_server_entry(d,w,myname,w->ServerType,0,lp_serverstring(),True);
-    DEBUG(3,("add_workgroup_to_subnet: Added server name entry %s to subnet %s\n",
-                myname, inet_ntoa(d->bcast_ip)));
+    int n;
+
+    add_my_name_entry(d,group,0x0 ,nb_type|NB_ACTIVE|NB_GROUP);
+
+    /* Only register the WORKGROUP<0x1e> name if we could be a local master
+       browser. */
+    if(lp_local_master())
+      add_my_name_entry(d,group,0x1e,nb_type|NB_ACTIVE|NB_GROUP);
+
+    /* Add all our server names to the workgroup list. We remove any
+       browser or logon server flags from all but the primary name.
+     */
+    for( n = 0; my_netbios_names[n]; n++)
+    {    
+      char *name = my_netbios_names[n];
+      int stype = w->ServerType;
+
+      if(!strequal(myname, name))
+          stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|
+                     SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);
+
+      add_server_entry(d,w,name,stype|SV_TYPE_LOCAL_LIST_ONLY,0,
+               lp_serverstring(),True);
+      DEBUG(3,("add_workgroup_to_subnet: Added server name entry %s \
+to subnet %s\n", name, inet_ntoa(d->bcast_ip)));
+    }
   }
 }
 
@@ -294,11 +312,11 @@ void write_browse_list(time_t t)
   dump_names();
   dump_workgroups();
   
-  strcpy(fname,lp_lockdir());
+  pstrcpy(fname,lp_lockdir());
   trim_string(fname,NULL,"/");
   strcat(fname,"/");
   strcat(fname,SERVER_LIST);
-  strcpy(fnamenew,fname);
+  pstrcpy(fnamenew,fname);
   strcat(fnamenew,".");
   
   f = fopen(fnamenew,"w");