[SCM] Samba Shared Repository - branch master updated

Simo Sorce idra at samba.org
Fri Aug 13 10:20:43 MDT 2010


The branch, master has been updated
       via  ca8db7f... s3-smbd: Publish nt printers.
       via  aff002e... s3-smbd: Move rpc services init to smbd parent.
       via  62a2a9e... s3-smbd: Regroup some init functions.
       via  9ab62b7... s3-smbd: Fixed indent.
       via  4a5cef8... s3-loadparm: Added some comments to lp_load_ex calls.
       via  e180390... s3-smbd: Cleanup the order of the init functions.
       via  120bd97... s3-smbd: Make sure the event context is initialized.
      from  2c99eef... s3-build: remove pointless RPC_PARSE_OBJ2.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ca8db7fd63749989dcb3daae0c38b8b788ebdfb8
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Aug 10 13:45:55 2010 +0200

    s3-smbd: Publish nt printers.
    
    Reloading of the printers requires rpc services up and running! The
    first call in reload_services will be skipped.
    
    Signed-off-by: Simo Sorce <idra at samba.org>

commit aff002e829b8169997f7f446959e2f1d5baf3a60
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Aug 10 12:29:27 2010 +0200

    s3-smbd: Move rpc services init to smbd parent.
    
    The move to the parent makes it possible to use an internal rpc pipe
    really early and as we migrated serveral parts of samba to rpc function
    this is required. This should speed up the fork of a smbd a bit cause
    the rpc services are already running.
    
    We still have several problems here which aren't solved. We don't have a
    dependency tree here. For example we have to make sure that the registry
    is initialized before we can use the winreg pipe. The spoolss server
    requires winreg, so we have to start winreg before we can start the
    spoolss server. I'm sure there are more dependencies.
    
    Signed-off-by: Simo Sorce <idra at samba.org>

commit 62a2a9e27f8983717f13dbe3d92b21ed4b9bf22e
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Aug 10 12:28:46 2010 +0200

    s3-smbd: Regroup some init functions.
    
    Signed-off-by: Simo Sorce <idra at samba.org>

commit 9ab62b774f071be83375a4b2544a7e70e147e699
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Aug 9 15:57:38 2010 +0200

    s3-smbd: Fixed indent.
    
    Signed-off-by: Simo Sorce <idra at samba.org>

commit 4a5cef82d8c2a0f35e9c06a0dc262fdb367279a1
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Aug 9 14:50:12 2010 +0200

    s3-loadparm: Added some comments to lp_load_ex calls.
    
    Signed-off-by: Simo Sorce <idra at samba.org>

commit e18039062c77947dd4e6d1c841a7c587a85ab8ce
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Aug 9 14:49:08 2010 +0200

    s3-smbd: Cleanup the order of the init functions.
    
    Signed-off-by: Simo Sorce <idra at samba.org>

commit 120bd9775a286e173a22f7c90b61e107887122e4
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Aug 9 14:47:55 2010 +0200

    s3-smbd: Make sure the event context is initialized.
    
    Signed-off-by: Simo Sorce <idra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/param/loadparm.c     |   19 ++++----
 source3/smbd/files.c         |    5 +-
 source3/smbd/process.c       |   43 +------------------
 source3/smbd/server.c        |   95 ++++++++++++++++++++++++++++++++++--------
 source3/smbd/server_reload.c |    2 +-
 5 files changed, 92 insertions(+), 72 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 90699c0..e5c6038 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -9296,18 +9296,19 @@ bool lp_load(const char *pszFname,
 			  save_defaults,
 			  add_ipc,
 			  initialize_globals,
-			  true, false);
+			  true,   /* allow_include_registry */
+			  false); /* allow_registry_shares*/
 }
 
 bool lp_load_initial_only(const char *pszFname)
 {
 	return lp_load_ex(pszFname,
-			  true,
-			  false,
-			  false,
-			  true,
-			  false,
-			  false);
+			  true,   /* global only */
+			  false,  /* save_defaults */
+			  false,  /* add_ipc */
+			  true,   /* initialize_globals */
+			  false,  /* allow_include_registry */
+			  false); /* allow_registry_shares*/
 }
 
 bool lp_load_with_registry_shares(const char *pszFname,
@@ -9321,8 +9322,8 @@ bool lp_load_with_registry_shares(const char *pszFname,
 			  save_defaults,
 			  add_ipc,
 			  initialize_globals,
-			  true,
-			  true);
+			  true,  /* allow_include_registry */
+			  true); /* allow_registry_shares*/
 }
 
 /***************************************************************************
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 7ad5ce3..9a7c5b0 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -189,8 +189,9 @@ void file_init(void)
 		real_max_open_files = 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES;
 
 	if(real_max_open_files != request_max_open_files) {
-		DEBUG(1,("file_init: Information only: requested %d \
-open files, %d are available.\n", request_max_open_files, real_max_open_files));
+		DEBUG(1, ("file_init: Information only: requested %d "
+			  "open files, %d are available.\n",
+			  request_max_open_files, real_max_open_files));
 	}
 
 	SMB_ASSERT(real_max_open_files > 100);
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index adfcad1..61db712 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -20,22 +20,8 @@
 
 #include "includes.h"
 #include "smbd/globals.h"
-#include "../librpc/gen_ndr/srv_dfs.h"
-#include "../librpc/gen_ndr/srv_dssetup.h"
-#include "../librpc/gen_ndr/srv_echo.h"
-#include "../librpc/gen_ndr/srv_eventlog.h"
-#include "../librpc/gen_ndr/srv_initshutdown.h"
-#include "../librpc/gen_ndr/srv_lsa.h"
-#include "../librpc/gen_ndr/srv_netlogon.h"
-#include "../librpc/gen_ndr/srv_ntsvcs.h"
-#include "../librpc/gen_ndr/srv_samr.h"
-#include "../librpc/gen_ndr/srv_spoolss.h"
-#include "../librpc/gen_ndr/srv_srvsvc.h"
-#include "../librpc/gen_ndr/srv_svcctl.h"
-#include "../librpc/gen_ndr/srv_winreg.h"
-#include "../librpc/gen_ndr/srv_wkssvc.h"
+#include "librpc/gen_ndr/netlogon.h"
 #include "librpc/gen_ndr/messaging.h"
-#include "printing/nt_printing_migrate.h"
 
 extern bool global_machine_password_needs_changing;
 
@@ -2868,13 +2854,6 @@ fail:
 	return false;
 }
 
-static bool spoolss_init_cb(void *ptr)
-{
-	struct messaging_context *msg_ctx = talloc_get_type_abort(
-		ptr, struct messaging_context);
-	return nt_printing_tdb_migrate(msg_ctx);
-}
-
 /****************************************************************************
  Process commands from the client
 ****************************************************************************/
