Fix bug 9900: is_printer_published GUID retrieval
[obnox/samba/samba-obnox.git] / source3 / smbd / server_reload.c
index f9891de218f4a2865bbd74ca56e27bc15efb08f5..1d6f9c2911ff0581fd39d527ab2a6ab5e05764f2 100644 (file)
@@ -95,16 +95,18 @@ void delete_and_reload_printers(struct tevent_context *ev,
                }
 
                sname = lp_const_servicename(snum);
-               pname = lp_printername(snum);
+               pname = lp_printername(session_info, snum);
 
                /* check printer, but avoid removing non-autoloaded printers */
-               if (!pcap_printername_ok(pname) && lp_autoloaded(snum)) {
+               if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) {
                        DEBUG(3, ("removing stale printer %s\n", pname));
 
                        if (is_printer_published(session_info, session_info,
                                                 msg_ctx,
-                                                NULL, lp_servicename(snum),
-                                                NULL, &pinfo2)) {
+                                                NULL,
+                                                lp_servicename(session_info,
+                                                               snum),
+                                                &pinfo2)) {
                                nt_printer_publish(session_info,
                                                   session_info,
                                                   msg_ctx,
@@ -140,12 +142,13 @@ bool reload_services(struct smbd_server_connection *sconn,
        bool ret;
 
        if (lp_loaded()) {
-               char *fname = lp_configfile();
+               char *fname = lp_configfile(talloc_tos());
                if (file_exist(fname) &&
                    !strcsequal(fname, get_dyn_CONFIGFILE())) {
                        set_dyn_CONFIGFILE(fname);
                        test = False;
                }
+               TALLOC_FREE(fname);
        }
 
        reopen_logs();
@@ -155,7 +158,11 @@ bool reload_services(struct smbd_server_connection *sconn,
 
        lp_killunused(sconn, snumused);
 
-       ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
+       ret = lp_load(get_dyn_CONFIGFILE(),
+                     false, /* global only */
+                     false, /* save defaults */
+                     true,  /* add_ipc */
+                     true); /* initialize globals */
 
        /* perhaps the config filename is now set */
        if (!test) {