Forward port of Richard Sharpe's <realrichardsharpe@gmail.com> fix for bug #8970...
authorJeremy Allison <jra@samba.org>
Thu, 31 May 2012 23:25:52 +0000 (16:25 -0700)
committerKarolin Seeger <kseeger@samba.org>
Wed, 13 Jun 2012 17:34:45 +0000 (19:34 +0200)
source3/include/proto.h
source3/nmbd/nmbd.c
source3/param/loadparm.c
source3/printing/load.c
source3/smbd/server_reload.c
source3/winbindd/winbindd.c

index 28b58b2879cbe9ce51287469446af6c7ae661066..e22fc9cd3d8437ba3967dfdfb5e4cf5dbe417eef 100644 (file)
@@ -1338,9 +1338,9 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
 /* The following definitions come from param/loadparm.c  */
 
 char *lp_smb_ports(void);
-char *lp_dos_charset(void);
-char *lp_unix_charset(void);
-char *lp_display_charset(void);
+const char *lp_dos_charset(void);
+const char *lp_unix_charset(void);
+const char *lp_display_charset(void);
 char *lp_logfile(void);
 char *lp_configfile(void);
 char *lp_smb_passwd_file(void);
index 986c57570ce9f32415bfd4a9899b545341084143..0172e084695f59943c9b918187640fc8af825b4d 100644 (file)
@@ -365,11 +365,12 @@ static bool reload_nmbd_services(bool test)
        set_remote_machine_name("nmbd", False);
 
        if ( lp_loaded() ) {
-               const char *fname = lp_configfile();
+               char *fname = lp_configfile();
                if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
                        set_dyn_CONFIGFILE(fname);
                        test = False;
                }
+               TALLOC_FREE(fname);
        }
 
        if ( test && !lp_file_list_changed() )
index 6ad2452b8a34570fe6ba0bc069b12b4d4d5359a1..dd633399a05f9c0c45db340a489689404f185f9e 100644 (file)
@@ -5575,9 +5575,9 @@ static char *lp_string(const char *s)
  char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
 
 FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
-FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
-FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
-FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
+FN_GLOBAL_CONST_STRING(lp_dos_charset, &Globals.dos_charset)
+FN_GLOBAL_CONST_STRING(lp_unix_charset, &Globals.unix_charset)
+FN_GLOBAL_CONST_STRING(lp_display_charset, &Globals.display_charset)
 FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
 FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
 FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
@@ -9647,7 +9647,11 @@ static bool lp_load_ex(const char *pszFname,
                }
        }
 
-       lp_add_auto_services(lp_auto_services());
+       {
+               char *serv = lp_auto_services();
+               lp_add_auto_services(serv);
+               TALLOC_FREE(serv);
+       }
 
        if (add_ipc) {
                /* When 'restrict anonymous = 2' guest connections to ipc$
index 5acc25833d0c2d94a0cc6d7afc02a44e1c5b6a69..829c3e32e407c21ffb02f2da09abc0be1b95cce0 100644 (file)
@@ -30,6 +30,7 @@ static void add_auto_printers(void)
        int pnum = lp_servicenumber(PRINTERS_NAME);
        char *str;
        char *saveptr;
+       char *auto_serv = NULL;
 
        if (pnum < 0)
                if (process_registry_service(PRINTERS_NAME))
@@ -38,8 +39,12 @@ static void add_auto_printers(void)
        if (pnum < 0)
                return;
 
-       if ((str = SMB_STRDUP(lp_auto_services())) == NULL)
+       auto_serv = lp_auto_services();
+       str = SMB_STRDUP(auto_serv);
+       TALLOC_FREE(auto_serv);
+       if (str == NULL) {
                return;
+       }
 
        for (p = strtok_r(str, LIST_SEP, &saveptr); p;
             p = strtok_r(NULL, LIST_SEP, &saveptr)) {
index 6e0ab399127f730b464c6aa8273de81f2dc3f7f8..fd6dc1a59bfe1ffa1dd59ac9f01bad3ae00bc60f 100644 (file)
@@ -127,6 +127,7 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
                        set_dyn_CONFIGFILE(fname);
                        test = False;
                }
+               TALLOC_FREE(fname);
        }
 
        reopen_logs();
index 110f0348cb953a2a64c847c4b83efd31aca5df54..f80949dc4e1921eab97354e7bbe642d5aa95f9a6 100644 (file)
@@ -65,11 +65,12 @@ static bool reload_services_file(const char *lfile)
        bool ret;
 
        if (lp_loaded()) {
-               const char *fname = lp_configfile();
+               char *fname = lp_configfile();
 
                if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
                        set_dyn_CONFIGFILE(fname);
                }
+               TALLOC_FREE(fname);
        }
 
        /* if this is a child, restore the logfile to the special