s3:smbd split reload services/printers functions from server.c
authorAndrew Bartlett <abartlet@samba.org>
Thu, 27 May 2010 05:18:58 +0000 (07:18 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 28 May 2010 16:08:26 +0000 (18:08 +0200)
This helps vfstest, as it previously had duplicate copies of these
functions.

Andrew Bartlett

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/Makefile.in
source3/smbd/server.c
source3/smbd/server_reload.c [new file with mode: 0644]
source3/torture/vfstest.c

index 36380b5cc7fc5a7618f8a8ee7a1a0150267338b8..2bbb3c525033bc49570f4a76af0c2389b9956660 100644 (file)
@@ -780,7 +780,8 @@ SMBD_OBJ_MAIN = smbd/server.o smbd/server_exit.o
 
 BUILDOPT_OBJ = smbd/build_options.o
 
-SMBD_OBJ_SRV = smbd/files.o smbd/connection.o \
+SMBD_OBJ_SRV = smbd/server_reload.o \
+              smbd/files.o smbd/connection.o \
               smbd/utmp.o smbd/session.o smbd/map_username.o \
                smbd/dfree.o smbd/dir.o smbd/password.o smbd/conn.o \
               smbd/share_access.o smbd/fileio.o \
index 80c5fba25fdfdb0c55aafc9c511ce32c5299322e..0e3ec1d033ae38d1f87002eef9d1f1c44f59831a 100644 (file)
@@ -766,88 +766,6 @@ static void smbd_parent_loop(struct smbd_parent_context *parent)
 /* NOTREACHED  return True; */
 }
 
-/****************************************************************************
- Reload printers
-**************************************************************************/
-void reload_printers(void)
-{
-       int snum;
-       int n_services = lp_numservices();
-       int pnum = lp_servicenumber(PRINTERS_NAME);
-       const char *pname;
-
-       pcap_cache_reload();
-
-       /* remove stale printers */
-       for (snum = 0; snum < n_services; snum++) {
-               /* avoid removing PRINTERS_NAME or non-autoloaded printers */
-               if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&
-                                     lp_autoloaded(snum)))
-                       continue;
-
-               pname = lp_printername(snum);
-               if (!pcap_printername_ok(pname)) {
-                       DEBUG(3, ("removing stale printer %s\n", pname));
-
-                       if (is_printer_published(NULL, snum, NULL))
-                               nt_printer_publish(NULL, snum, DSPRINT_UNPUBLISH);
-                       del_a_printer(pname);
-                       lp_killservice(snum);
-               }
-       }
-
-       load_printers();
-}
-
-/****************************************************************************
- Reload the services file.
-**************************************************************************/
-
-bool reload_services(bool test)
-{
-       bool ret;
-
-       if (lp_loaded()) {
-               char *fname = lp_configfile();
-               if (file_exist(fname) &&
-                   !strcsequal(fname, get_dyn_CONFIGFILE())) {
-                       set_dyn_CONFIGFILE(fname);
-                       test = False;
-               }
-       }
-
-       reopen_logs();
-
-       if (test && !lp_file_list_changed())
-               return(True);
-
-       lp_killunused(conn_snum_used);
-
-       ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
-
-       reload_printers();
-
-       /* 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(), lp_socket_options());
-       }
-
-       mangle_reset_cache();
-       reset_stat_cache();
-
-       /* this forces service parameters to be flushed */
-       set_current_service(NULL,0,True);
-
-       return(ret);
-}
 
 /****************************************************************************
  Initialise connect, service and file structs.
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
new file mode 100644 (file)
index 0000000..10f2ac9
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+   Unix SMB/CIFS implementation.
+   Main SMB server routines
+   Copyright (C) Andrew Tridgell               1992-1998
+   Copyright (C) Martin Pool                   2002
+   Copyright (C) Jelmer Vernooij               2002-2003
+   Copyright (C) Volker Lendecke               1993-2007
+   Copyright (C) Jeremy Allison                        1993-2007
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "smbd/globals.h"
+#include "librpc/gen_ndr/messaging.h"
+
+/****************************************************************************
+ Reload printers
+**************************************************************************/
+void reload_printers(void)
+{
+       int snum;
+       int n_services = lp_numservices();
+       int pnum = lp_servicenumber(PRINTERS_NAME);
+       const char *pname;
+
+       pcap_cache_reload();
+
+       /* remove stale printers */
+       for (snum = 0; snum < n_services; snum++) {
+               /* avoid removing PRINTERS_NAME or non-autoloaded printers */
+               if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&
+                                     lp_autoloaded(snum)))
+                       continue;
+
+               pname = lp_printername(snum);
+               if (!pcap_printername_ok(pname)) {
+                       DEBUG(3, ("removing stale printer %s\n", pname));
+
+                       if (is_printer_published(NULL, snum, NULL))
+                               nt_printer_publish(NULL, snum, DSPRINT_UNPUBLISH);
+                       del_a_printer(pname);
+                       lp_killservice(snum);
+               }
+       }
+
+       load_printers();
+}
+
+/****************************************************************************
+ Reload the services file.
+**************************************************************************/
+
+bool reload_services(bool test)
+{
+       bool ret;
+
+       if (lp_loaded()) {
+               char *fname = lp_configfile();
+               if (file_exist(fname) &&
+                   !strcsequal(fname, get_dyn_CONFIGFILE())) {
+                       set_dyn_CONFIGFILE(fname);
+                       test = False;
+               }
+       }
+
+       reopen_logs();
+
+       if (test && !lp_file_list_changed())
+               return(True);
+
+       lp_killunused(conn_snum_used);
+
+       ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
+
+       reload_printers();
+
+       /* 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(), lp_socket_options());
+       }
+
+       mangle_reset_cache();
+       reset_stat_cache();
+
+       /* this forces service parameters to be flushed */
+       set_current_service(NULL,0,True);
+
+       return(ret);
+}
index d5237827d8e77262ba51ca74e69cb09a9717f689..c885163729ab5b0269c92f4f164a30ca7712dec7 100644 (file)
@@ -422,62 +422,6 @@ int smbd_server_fd(void)
                return server_fd;
 }
 
-void reload_printers(void)
-{
-       return;
-}
-
-/****************************************************************************
- Reload the services file.
-**************************************************************************/
-
-bool reload_services(bool test)
-{
-       bool ret;
-
-       if (lp_loaded()) {
-               const char *fname = lp_configfile();
-               if (file_exist(fname) &&
-                   !strcsequal(fname, get_dyn_CONFIGFILE())) {
-                       set_dyn_CONFIGFILE(fname);
-                       test = False;
-               }
-       }
-
-       reopen_logs();
-
-       if (test && !lp_file_list_changed())
-               return(True);
-
-       lp_killunused(conn_snum_used);
-
-       ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
-
-       /* 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(),
-                                          lp_socket_options());
-               }
-       }
-
-       mangle_reset_cache();
-       reset_stat_cache();
-
-       /* this forces service parameters to be flushed */
-       set_current_service(NULL,0,True);
-
-       return (ret);
-}
-
 struct event_context *smbd_event_context(void)
 {
        static struct event_context *ctx;