[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-test-1431-g5680181

Michael Adam obnox at samba.org
Wed Jan 16 16:10:40 GMT 2008


The branch, v3-2-test has been updated
       via  56801810253ae870437f694947f58c27661cef9b (commit)
       via  c5a7d421c512a6221b0300549d7b5de0368d252e (commit)
       via  d8a7c3ec8e2bd548509178f138d00a3b57119d10 (commit)
       via  9f69efe954cde6c6cce4283ba35a553ca980c347 (commit)
       via  eec3248ef90fbfe6e048394c875173b164a8b439 (commit)
       via  77b33cf34c2aec6673dfab3962733a60a60d126a (commit)
       via  a103509a467bf6a93fbb21ec5e64456c5f086d6c (commit)
       via  9e11768256623636e69eda67b3bb888426f9ab84 (commit)
      from  175662b5bbb5c8ecd81a60539f5846a938c26a3a (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 56801810253ae870437f694947f58c27661cef9b
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 17:09:07 2008 +0100

    Remove special semantics of "include = registry" from loadparm.c
    
    This is now replaced by "config backend = registry".
    
    Michael

commit c5a7d421c512a6221b0300549d7b5de0368d252e
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 17:05:38 2008 +0100

    Use lp_config_backend_is_registry() instead of lp_include_registry_globals().
    
    Michael

commit d8a7c3ec8e2bd548509178f138d00a3b57119d10
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 17:03:21 2008 +0100

    Add utility function lp_config_backend_is_registry().
    
    So external callers can determine if we are running on
    registry config without knowing the internals.
    
    Michael

commit 9f69efe954cde6c6cce4283ba35a553ca980c347
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 16:58:29 2008 +0100

    Initialise Globals.ConfigBackend from global var config_backend.
    
    and use lp_config_backend() instead of config_backend.
    
    Michael

commit eec3248ef90fbfe6e048394c875173b164a8b439
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 16:40:59 2008 +0100

    Add handling of [homes] and [printers] via registry shares.
    
    Now homes and printers shares can be accessed through the
    registry meachanism on demand in pure registry configurations
    with "config backend = registry" without the need to
    have a special handler for these two.
    
    Michael

commit 77b33cf34c2aec6673dfab3962733a60a60d126a
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 16:18:28 2008 +0100

    Add config parameter "config backend = registry".
    
    This adds a new config parameter "config backend" that can have
    values "file" (default) and "registry". When lp_load() encounters
    a "config backend = registry", then all config read up to that
    point is discarded and globals are read from registry.
    
    This is done in suche a way that as with "config file",
    there is no way back to non-registry config during the
    lifetime of a process: The file_list_changed mechanism
    does not look at files anymore once config backend is
    set to registry. This is modelled after the behaviour
    of the "config file" option.
    
    Note that only the global section is read by lp_load().
    The shares are handled by the registry shares mechanism,
    thus allowing for a smaller memory footprint since
    share definitions are read on demand.
    
    This new parameter is intended as a substitute of the
    previously installed special semantics of "include = registry"
    which allows for messed up mixed configurations.
    This parameter (which has not yet been released) will
    vanish next.
    
    Michael

commit a103509a467bf6a93fbb21ec5e64456c5f086d6c
Author: Michael Adam <obnox at samba.org>
Date:   Tue Jan 15 13:46:02 2008 +0100

    Add "MSDFS options" separator to parm_table.
    
    Michael

commit 9e11768256623636e69eda67b3bb888426f9ab84
Author: Michael Adam <obnox at samba.org>
Date:   Tue Jan 15 13:44:51 2008 +0100

    Re-order an option block in parm_table to re-unite the misc options.
    
    Michael

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

Summary of changes:
 source/lib/netapi/serverinfo.c |    2 +-
 source/libnet/libnet_join.c    |    4 +-
 source/param/loadparm.c        |  127 +++++++++++++++++++++++++---------------
 source/smbd/service.c          |   84 ++++++++++++++------------
 4 files changed, 127 insertions(+), 90 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/netapi/serverinfo.c b/source/lib/netapi/serverinfo.c
index 67680ba..6cd0746 100644
--- a/source/lib/netapi/serverinfo.c
+++ b/source/lib/netapi/serverinfo.c
@@ -167,7 +167,7 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx,
 		return WERR_INVALID_PARAM;
 	}
 
-	if (!lp_include_registry_globals()) {
+	if (!lp_config_backend_is_registry()) {
 		return WERR_NOT_SUPPORTED;
 	}
 
diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c
index af7f9a6..a9978ba 100644
--- a/source/libnet/libnet_join.c
+++ b/source/libnet/libnet_join.c
@@ -1041,7 +1041,7 @@ static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx,
 		return WERR_INVALID_PARAM;
 	}
 
-	if (r->in.modify_config && !lp_include_registry_globals()) {
+	if (r->in.modify_config && !lp_config_backend_is_registry()) {
 		return WERR_NOT_SUPPORTED;
 	}
 
@@ -1350,7 +1350,7 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
 static WERROR libnet_unjoin_pre_processing(TALLOC_CTX *mem_ctx,
 					   struct libnet_UnjoinCtx *r)
 {
-	if (r->in.modify_config && !lp_include_registry_globals()) {
+	if (r->in.modify_config && !lp_config_backend_is_registry()) {
 		return WERR_NOT_SUPPORTED;
 	}
 
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index eaf19b7..4fc8b89 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -70,16 +70,12 @@ extern userdom_struct current_user_info;
 #define HOMES_NAME "homes"
 #endif
 
-/* the special value for the include parameter
- * to be interpreted not as a file name but to
- * trigger loading of the global smb.conf options
- * from registry. */
-#ifndef INCLUDE_REGISTRY_NAME
-#define INCLUDE_REGISTRY_NAME "registry"
-#endif
-
 static int regdb_last_seqnum = 0;
-static bool include_registry_globals = False;
+
+#define CONFIG_BACKEND_FILE 0
+#define CONFIG_BACKEND_REGISTRY 1
+
+static int config_backend = CONFIG_BACKEND_FILE;
 
 /* some helpful bits */
 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
@@ -104,6 +100,7 @@ struct _param_opt_struct {
  * This structure describes global (ie., server-wide) parameters.
  */
 typedef struct {
+	int ConfigBackend;
 	char *smb_ports;
 	char *dos_charset;
 	char *unix_charset;
@@ -842,6 +839,14 @@ static const struct enum_list enum_map_to_guest[] = {
 	{-1, NULL}
 };
 
+/* Config backend options */
+
+static const struct enum_list enum_config_backend[] = {
+	{CONFIG_BACKEND_FILE, "file"},
+	{CONFIG_BACKEND_REGISTRY, "registry"},
+	{-1, NULL}
+};
+
 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
  *
  * The FLAG_HIDE is explicit. Paramters set this way do NOT appear in any edit
@@ -880,6 +885,8 @@ static struct parm_struct parm_table[] = {
 	{"interfaces", P_LIST, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD}, 
 	{"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD}, 
 
+	{"config backend", P_ENUM, P_GLOBAL, &Globals.ConfigBackend, NULL, enum_config_backend, FLAG_ADVANCED},
+
 	{N_("Security Options"), P_SEP, P_SEPARATOR}, 
 
 	{"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD}, 
@@ -1215,14 +1222,14 @@ static struct parm_struct parm_table[] = {
 	{"ldap page size", P_INTEGER, P_GLOBAL, &Globals.ldap_page_size, NULL, NULL, FLAG_ADVANCED},
 	{"ldap user suffix", P_STRING, P_GLOBAL, &Globals.szLdapUserSuffix, NULL, NULL, FLAG_ADVANCED}, 
 
+	{N_("EventLog Options"), P_SEP, P_SEPARATOR}, 
+	{"eventlog list",  P_LIST, P_GLOBAL, &Globals.szEventLogs, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE}, 
+
 	{N_("Miscellaneous Options"), P_SEP, P_SEPARATOR}, 
 	{"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, FLAG_ADVANCED}, 
 	{"change share command", P_STRING, P_GLOBAL, &Globals.szChangeShareCommand, NULL, NULL, FLAG_ADVANCED}, 
 	{"delete share command", P_STRING, P_GLOBAL, &Globals.szDeleteShareCommand, NULL, NULL, FLAG_ADVANCED}, 
 
-	{N_("EventLog Options"), P_SEP, P_SEPARATOR}, 
-	{"eventlog list",  P_LIST, P_GLOBAL, &Globals.szEventLogs, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE}, 
-	
 	{"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE}, 
 	{"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
 	{"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
@@ -1294,6 +1301,8 @@ static struct parm_struct parm_table[] = {
 	{"vfs object", P_LIST, P_LOCAL, &sDefault.szVfsObjects, NULL, NULL, FLAG_HIDE}, 
 
 
+	{N_("MSDFS options"), P_SEP, P_SEPARATOR},
+
 	{"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, 
 	{"msdfs proxy", P_STRING, P_LOCAL, &sDefault.szMSDfsProxy, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, 
 	{"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_ADVANCED}, 
@@ -1527,6 +1536,8 @@ static void init_globals(bool first_time_only)
 	Globals.bLoadPrinters = True;
 	Globals.PrintcapCacheTime = 750; 	/* 12.5 minutes */
 
+	Globals.ConfigBackend = config_backend;
+
 	/* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
 	/* Discovered by 2 days of pain by Don McCall @ HP :-). */
 	Globals.max_xmit = 0x4104;
@@ -2046,6 +2057,7 @@ FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
+FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend);
 
 FN_LOCAL_STRING(lp_preexec, szPreExec)
 FN_LOCAL_STRING(lp_postexec, szPostExec)
@@ -3422,8 +3434,6 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *))
 	char * valstr;
 	struct registry_value *value = NULL;
 
-	include_registry_globals = True;
-
 	ZERO_STRUCT(data);
 
 	reg_tdb = lp_regdb_open();
@@ -3536,8 +3546,6 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *))
 		smb_panic("Failed to create talloc context!");
 	}
 
-	include_registry_globals = True;
-
 	if (!registry_init_regdb()) {
 		DEBUG(1, ("Error initializing the registry.\n"));
 		goto done;
@@ -3637,9 +3645,12 @@ static void add_to_file_list(const char *fname, const char *subfname)
 	}
 }
 
-bool lp_include_registry_globals(void)
+/**
+ * Utility function for outsiders to check if we're running on registry.
+ */
+bool lp_config_backend_is_registry(void)
 {
-	return include_registry_globals;
+	return (lp_config_backend() == CONFIG_BACKEND_REGISTRY);
 }
 
 /*******************************************************************
@@ -3653,7 +3664,7 @@ bool lp_file_list_changed(void)
 
  	DEBUG(6, ("lp_file_list_changed()\n"));
 
-	if (include_registry_globals) {
+	if (lp_config_backend() == CONFIG_BACKEND_REGISTRY) {
 		reg_tdb = lp_regdb_open();
 		if (reg_tdb && (regdb_last_seqnum != tdb_get_seqnum(reg_tdb->tdb)))
 		{
@@ -3661,6 +3672,15 @@ bool lp_file_list_changed(void)
 				    regdb_last_seqnum, tdb_get_seqnum(reg_tdb->tdb)));
 			TALLOC_FREE(reg_tdb);
 			return true;
+		} else {
+			/*
+			 * Don't check files when config_backend is registry.
+			 * Remove this to obtain checking of files even with
+			 * registry config backend. That would enable switching
+			 * off registry configuration by changing smb.conf even
+			 * without restarting smbd.
+			 */
+			return false;
 		}
 	}
 
@@ -3696,6 +3716,7 @@ bool lp_file_list_changed(void)
 	return (False);
 }
 
+
 /***************************************************************************
  Run standard_sub_basic on netbios name... needed because global_myname
  is not accessed through any lp_ macro.
@@ -3765,17 +3786,6 @@ static bool handle_include(int snum, const char *pszParmValue, char **ptr)
 {
 	char *fname;
 
-	if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
-		if (bInGlobalSection) {
-			return process_registry_globals(do_parameter);
-		}
-		else {
-			DEBUG(1, ("\"include = registry\" only effective "
-				  "in %s section\n", GLOBAL_NAME));
-			return false;
-		}
-	}
-
 	fname = alloc_sub_basic(get_current_username(),
 				current_user_info.domain,
 				pszParmValue);
@@ -5654,15 +5664,6 @@ bool lp_load(const char *pszFname,
 	bool bRetval;
 	param_opt_struct *data, *pdata;
 
-	n2 = alloc_sub_basic(get_current_username(),
-				current_user_info.domain,
-				pszFname);
-	if (!n2) {
-		smb_panic("lp_load: out of memory");
-	}
-
-	add_to_file_list(pszFname, n2);
-
 	bRetval = False;
 
 	DEBUG(3, ("lp_load: refreshing parameters\n"));
@@ -5691,17 +5692,47 @@ bool lp_load(const char *pszFname,
 		Globals.param_opt = NULL;
 	}
 
-	/* We get sections first, so have to start 'behind' to make up */
-	iServiceIndex = -1;
-	bRetval = pm_process(n2, do_section, do_parameter);
-	SAFE_FREE(n2);
+	if (lp_config_backend() == CONFIG_BACKEND_FILE) {
+		n2 = alloc_sub_basic(get_current_username(),
+					current_user_info.domain,
+					pszFname);
+		if (!n2) {
+			smb_panic("lp_load: out of memory");
+		}
+
+		add_to_file_list(pszFname, n2);
 
-	/* finish up the last section */
-	DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
-	if (bRetval) {
-		if (iServiceIndex >= 0) {
-			bRetval = service_ok(iServiceIndex);
+		/* We get sections first, so have to start 'behind' to make up */
+		iServiceIndex = -1;
+		bRetval = pm_process(n2, do_section, do_parameter);
+		SAFE_FREE(n2);
+
+		/* finish up the last section */
+		DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
+		if (bRetval) {
+			if (iServiceIndex >= 0) {
+				bRetval = service_ok(iServiceIndex);
+			}
+		}
+
+		if (lp_config_backend() == CONFIG_BACKEND_REGISTRY) {
+			/*
+			 * We need to use this extra global variable here to
+			 * survive restart: init_globals usese this as a default
+			 * for ConfigBackend. Otherwise, init_globals would
+			 *  send us into an endless loop here.
+			 */
+			config_backend = CONFIG_BACKEND_REGISTRY;
+			/* start over */
+			return lp_load(pszFname, global_only, save_defaults,
+				       add_ipc, initialize_globals);
 		}
+	} else if (lp_config_backend() == CONFIG_BACKEND_REGISTRY) {
+		bRetval = process_registry_globals(do_parameter);
+	} else {
+		DEBUG(0, ("Illegal config  backend given: %d\n",
+			  lp_config_backend()));
+		bRetval = false;
 	}
 
 	lp_add_auto_services(lp_auto_services());
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 2588a66..ed8061e 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -219,44 +219,6 @@ bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir)
 	return(True);
 }
 
-/****************************************************************************
- Add a home service. Returns the new service number or -1 if fail.
-****************************************************************************/
-
-int add_home_service(const char *service, const char *username, const char *homedir)
-{
-	int iHomeService;
-
-	if (!service || !homedir)
-		return -1;
-
-	if ((iHomeService = lp_servicenumber(HOMES_NAME)) < 0)
-		return -1;
-
-	/*
-	 * If this is a winbindd provided username, remove
-	 * the domain component before adding the service.
-	 * Log a warning if the "path=" parameter does not
-	 * include any macros.
-	 */
-
-	{
-		const char *p = strchr(service,*lp_winbind_separator());
-
-		/* We only want the 'user' part of the string */
-		if (p) {
-			service = p + 1;
-		}
-	}
-
-	if (!lp_add_home(service, iHomeService, username, homedir)) {
-		return -1;
-	}
-	
-	return lp_servicenumber(service);
-
-}
-
 static int load_registry_service(const char *servicename)
 {
 	struct registry_key *key;
@@ -348,6 +310,47 @@ void load_registry_shares(void)
 	return;
 }
 
+/****************************************************************************
+ Add a home service. Returns the new service number or -1 if fail.
+****************************************************************************/
+
+int add_home_service(const char *service, const char *username, const char *homedir)
+{
+	int iHomeService;
+
+	if (!service || !homedir)
+		return -1;
+
+	if ((iHomeService = lp_servicenumber(HOMES_NAME)) < 0) {
+		if ((iHomeService = load_registry_service(HOMES_NAME)) < 0) {
+			return -1;
+		}
+	}
+
+	/*
+	 * If this is a winbindd provided username, remove
+	 * the domain component before adding the service.
+	 * Log a warning if the "path=" parameter does not
+	 * include any macros.
+	 */
+
+	{
+		const char *p = strchr(service,*lp_winbind_separator());
+
+		/* We only want the 'user' part of the string */
+		if (p) {
+			service = p + 1;
+		}
+	}
+
+	if (!lp_add_home(service, iHomeService, username, homedir)) {
+		return -1;
+	}
+	
+	return lp_servicenumber(service);
+
+}
+
 /**
  * Find a service entry.
  *
@@ -386,7 +389,10 @@ int find_service(fstring service)
 	if (iService < 0) {
 		int iPrinterService;
 
-		if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) >= 0) {
+		if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) < 0) {
+			iPrinterService = load_registry_service(PRINTERS_NAME);
+		}
+		if (iPrinterService) {
 			DEBUG(3,("checking whether %s is a valid printer name...\n", service));
 			if (pcap_printername_ok(service)) {
 				DEBUG(3,("%s is a valid printer name\n", service));


-- 
Samba Shared Repository


More information about the samba-cvs mailing list