summaryrefslogtreecommitdiff
path: root/source3/param/loadparm.c
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2008-01-16 23:24:44 +0300
committerAlexander Bokovoy <ab@samba.org>2008-01-16 23:24:44 +0300
commitfd03ea4a903b79a0a7894315b3b43fb08108f938 (patch)
tree0dbce899aca9e727977b2a0becbcc78c6c2de6a4 /source3/param/loadparm.c
parente2ffd5110173c6c7d9c15853646988e536331ed0 (diff)
parent60c3ec3fca08b7d36df760cd6093adb5a807afa0 (diff)
downloadsamba-fd03ea4a903b79a0a7894315b3b43fb08108f938.tar.gz
samba-fd03ea4a903b79a0a7894315b3b43fb08108f938.tar.bz2
samba-fd03ea4a903b79a0a7894315b3b43fb08108f938.zip
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
(This used to be commit b01f34141509c90b12003786957790866c286cba)
Diffstat (limited to 'source3/param/loadparm.c')
-rw-r--r--source3/param/loadparm.c128
1 files changed, 80 insertions, 48 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index eaf19b746a..0d3fbbf77c 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -9,6 +9,7 @@
Copyright (C) Alexander Bokovoy 2002
Copyright (C) Stefan (metze) Metzmacher 2002
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
+ Copyright (C) Michael Adam 2008
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
@@ -70,16 +71,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 +101,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 +840,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 +886,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 +1223,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 +1302,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 +1537,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 +2058,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 +3435,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 +3547,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 +3646,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 +3665,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 +3673,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 +3717,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 +3787,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 +5665,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 +5693,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());