@@ -2889,7 +2868,6 @@ void smbd_process(struct smbd_server_connection *sconn)
 	struct tsocket_address *remote_address = NULL;
 	const char *remaddr = NULL;
 	int ret;
-	struct rpc_srv_callbacks spoolss_cb;
 
 	if (lp_maxprotocol() == PROTOCOL_SMB2 &&
 	    lp_security() != SEC_SHARE &&
@@ -3127,25 +3105,6 @@ void smbd_process(struct smbd_server_connection *sconn)
 		exit_server("failed to create smbd_server_connection fde");
 	}
 
-	/*
-	 * Initialize spoolss with an init function to convert printers first.
-	 * static_init_rpc will try to initialize the spoolss server too but you
-	 * can't register it twice.
-	 */
-	spoolss_cb.init = spoolss_init_cb;
-	spoolss_cb.shutdown = NULL;
-	spoolss_cb.private_data = sconn->msg_ctx;
-
-	if (!NT_STATUS_IS_OK(rpc_winreg_init(NULL))) {
-		exit(1);
-	}
-
-	if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
-		exit(1);
-	}
-
-	static_init_rpc;
-
 	TALLOC_FREE(frame);
 
 	while (True) {
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 1a5d81f..1c614da 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -29,6 +29,23 @@
 #include "libcli/auth/schannel.h"
 #include "secrets.h"
 
+#include "../librpc/gen_ndr/srv_dfs.h"
+#include "../librpc/gen_ndr/srv_dssetup.h"
+#include "../librpc/gen_ndr/srv_echo.h"
+#include "../librpc/gen_ndr/srv_eventlog.h"
+#include "../librpc/gen_ndr/srv_initshutdown.h"
+#include "../librpc/gen_ndr/srv_lsa.h"
+#include "../librpc/gen_ndr/srv_netlogon.h"
+#include "../librpc/gen_ndr/srv_ntsvcs.h"
+#include "../librpc/gen_ndr/srv_samr.h"
+#include "../librpc/gen_ndr/srv_spoolss.h"
+#include "../librpc/gen_ndr/srv_srvsvc.h"
+#include "../librpc/gen_ndr/srv_svcctl.h"
+#include "../librpc/gen_ndr/srv_winreg.h"
+#include "../librpc/gen_ndr/srv_wkssvc.h"
+
+#include "printing/nt_printing_migrate.h"
+
 static_decl_rpc;
 
 #ifdef WITH_DFS
@@ -767,6 +784,13 @@ static bool init_structs(void )
 	return True;
 }
 
+static bool spoolss_init_cb(void *ptr)
+{
+	struct messaging_context *msg_ctx = talloc_get_type_abort(
+		ptr, struct messaging_context);
+	return nt_printing_tdb_migrate(msg_ctx);
+}
+
 /****************************************************************************
  main program.
 ****************************************************************************/
@@ -815,6 +839,10 @@ extern void build_options(bool screen);
 	TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
 	NTSTATUS status;
 	uint64_t unique_id;
