static void smb_conf_updated(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { struct tevent_context *ev_ctx = talloc_get_type_abort(private_data, struct tevent_context); DEBUG(10, ("Got message saying smb.conf was updated. Reloading.\n")); change_to_root_user(); reload_printers(ev_ctx, msg); spoolss_reopen_logs(); }
static void spoolss_sig_hup_handler(struct tevent_context *ev, struct tevent_signal *se, int signum, int count, void *siginfo, void *private_data) { struct messaging_context *msg_ctx = talloc_get_type_abort(private_data, struct messaging_context); change_to_root_user(); DEBUG(1,("Reloading printers after SIGHUP\n")); reload_printers(ev, msg_ctx); spoolss_reopen_logs(); }
BOOL reload_services(BOOL test) { BOOL ret; if (lp_loaded()) { pstring fname; pstrcpy(fname,lp_configfile()); if (file_exist(fname, NULL) && !strcsequal(fname, dyn_CONFIGFILE)) { pstrcpy(dyn_CONFIGFILE, fname); test = False; } } reopen_logs(); if (test && !lp_file_list_changed()) return(True); lp_killunused(conn_snum_used); ret = lp_load(dyn_CONFIGFILE, False, False, True, True); #ifndef _XBOX reload_printers(); #endif /* perhaps the config filename is now set */ if (!test) reload_services(True); reopen_logs(); load_interfaces(); if (smbd_server_fd() != -1) { set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); set_socket_options(smbd_server_fd(), user_socket_options); } mangle_reset_cache(); reset_stat_cache(); /* this forces service parameters to be flushed */ set_current_service(NULL,0,True); return(ret); }
/**************************************************************************** purge stale printers and reload from pre-populated pcap cache **************************************************************************/ void reload_printers_full(struct tevent_context *ev, struct messaging_context *msg_ctx) { struct auth_serversupplied_info *session_info = NULL; int n_services; int pnum; int snum; const char *pname; const char *sname; NTSTATUS status; n_services = lp_numservices(); pnum = lp_servicenumber(PRINTERS_NAME); status = make_session_info_system(talloc_new(NULL), &session_info); if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("Could not create system session_info\n")); /* can't remove stale printers before we * are fully initilized */ return; } /* * Add default config for printers added to smb.conf file and remove * stale printers */ for (snum = 0; snum < n_services; snum++) { /* avoid removing PRINTERS_NAME */ if (snum == pnum) { continue; } /* skip no-printer services */ if (!(lp_snum_ok(snum) && lp_print_ok(snum))) { continue; } sname = lp_const_servicename(snum); pname = lp_printername(snum); /* check printer, but avoid removing non-autoloaded printers */ if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) { struct spoolss_PrinterInfo2 *pinfo2 = NULL; if (is_printer_published(session_info, session_info, msg_ctx, NULL, lp_servicename(snum), &pinfo2)) { nt_printer_publish(session_info, session_info, msg_ctx, pinfo2, DSPRINT_UNPUBLISH); TALLOC_FREE(pinfo2); } nt_printer_remove(session_info, session_info, msg_ctx, pname); } else { DEBUG(8, ("Adding default registry entry for printer " "[%s], if it doesn't exist.\n", sname)); nt_printer_add(session_info, session_info, msg_ctx, sname); } } /* finally, purge old snums */ reload_printers(ev, msg_ctx); TALLOC_FREE(session_info); }