s4-smbtorture: remove another incarnation of test_ClosePrinter.
[Samba.git] / source3 / smbd / server_reload.c
blob10f2ac91130ec944ffe8dc2a0869bd59e9b41401
1 /*
2 Unix SMB/CIFS implementation.
3 Main SMB server routines
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Martin Pool 2002
6 Copyright (C) Jelmer Vernooij 2002-2003
7 Copyright (C) Volker Lendecke 1993-2007
8 Copyright (C) Jeremy Allison 1993-2007
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "includes.h"
25 #include "smbd/globals.h"
26 #include "librpc/gen_ndr/messaging.h"
28 /****************************************************************************
29 Reload printers
30 **************************************************************************/
31 void reload_printers(void)
33 int snum;
34 int n_services = lp_numservices();
35 int pnum = lp_servicenumber(PRINTERS_NAME);
36 const char *pname;
38 pcap_cache_reload();
40 /* remove stale printers */
41 for (snum = 0; snum < n_services; snum++) {
42 /* avoid removing PRINTERS_NAME or non-autoloaded printers */
43 if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&
44 lp_autoloaded(snum)))
45 continue;
47 pname = lp_printername(snum);
48 if (!pcap_printername_ok(pname)) {
49 DEBUG(3, ("removing stale printer %s\n", pname));
51 if (is_printer_published(NULL, snum, NULL))
52 nt_printer_publish(NULL, snum, DSPRINT_UNPUBLISH);
53 del_a_printer(pname);
54 lp_killservice(snum);
58 load_printers();
61 /****************************************************************************
62 Reload the services file.
63 **************************************************************************/
65 bool reload_services(bool test)
67 bool ret;
69 if (lp_loaded()) {
70 char *fname = lp_configfile();
71 if (file_exist(fname) &&
72 !strcsequal(fname, get_dyn_CONFIGFILE())) {
73 set_dyn_CONFIGFILE(fname);
74 test = False;
78 reopen_logs();
80 if (test && !lp_file_list_changed())
81 return(True);
83 lp_killunused(conn_snum_used);
85 ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
87 reload_printers();
89 /* perhaps the config filename is now set */
90 if (!test)
91 reload_services(True);
93 reopen_logs();
95 load_interfaces();
97 if (smbd_server_fd() != -1) {
98 set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");
99 set_socket_options(smbd_server_fd(), lp_socket_options());
102 mangle_reset_cache();
103 reset_stat_cache();
105 /* this forces service parameters to be flushed */
106 set_current_service(NULL,0,True);
108 return(ret);