+	struct rpc_srv_callbacks spoolss_cb;
+
+	/* Initialize the event context, it will panic on error */
+	smbd_event_context();
 
 	smbd_init_globals();
 
@@ -873,8 +901,6 @@ extern void build_options(bool screen);
 	setluid(0);
 #endif
 
-	sec_init();
-
 	set_remote_machine_name("smbd", False);
 
 	if (interactive && (DEBUGLEVEL >= 9)) {
@@ -890,9 +916,11 @@ extern void build_options(bool screen);
            client problems at a later date. (tridge) */
 	generate_random_buffer(NULL, 0);
 
+	/* get initial effective uid and gid */
+	sec_init();
+
 	/* make absolutely sure we run as root - to handle cases where people
 	   are crazy enough to have it setuid */
-
 	gain_root_privilege();
 	gain_root_group_privilege();
 
@@ -927,8 +955,6 @@ extern void build_options(bool screen);
 	   so set our umask to 0 */
 	umask(0);
 
-	init_sec_ctx();
-
 	reopen_logs();
 
 	DEBUG(0,("smbd version %s started.\n", samba_version_string()));
@@ -950,11 +976,23 @@ extern void build_options(bool screen);
 		exit(1);
 	}
 
+	/* Init the security context and global current_user */
+	init_sec_ctx();
+
 	if (smbd_messaging_context() == NULL)
 		exit(1);
 
-	if (!reload_services(smbd_messaging_context(), False))
-		return(-1);	
+	/*
+	 * Reloading of the printers will not work here as we don't have a
+	 * server info and rpc services set up. It will be called later.
+	 */
+	if (!reload_services(smbd_messaging_context(), False)) {
+		exit(1);
+	}
+
+	/* ...NOTE... Log files are working from this point! */
+
+	DEBUG(3,("loaded services\n"));
 
 	init_structs();
 
@@ -973,8 +1011,6 @@ extern void build_options(bool screen);
 	}
 #endif
 
-	DEBUG(3,( "loaded services\n"));
-
 	if (!is_daemon && !is_a_socket(0)) {
 		if (!interactive)
 			DEBUG(0,("standard input is not a socket, assuming -D option\n"));
@@ -1080,33 +1116,56 @@ extern void build_options(bool screen);
 	if (!W_ERROR_IS_OK(registry_init_full()))
 		exit(1);
 
+	if (!print_backend_init(smbd_messaging_context()))
+		exit(1);
+
 #if 0
 	if (!init_svcctl_db())
                 exit(1);
 #endif
 
+	/* Open the share_info.tdb here, so we don't have to open
+	   after the fork on every single connection.  This is a small
+	   performance improvment and reduces the total number of system
+	   fds used. */
+	if (!share_info_db_init()) {
+		DEBUG(0,("ERROR: failed to load share info db.\n"));
+		exit(1);
+	}
+
 	if (!init_system_info()) {
 		DEBUG(0,("ERROR: failed to setup system user info.\n"));
 		return -1;
 	}
 
-	if (!print_backend_init(smbd_messaging_context()))
-		exit(1);
-
 	if (!init_guest_info()) {
 		DEBUG(0,("ERROR: failed to setup guest info.\n"));
 		return -1;
 	}
 
-	/* Open the share_info.tdb here, so we don't have to open
-	   after the fork on every single connection.  This is a small
-	   performance improvment and reduces the total number of system
-	   fds used. */
-	if (!share_info_db_init()) {
-		DEBUG(0,("ERROR: failed to load share info db.\n"));
+	/*
+	 * Initialize spoolss with an init function to convert printers first.
+	 * static_init_rpc will try to initialize the spoolss server too but you
+	 * can't register it twice.
+	 */
+	spoolss_cb.init = spoolss_init_cb;
+	spoolss_cb.shutdown = NULL;
+	spoolss_cb.private_data = smbd_server_conn->msg_ctx;
+
+	/* Spoolss depends on a winreg pipe, so start it first. */
+	if (!NT_STATUS_IS_OK(rpc_winreg_init(NULL))) {
+		exit(1);
+	}
+
+	if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
 		exit(1);
 	}
 
+	static_init_rpc;
+
+	/* Publish nt printers, this requires a working winreg pipe */
+	reload_printers(smbd_messaging_context());
+
 	/* only start the background queue daemon if we are 
 	   running as a daemon -- bad things will happen if
 	   smbd is launched via inetd and we fork a copy of 
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index 7512f8e..e1d563d 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -44,7 +44,7 @@ void reload_printers(struct messaging_context *msg_ctx)
 
 	status = make_server_info_system(talloc_tos(), &server_info);
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0, ("reload_printers: "
+		DEBUG(3, ("reload_printers: "
 			  "Could not create system server_info\n"));
 		/* can't remove stale printers before we
 		 * are fully initilized */


-- 
Samba Shared Repository


More information about the samba-cvs mailing list