summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-08 17:25:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:05:44 -0500
commit2461a4f14b21ac741c6da62b68ab929336f0184d (patch)
treed7c3ec021b9e7e0e8a173f7e7ad64cbb9604640f /source4/param
parent98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 (diff)
downloadsamba-2461a4f14b21ac741c6da62b68ab929336f0184d.tar.gz
samba-2461a4f14b21ac741c6da62b68ab929336f0184d.tar.bz2
samba-2461a4f14b21ac741c6da62b68ab929336f0184d.zip
r25037: Start passing the context around.
(This used to be commit 88c72ac75fed673f7bfb65bf633f352f231c90a3)
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/loadparm.c356
-rw-r--r--source4/param/param.h1
2 files changed, 183 insertions, 174 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 61b1aafbf4..18a1e22d6c 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -578,165 +578,6 @@ struct parm_struct *lp_parm_table(void)
return parm_table;
}
-/***************************************************************************
- Initialise the global parameter structure.
-***************************************************************************/
-static void init_globals(void)
-{
- int i;
- char *myname;
-
- DEBUG(3, ("Initialising global parameters\n"));
-
- for (i = 0; parm_table[i].label; i++) {
- if ((parm_table[i].type == P_STRING ||
- parm_table[i].type == P_USTRING) &&
- parm_table[i].ptr &&
- !(parm_table[i].flags & FLAG_CMDLINE)) {
- string_set(talloc_autofree_context(),
- (char **)parm_table[i].ptr, "");
- }
- }
-
- lp_do_global_parameter("config file", dyn_CONFIGFILE);
-
- lp_do_global_parameter("share backend", "classic");
-
- lp_do_global_parameter("server role", "standalone");
-
- /* options that can be set on the command line must be initialised via
- the slower lp_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
-#ifdef TCP_NODELAY
- lp_do_global_parameter("socket options", "TCP_NODELAY");
-#endif
- lp_do_global_parameter("workgroup", DEFAULT_WORKGROUP);
- myname = get_myname();
- lp_do_global_parameter("netbios name", myname);
- SAFE_FREE(myname);
- lp_do_global_parameter("name resolve order", "lmhosts wins host bcast");
-
- lp_do_global_parameter("fstype", FSTYPE_STRING);
- lp_do_global_parameter("ntvfs handler", "unixuid default");
- lp_do_global_parameter("max connections", "-1");
-
- lp_do_global_parameter("dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo");
- lp_do_global_parameter("server services", "smb rpc nbt wrepl ldap cldap web kdc drepl winbind");
- lp_do_global_parameter("ntptr providor", "simple_ldb");
- lp_do_global_parameter("auth methods:domain controller", "anonymous sam_ignoredomain");
- lp_do_global_parameter("auth methods:member server", "anonymous sam winbind");
- lp_do_global_parameter("auth methods:standalone", "anonymous sam_ignoredomain");
- lp_do_global_parameter("private dir", dyn_PRIVATE_DIR);
- lp_do_global_parameter("sam database", "sam.ldb");
- lp_do_global_parameter("secrets database", "secrets.ldb");
- lp_do_global_parameter("spoolss database", "spoolss.ldb");
- lp_do_global_parameter("wins config database", "wins_config.ldb");
- lp_do_global_parameter("wins database", "wins.ldb");
- lp_do_global_parameter("registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
-
- /* This hive should be dynamically generated by Samba using
- data from the sam, but for the moment leave it in a tdb to
- keep regedt32 from popping up an annoying dialog. */
- lp_do_global_parameter("registry:HKEY_USERS", "hku.ldb");
-
- /* using UTF8 by default allows us to support all chars */
- lp_do_global_parameter("unix charset", "UTF8");
-
- /* Use codepage 850 as a default for the dos character set */
- lp_do_global_parameter("dos charset", "CP850");
-
- /*
- * Allow the default PASSWD_CHAT to be overridden in local.h.
- */
- lp_do_global_parameter("passwd chat", DEFAULT_PASSWD_CHAT);
-
- lp_do_global_parameter("pid directory", dyn_PIDDIR);
- lp_do_global_parameter("lock dir", dyn_LOCKDIR);
- lp_do_global_parameter("modules dir", dyn_MODULESDIR);
- lp_do_global_parameter("ncalrpc dir", dyn_NCALRPCDIR);
-
- lp_do_global_parameter("socket address", "0.0.0.0");
- lp_do_global_parameter_var("server string",
- "Samba %s", SAMBA_VERSION_STRING);
-
- lp_do_global_parameter_var("announce version", "%d.%d",
- DEFAULT_MAJOR_VERSION,
- DEFAULT_MINOR_VERSION);
-
- lp_do_global_parameter("password server", "*");
-
- lp_do_global_parameter("max mux", "50");
- lp_do_global_parameter("max xmit", "12288");
- lp_do_global_parameter("password level", "0");
- lp_do_global_parameter("LargeReadwrite", "True");
- lp_do_global_parameter("server min protocol", "CORE");
- lp_do_global_parameter("server max protocol", "NT1");
- lp_do_global_parameter("client min protocol", "CORE");
- lp_do_global_parameter("client max protocol", "NT1");
- lp_do_global_parameter("security", "USER");
- lp_do_global_parameter("paranoid server security", "True");
- lp_do_global_parameter("EncryptPasswords", "True");
- lp_do_global_parameter("ReadRaw", "True");
- lp_do_global_parameter("WriteRaw", "True");
- lp_do_global_parameter("NullPasswords", "False");
- lp_do_global_parameter("ObeyPamRestrictions", "False");
- lp_do_global_parameter("announce as", "NT SERVER");
-
- lp_do_global_parameter("TimeServer", "False");
- lp_do_global_parameter("BindInterfacesOnly", "False");
- lp_do_global_parameter("Unicode", "True");
- lp_do_global_parameter("ClientLanManAuth", "True");
- lp_do_global_parameter("LanmanAuth", "True");
- lp_do_global_parameter("NTLMAuth", "True");
- lp_do_global_parameter("client use spnego principal", "False");
-
- lp_do_global_parameter("UnixExtensions", "False");
-
- lp_do_global_parameter("PreferredMaster", "Auto");
- lp_do_global_parameter("LocalMaster", "True");
-
- lp_do_global_parameter("wins support", "False");
- lp_do_global_parameter("dns proxy", "True");
-
- lp_do_global_parameter("winbind separator", "\\");
- lp_do_global_parameter("winbind sealed pipes", "True");
- lp_do_global_parameter("winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
- lp_do_global_parameter("template shell", "/bin/false");
- lp_do_global_parameter("template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
-
- lp_do_global_parameter("client signing", "Yes");
- lp_do_global_parameter("server signing", "auto");
-
- lp_do_global_parameter("use spnego", "True");
-
- lp_do_global_parameter("smb ports", "445 139");
- lp_do_global_parameter("nbt port", "137");
- lp_do_global_parameter("dgram port", "138");
- lp_do_global_parameter("cldap port", "389");
- lp_do_global_parameter("krb5 port", "88");
- lp_do_global_parameter("kpasswd port", "464");
- lp_do_global_parameter("web port", "901");
- lp_do_global_parameter("web application directory", dyn_WEBAPPSDIR);
- lp_do_global_parameter("jsonrpc services directory", dyn_SERVICESDIR);
-
- lp_do_global_parameter("nt status support", "True");
-
- lp_do_global_parameter("max wins ttl", "518400"); /* 6 days */
- lp_do_global_parameter("min wins ttl", "10");
-
- lp_do_global_parameter("tls enabled", "True");
- lp_do_global_parameter("tls keyfile", "tls/key.pem");
- lp_do_global_parameter("tls certfile", "tls/cert.pem");
- lp_do_global_parameter("tls cafile", "tls/ca.pem");
- lp_do_global_parameter_var("js include", "%s", dyn_JSDIR);
- lp_do_global_parameter_var("setup directory", "%s", dyn_SETUPDIR);
-
- for (i = 0; parm_table[i].label; i++) {
- if (!(parm_table[i].flags & FLAG_CMDLINE)) {
- parm_table[i].flags |= FLAG_DEFAULT;
- }
- }
-}
-
static TALLOC_CTX *lp_talloc;
/******************************************************************* a
@@ -1878,7 +1719,8 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
}
-bool lp_do_global_parameter(const char *pszParmName, const char *pszParmValue)
+bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *pszParmValue)
{
int parmnum = map_parameter(pszParmName);
void *parm_ptr;
@@ -1962,12 +1804,14 @@ bool lp_do_service_parameter(struct service *service,
Process a parameter for a particular service number. If snum < 0
then assume we are in the globals.
***************************************************************************/
-bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
+bool lp_do_parameter(struct service *service, const char *pszParmName,
+ const char *pszParmValue)
{
- if (snum < 0) {
- return lp_do_global_parameter(pszParmName, pszParmValue);
+ if (service == NULL) {
+ return lp_do_global_parameter(&loadparm, pszParmName,
+ pszParmValue);
} else {
- return lp_do_service_parameter(loadparm.ServicePtrs[snum],
+ return lp_do_service_parameter(service,
pszParmName, pszParmValue);
}
return true;
@@ -1981,7 +1825,8 @@ static bool do_parameter(const char *pszParmName, const char *pszParmValue,
void *userdata)
{
if (loadparm.bInGlobalSection)
- return lp_do_global_parameter(pszParmName, pszParmValue);
+ return lp_do_global_parameter(&loadparm, pszParmName,
+ pszParmValue);
else
return lp_do_service_parameter(loadparm.currentService,
pszParmName, pszParmValue);
@@ -1990,8 +1835,9 @@ static bool do_parameter(const char *pszParmName, const char *pszParmValue,
/*
variable argument do parameter
*/
-bool lp_do_global_parameter_var(const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
-bool lp_do_global_parameter_var(const char *pszParmName, const char *fmt, ...)
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *fmt, ...)
{
char *s;
bool ret;
@@ -2000,7 +1846,7 @@ bool lp_do_global_parameter_var(const char *pszParmName, const char *fmt, ...)
va_start(ap, fmt);
s = talloc_vasprintf(NULL, fmt, ap);
va_end(ap);
- ret = lp_do_global_parameter(pszParmName, s);
+ ret = lp_do_global_parameter(lp_ctx, pszParmName, s);
talloc_free(s);
return ret;
}
@@ -2032,7 +1878,7 @@ bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
/* reset the CMDLINE flag in case this has been called before */
parm_table[parmnum].flags &= ~FLAG_CMDLINE;
- if (!lp_do_parameter(-2, pszParmName, pszParmValue)) {
+ if (!lp_do_parameter(NULL, pszParmName, pszParmValue)) {
return false;
}
@@ -2456,6 +2302,168 @@ void lp_killservice(int iServiceIn)
}
/***************************************************************************
+ Initialise the global parameter structure.
+***************************************************************************/
+bool loadparm_init(struct loadparm_context *lp_ctx)
+{
+ int i;
+ char *myname;
+
+ DEBUG(3, ("Initialising global parameters\n"));
+
+ for (i = 0; parm_table[i].label; i++) {
+ if ((parm_table[i].type == P_STRING ||
+ parm_table[i].type == P_USTRING) &&
+ parm_table[i].ptr &&
+ !(parm_table[i].flags & FLAG_CMDLINE)) {
+ string_set(talloc_autofree_context(),
+ (char **)parm_table[i].ptr, "");
+ }
+ }
+
+ lp_do_global_parameter(lp_ctx, "config file", dyn_CONFIGFILE);
+
+ lp_do_global_parameter(lp_ctx, "share backend", "classic");
+
+ lp_do_global_parameter(lp_ctx, "server role", "standalone");
+
+ /* options that can be set on the command line must be initialised via
+ the slower lp_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
+#ifdef TCP_NODELAY
+ lp_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
+#endif
+ lp_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
+ myname = get_myname();
+ lp_do_global_parameter(lp_ctx, "netbios name", myname);
+ SAFE_FREE(myname);
+ lp_do_global_parameter(lp_ctx, "name resolve order", "lmhosts wins host bcast");
+
+ lp_do_global_parameter(lp_ctx, "fstype", FSTYPE_STRING);
+ lp_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
+ lp_do_global_parameter(lp_ctx, "max connections", "-1");
+
+ lp_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo");
+ lp_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap web kdc drepl winbind");
+ lp_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
+ lp_do_global_parameter(lp_ctx, "auth methods:domain controller", "anonymous sam_ignoredomain");
+ lp_do_global_parameter(lp_ctx, "auth methods:member server", "anonymous sam winbind");
+ lp_do_global_parameter(lp_ctx, "auth methods:standalone", "anonymous sam_ignoredomain");
+ lp_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
+ lp_do_global_parameter(lp_ctx, "sam database", "sam.ldb");
+ lp_do_global_parameter(lp_ctx, "secrets database", "secrets.ldb");
+ lp_do_global_parameter(lp_ctx, "spoolss database", "spoolss.ldb");
+ lp_do_global_parameter(lp_ctx, "wins config database", "wins_config.ldb");
+ lp_do_global_parameter(lp_ctx, "wins database", "wins.ldb");
+ lp_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
+
+ /* This hive should be dynamically generated by Samba using
+ data from the sam, but for the moment leave it in a tdb to
+ keep regedt32 from popping up an annoying dialog. */
+ lp_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
+
+ /* using UTF8 by default allows us to support all chars */
+ lp_do_global_parameter(lp_ctx, "unix charset", "UTF8");
+
+ /* Use codepage 850 as a default for the dos character set */
+ lp_do_global_parameter(lp_ctx, "dos charset", "CP850");
+
+ /*
+ * Allow the default PASSWD_CHAT to be overridden in local.h.
+ */
+ lp_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
+
+ lp_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
+ lp_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
+ lp_do_global_parameter(lp_ctx, "modules dir", dyn_MODULESDIR);
+ lp_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
+
+ lp_do_global_parameter(lp_ctx, "socket address", "0.0.0.0");
+ lp_do_global_parameter_var(lp_ctx, "server string",
+ "Samba %s", SAMBA_VERSION_STRING);
+
+ lp_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
+ DEFAULT_MAJOR_VERSION,
+ DEFAULT_MINOR_VERSION);
+
+ lp_do_global_parameter(lp_ctx, "password server", "*");
+
+ lp_do_global_parameter(lp_ctx, "max mux", "50");
+ lp_do_global_parameter(lp_ctx, "max xmit", "12288");
+ lp_do_global_parameter(lp_ctx, "password level", "0");
+ lp_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
+ lp_do_global_parameter(lp_ctx, "server min protocol", "CORE");
+ lp_do_global_parameter(lp_ctx, "server max protocol", "NT1");
+ lp_do_global_parameter(lp_ctx, "client min protocol", "CORE");
+ lp_do_global_parameter(lp_ctx, "client max protocol", "NT1");
+ lp_do_global_parameter(lp_ctx, "security", "USER");
+ lp_do_global_parameter(lp_ctx, "paranoid server security", "True");
+ lp_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
+ lp_do_global_parameter(lp_ctx, "ReadRaw", "True");
+ lp_do_global_parameter(lp_ctx, "WriteRaw", "True");
+ lp_do_global_parameter(lp_ctx, "NullPasswords", "False");
+ lp_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
+ lp_do_global_parameter(lp_ctx, "announce as", "NT SERVER");
+
+ lp_do_global_parameter(lp_ctx, "TimeServer", "False");
+ lp_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
+ lp_do_global_parameter(lp_ctx, "Unicode", "True");
+ lp_do_global_parameter(lp_ctx, "ClientLanManAuth", "True");
+ lp_do_global_parameter(lp_ctx, "LanmanAuth", "True");
+ lp_do_global_parameter(lp_ctx, "NTLMAuth", "True");
+ lp_do_global_parameter(lp_ctx, "client use spnego principal", "False");
+
+ lp_do_global_parameter(lp_ctx, "UnixExtensions", "False");
+
+ lp_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
+ lp_do_global_parameter(lp_ctx, "LocalMaster", "True");
+
+ lp_do_global_parameter(lp_ctx, "wins support", "False");
+ lp_do_global_parameter(lp_ctx, "dns proxy", "True");
+
+ lp_do_global_parameter(lp_ctx, "winbind separator", "\\");
+ lp_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
+ lp_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
+ lp_do_global_parameter(lp_ctx, "template shell", "/bin/false");
+ lp_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
+
+ lp_do_global_parameter(lp_ctx, "client signing", "Yes");
+ lp_do_global_parameter(lp_ctx, "server signing", "auto");
+
+ lp_do_global_parameter(lp_ctx, "use spnego", "True");
+
+ lp_do_global_parameter(lp_ctx, "smb ports", "445 139");
+ lp_do_global_parameter(lp_ctx, "nbt port", "137");
+ lp_do_global_parameter(lp_ctx, "dgram port", "138");
+ lp_do_global_parameter(lp_ctx, "cldap port", "389");
+ lp_do_global_parameter(lp_ctx, "krb5 port", "88");
+ lp_do_global_parameter(lp_ctx, "kpasswd port", "464");
+ lp_do_global_parameter(lp_ctx, "web port", "901");
+ lp_do_global_parameter(lp_ctx, "web application directory", dyn_WEBAPPSDIR);
+ lp_do_global_parameter(lp_ctx, "jsonrpc services directory", dyn_SERVICESDIR);
+
+ lp_do_global_parameter(lp_ctx, "nt status support", "True");
+
+ lp_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
+ lp_do_global_parameter(lp_ctx, "min wins ttl", "10");
+
+ lp_do_global_parameter(lp_ctx, "tls enabled", "True");
+ lp_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
+ lp_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
+ lp_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
+ lp_do_global_parameter_var(lp_ctx, "js include", "%s", dyn_JSDIR);
+ lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
+ dyn_SETUPDIR);
+
+ for (i = 0; parm_table[i].label; i++) {
+ if (!(parm_table[i].flags & FLAG_CMDLINE)) {
+ parm_table[i].flags |= FLAG_DEFAULT;
+ }
+ }
+
+ return true;
+}
+
+/***************************************************************************
Load the services array from the services file. Return True on success,
False on failure.
***************************************************************************/
@@ -2468,8 +2476,6 @@ bool lp_load(void)
bRetval = false;
- loadparm.bInGlobalSection = true;
-
if (loadparm.Globals.param_opt != NULL) {
struct param_opt *next;
for (data=loadparm.Globals.param_opt; data; data=next) {
@@ -2479,9 +2485,11 @@ bool lp_load(void)
talloc_free(data);
}
}
-
- init_globals();
+ if (!loadparm_init(&loadparm))
+ return false;
+
+ loadparm.bInGlobalSection = true;
n2 = standard_sub_basic(talloc_autofree_context(), lp_configfile());
DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
@@ -2505,7 +2513,7 @@ bool lp_load(void)
bLoaded = true;
if (!loadparm.Globals.szWINSservers && loadparm.Globals.bWINSsupport) {
- lp_do_parameter(-1, "wins server", "127.0.0.1");
+ lp_do_parameter(NULL, "wins server", "127.0.0.1");
}
init_iconv();
diff --git a/source4/param/param.h b/source4/param/param.h
index 9b21acf726..d5927f7dde 100644
--- a/source4/param/param.h
+++ b/source4/param/param.h
@@ -57,6 +57,7 @@ enum announce_as {/* Types of machine we can announce as. */
ANNOUNCE_AS_NT_WORKSTATION=4
};
+struct loadparm_context;
struct service;
#include "param/proto.h"