s3-registry: Check return code of push_reg_sz().
[kai/samba.git] / source3 / nmbd / nmbd_workgroupdb.c
index 1845401d9e7cbd029eaf996b3119c6d6c4b632fb..14b33b321e1cd2262cebb346f7108f5add689893 100644 (file)
@@ -21,6 +21,8 @@
 */
 
 #include "includes.h"
+#include "../librpc/gen_ndr/svcctl.h"
+#include "nmbd/nmbd.h"
 
 extern uint16 samba_nb_type;
 
@@ -50,7 +52,7 @@ static void name_to_unstring(unstring unname, const char *name)
        if (errno == E2BIG) {
                unstring tname;
                pull_ascii_nstring(tname, sizeof(tname), nname);
-               unstrcpy(unname, tname);
+               strlcpy(unname, tname, sizeof(nname));
                DEBUG(0,("name_to_nstring: workgroup name %s is too long. Truncating to %s\n",
                        name, tname));
        } else {
@@ -139,14 +141,7 @@ static struct work_record *remove_workgroup_from_subnet(struct subnet_record *su
        remove_all_servers(work);
   
        if (!work->serverlist) {
-               if (work->prev)
-                       work->prev->next = work->next;
-               if (work->next)
-                       work->next->prev = work->prev;
-  
-               if (subrec->workgrouplist == work)
-                       subrec->workgrouplist = work->next; 
-  
+               DLIST_REMOVE(subrec->workgrouplist, work);
                ZERO_STRUCTP(work);
                SAFE_FREE(work);
        }
@@ -255,11 +250,11 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name));
                const char *name = my_netbios_names(i);
                int stype = lp_default_server_announce() | (lp_local_master() ?  SV_TYPE_POTENTIAL_BROWSER : 0 );
    
-               if(!strequal(global_myname(), name))
+               if(!strequal(lp_netbios_name(), name))
                        stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);
    
                create_server_on_workgroup(work,name,stype|SV_TYPE_LOCAL_LIST_ONLY, PERMANENT_TTL, 
-                               string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
+                               string_truncate(lp_serverstring(talloc_tos()), MAX_SERVER_STRING_LENGTH));
                DEBUG(3,("initiate_myworkgroup_startup: Added server name entry %s \
 on subnet %s\n", name, subrec->subnet_name));
        }