summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c481
-rw-r--r--source3/param/params.c24
2 files changed, 138 insertions, 367 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 2cc16ee79b..ba6e3f9e47 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -7,7 +7,6 @@
Copyright (C) Simo Sorce 2001
Copyright (C) Alexander Bokovoy 2002
- Copyright (C) Stefan (metze) Metzmacher 2002
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
@@ -81,13 +80,6 @@ extern int extra_time_offset;
static BOOL defaults_saved = False;
-typedef struct _param_opt_struct param_opt_struct;
-struct _param_opt_struct {
- param_opt_struct *prev, *next;
- char *key;
- char *value;
-};
-
/*
* This structure describes global (ie., server-wide) parameters.
*/
@@ -118,8 +110,6 @@ typedef struct
char *szSMBPasswdFile;
char *szPrivateDir;
char **szPassdbBackend;
- char **szSamBackend;
- char **szModules;
char *szPasswordServer;
char *szSocketOptions;
char *szRealm;
@@ -275,7 +265,6 @@ typedef struct
BOOL bKernelChangeNotify;
int restrict_anonymous;
int name_cache_timeout;
- param_opt_struct *param_opt;
}
global;
@@ -397,7 +386,6 @@ typedef struct
BOOL bNTAclSupport;
BOOL bUseSendfile;
BOOL bProfileAcls;
- param_opt_struct *param_opt;
char dummy[3]; /* for alignment */
}
@@ -517,8 +505,6 @@ static service sDefault = {
True, /* bNTAclSupport */
False, /* bUseSendfile */
False, /* bProfileAcls */
-
- NULL, /* Parametric options */
"" /* dummy */
};
@@ -535,29 +521,29 @@ static int default_server_announce;
#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
/* prototypes for the special type handlers */
-static BOOL handle_include(const char *pszParmValue, char **ptr);
-static BOOL handle_copy(const char *pszParmValue, char **ptr);
-static BOOL handle_vfs_object(const char *pszParmValue, char **ptr);
-static BOOL handle_source_env(const char *pszParmValue, char **ptr);
-static BOOL handle_netbios_name(const char *pszParmValue, char **ptr);
-static BOOL handle_winbind_uid(const char *pszParmValue, char **ptr);
-static BOOL handle_winbind_gid(const char *pszParmValue, char **ptr);
-static BOOL handle_non_unix_account_range(const char *pszParmValue, char **ptr);
-static BOOL handle_debug_list( const char *pszParmValue, char **ptr );
-static BOOL handle_workgroup( const char *pszParmValue, char **ptr );
-static BOOL handle_netbios_aliases( const char *pszParmValue, char **ptr );
-static BOOL handle_netbios_scope( const char *pszParmValue, char **ptr );
-
-static BOOL handle_ldap_machine_suffix ( const char *pszParmValue, char **ptr );
-static BOOL handle_ldap_user_suffix ( const char *pszParmValue, char **ptr );
-static BOOL handle_ldap_suffix ( const char *pszParmValue, char **ptr );
-
-static BOOL handle_acl_compatibility(const char *pszParmValue, char **ptr);
+static BOOL handle_include(char *pszParmValue, char **ptr);
+static BOOL handle_copy(char *pszParmValue, char **ptr);
+static BOOL handle_vfs_object(char *pszParmValue, char **ptr);
+static BOOL handle_source_env(char *pszParmValue, char **ptr);
+static BOOL handle_netbios_name(char *pszParmValue, char **ptr);
+static BOOL handle_winbind_uid(char *pszParmValue, char **ptr);
+static BOOL handle_winbind_gid(char *pszParmValue, char **ptr);
+static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr);
+static BOOL handle_debug_list( char *pszParmValue, char **ptr );
+static BOOL handle_workgroup( char *pszParmValue, char **ptr );
+static BOOL handle_netbios_aliases( char *pszParmValue, char **ptr );
+static BOOL handle_netbios_scope( char *pszParmValue, char **ptr );
+
+static BOOL handle_ldap_machine_suffix ( char *pszParmValue, char **ptr );
+static BOOL handle_ldap_user_suffix ( char *pszParmValue, char **ptr );
+static BOOL handle_ldap_suffix ( char *pszParmValue, char **ptr );
+
+static BOOL handle_acl_compatibility(char *pszParmValue, char **ptr);
static void set_server_role(void);
static void set_default_server_announce_type(void);
-static const struct enum_list enum_protocol[] = {
+static struct enum_list enum_protocol[] = {
{PROTOCOL_NT1, "NT1"},
{PROTOCOL_LANMAN2, "LANMAN2"},
{PROTOCOL_LANMAN1, "LANMAN1"},
@@ -567,7 +553,7 @@ static const struct enum_list enum_protocol[] = {
{-1, NULL}
};
-static const struct enum_list enum_security[] = {
+static struct enum_list enum_security[] = {
{SEC_SHARE, "SHARE"},
{SEC_USER, "USER"},
{SEC_SERVER, "SERVER"},
@@ -578,7 +564,7 @@ static const struct enum_list enum_security[] = {
{-1, NULL}
};
-static const struct enum_list enum_printing[] = {
+static struct enum_list enum_printing[] = {
{PRINT_SYSV, "sysv"},
{PRINT_AIX, "aix"},
{PRINT_HPUX, "hpux"},
@@ -597,7 +583,7 @@ static const struct enum_list enum_printing[] = {
{-1, NULL}
};
-static const struct enum_list enum_ldap_ssl[] = {
+static struct enum_list enum_ldap_ssl[] = {
#ifdef WITH_LDAP_SAMCONFIG
{LDAP_SSL_ON, "Yes"},
{LDAP_SSL_ON, "yes"},
@@ -613,7 +599,7 @@ static const struct enum_list enum_ldap_ssl[] = {
{-1, NULL}
};
-static const struct enum_list enum_ldap_passwd_sync[] = {
+static struct enum_list enum_ldap_passwd_sync[] = {
{LDAP_PASSWD_SYNC_ON, "Yes"},
{LDAP_PASSWD_SYNC_ON, "yes"},
{LDAP_PASSWD_SYNC_ON, "on"},
@@ -635,7 +621,7 @@ static const struct enum_list enum_ldap_passwd_sync[] = {
#define ANNOUNCE_AS_WFW 3
#define ANNOUNCE_AS_NT_WORKSTATION 4
-static const struct enum_list enum_announce_as[] = {
+static struct enum_list enum_announce_as[] = {
{ANNOUNCE_AS_NT_SERVER, "NT"},
{ANNOUNCE_AS_NT_SERVER, "NT Server"},
{ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
@@ -644,13 +630,13 @@ static const struct enum_list enum_announce_as[] = {
{-1, NULL}
};
-static const struct enum_list enum_case[] = {
+static struct enum_list enum_case[] = {
{CASE_LOWER, "lower"},
{CASE_UPPER, "upper"},
{-1, NULL}
};
-static const struct enum_list enum_bool_auto[] = {
+static struct enum_list enum_bool_auto[] = {
{False, "No"},
{False, "False"},
{False, "0"},
@@ -667,7 +653,7 @@ static const struct enum_list enum_bool_auto[] = {
#define CSC_POLICY_PROGRAMS 2
#define CSC_POLICY_DISABLE 3
-static const struct enum_list enum_csc_policy[] = {
+static struct enum_list enum_csc_policy[] = {
{CSC_POLICY_MANUAL, "manual"},
{CSC_POLICY_DOCUMENTS, "documents"},
{CSC_POLICY_PROGRAMS, "programs"},
@@ -696,7 +682,7 @@ static const struct enum_list enum_csc_policy[] = {
level security.
*/
-static const struct enum_list enum_map_to_guest[] = {
+static struct enum_list enum_map_to_guest[] = {
{NEVER_MAP_TO_GUEST, "Never"},
{MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
{MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
@@ -749,7 +735,6 @@ static struct parm_struct parm_table[] = {
{"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"private dir", P_STRING, P_GLOBAL, &Globals.szPrivateDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"passdb backend", P_LIST, P_GLOBAL, &Globals.szPassdbBackend, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"sam backend", P_LIST, P_GLOBAL, &Globals.szSamBackend, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"non unix account range", P_STRING, P_GLOBAL, &Globals.szNonUnixAccountRange, handle_non_unix_account_range, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"algorithmic rid base", P_INTEGER, P_GLOBAL, &Globals.bAlgorithmicRidBase, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
@@ -811,7 +796,6 @@ static struct parm_struct parm_table[] = {
{"allow hosts", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_HIDE},
{"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
{"deny hosts", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_HIDE},
- {"modules", P_LIST, P_GLOBAL, &Globals.szModules, NULL, NULL, FLAG_BASIC | FLAG_GLOBAL},
{"Logging Options", P_SEP, P_SEPARATOR},
@@ -1583,8 +1567,6 @@ FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
FN_GLOBAL_LIST(lp_passdb_backend, &Globals.szPassdbBackend)
-FN_GLOBAL_LIST(lp_sam_backend, &Globals.szSamBackend)
-FN_GLOBAL_LIST(lp_modules, &Globals.szModules)
FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
@@ -1819,210 +1801,61 @@ FN_GLOBAL_BOOL(lp_hide_local_users, &Globals.bHideLocalUsers)
FN_GLOBAL_BOOL(lp_algorithmic_rid_base, &Globals.bAlgorithmicRidBase)
FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
-/* local prototypes */
-
-static int map_parameter(const char *pszParmName);
-static BOOL set_boolean(BOOL *pb, const char *pszParmValue);
-static int getservicebyname(const char *pszServiceName,
- service * pserviceDest);
-static void copy_service(service * pserviceDest,
- service * pserviceSource, BOOL *pcopymapDest);
-static BOOL service_ok(int iService);
-static BOOL do_parameter(const char *pszParmName, const char *pszParmValue);
-static BOOL do_section(const char *pszSectionName);
-static void init_copymap(service * pservice);
-
-/* This is a helper function for parametrical options support. */
-/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
-/* Actual parametrical functions are quite simple */
-static const char *get_parametrics(int lookup_service, const char *type, const char *option)
-{
- char* vfskey;
- param_opt_struct *data;
-
- if (lookup_service >= iNumServices) return NULL;
-
- data = (lookup_service < 0) ?
- Globals.param_opt : ServicePtrs[lookup_service]->param_opt;
-
- asprintf(&vfskey, "%s:%s", type, option);
- while (data) {
- if (strcmp(data->key, vfskey) == 0) {
- string_free(&vfskey);
- return data->value;
- }
- data = data->next;
- }
-
- if (lookup_service >= 0) {
- /* Try to fetch the same option but from globals */
- /* but only if we are not already working with Globals */
- data = Globals.param_opt;
- while (data) {
- if (strcmp(data->key, vfskey) == 0) {
- string_free(&vfskey);
- return data->value;
- }
- data = data->next;
- }
- }
-
- string_free(&vfskey);
-
- return NULL;
-}
-
-
-/*******************************************************************
-convenience routine to return int parameters.
-********************************************************************/
-static int lp_int(const char *s)
-{
-
- if (!s) {
- DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
- return (-1);
- }
-
- return atoi(s);
-}
-
-/*******************************************************************
-convenience routine to return unsigned long parameters.
-********************************************************************/
-static int lp_ulong(const char *s)
-{
-
- if (!s) {
- DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
- return (-1);
- }
-
- return strtoul(s, NULL, 10);
-}
-
-/*******************************************************************
-convenience routine to return boolean parameters.
-********************************************************************/
-static BOOL lp_bool(const char *s)
-{
- BOOL ret = False;
-
- if (!s) {
- DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
- return False;
- }
-
- if (!set_boolean(&ret,s)) {
- DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
- return False;
- }
-
- return ret;
-}
-
-/*******************************************************************
-convenience routine to return enum parameters.
-********************************************************************/
-static int lp_enum(const char *s,const struct enum_list *_enum)
-{
- int i;
-
- if (!s || !_enum) {
- DEBUG(0,("lp_enum(%s,enum): is called with NULL!\n",s));
- return False;
- }
-
- for (i=0; _enum[i].name; i++) {
- if (strcasecmp(_enum[i].name,s)==0)
- return _enum[i].value;
- }
-
- DEBUG(0,("lp_enum(%s,enum): value is not in enum_list!\n",s));
- return (-1);
-}
-
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-/* Returned value is allocated in 'lp_talloc' context */
-
-char *lp_parm_string(int lookup_service, const char *type, const char *option)
-{
- const char *value = get_parametrics(lookup_service, type, option);
-
- if (value)
- return lp_string(value);
+typedef struct _param_opt_struct param_opt_struct;
+struct _param_opt_struct {
+ char *key;
+ char *value;
+ param_opt_struct *prev, *next;
+};
- return NULL;
-}
+static param_opt_struct *param_opt = NULL;
-/* Return parametric option from a given service. Type is a part of option before ':' */
+/* Return parametric option from given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
/* Returned value is allocated in 'lp_talloc' context */
-char **lp_parm_string_list(int lookup_service, const char *type, const char *option,
- const char *separator)
-{
- const char *value = get_parametrics(lookup_service, type, option);
-
- if (value)
- return str_list_make(value, separator);
-
- return NULL;
-}
-
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-
-int lp_parm_int(int lookup_service, const char *type, const char *option)
-{
- const char *value = get_parametrics(lookup_service, type, option);
-
- if (value)
- return lp_int(value);
-
- return (-1);
-}
-
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-
-unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *option)
-{
- const char *value = get_parametrics(lookup_service, type, option);
-
- if (value)
- return lp_ulong(value);
-
- return (0);
-}
-
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-
-BOOL lp_parm_bool(int lookup_service, const char *type, const char *option)
+char *lp_parm_string(const char *servicename, const char *type, const char *option)
{
- const char *value = get_parametrics(lookup_service, type, option);
+ param_opt_struct *data;
+ pstring vfskey;
+
+ if (param_opt != NULL) {
+ ZERO_STRUCT(vfskey);
+ pstr_sprintf(vfskey, "%s:%s:%s", (servicename==NULL) ? "global" : servicename,
+ type, option);
+ data = param_opt;
+ while (data) {
+ if (strcmp(data->key, vfskey) == 0) {
+ return lp_string(data->value);
+ }
+ data = data->next;
+ }
+ /* Try to fetch the same option but from globals */
+ pstr_sprintf(vfskey, "global:%s:%s", type, option);
+ data = param_opt;
+ while (data) {
+ if (strcmp(data->key, vfskey) == 0) {
+ return lp_string(data->value);
+ }
+ data = data->next;
+ }
- if (value)
- return lp_bool(value);
-
- return False;
+ }
+ return NULL;
}
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-
-int lp_parm_enum(int lookup_service, const char *type, const char *option,
- const struct enum_list *_enum)
-{
- const char *value = get_parametrics(lookup_service, type, option);
-
- if (value)
- return lp_enum(value, _enum);
+/* local prototypes */
- return (-1);
-}
+static int map_parameter(char *pszParmName);
+static BOOL set_boolean(BOOL *pb, char *pszParmValue);
+static int getservicebyname(const char *pszServiceName,
+ service * pserviceDest);
+static void copy_service(service * pserviceDest,
+ service * pserviceSource, BOOL *pcopymapDest);
+static BOOL service_ok(int iService);
+static BOOL do_parameter(char *pszParmName, char *pszParmValue);
+static BOOL do_section(char *pszSectionName);
+static void init_copymap(service * pservice);
/***************************************************************************
@@ -2042,7 +1875,6 @@ static void init_service(service * pservice)
static void free_service(service *pservice)
{
int i;
- param_opt_struct *data, *pdata;
if (!pservice)
return;
@@ -2067,16 +1899,6 @@ static void free_service(service *pservice)
PTR_DIFF(parm_table[i].ptr, &sDefault)));
}
- DEBUG(5,("Freeing parametrics:\n"));
- data = pservice->param_opt;
- while (data) {
- DEBUG(5,("[%s = %s]\n", data->key, data->value));
- string_free(&data->key);
- string_free(&data->value);
- pdata = data->next;
- SAFE_FREE(data);
- data = pdata;
- }
ZERO_STRUCTP(pservice);
}
@@ -2091,27 +1913,14 @@ static int add_a_service(const service *pservice, const char *name)
int i;
service tservice;
int num_to_alloc = iNumServices + 1;
- param_opt_struct *data, *pdata;
tservice = *pservice;
/* it might already exist */
if (name) {
i = getservicebyname(name, NULL);
- if (i >= 0) {
- /* Clean all parametric options for service */
- /* They will be added during parsing again */
- data = ServicePtrs[i]->param_opt;
- while (data) {
- string_free(&data->key);
- string_free(&data->value);
- pdata = data->next;
- SAFE_FREE(data);
- data = pdata;
- }
- ServicePtrs[i]->param_opt = NULL;
+ if (i >= 0)
return (i);
- }
}
/* find an invalid one */
@@ -2208,7 +2017,7 @@ int lp_add_service(const char *pszService, int iDefaultService)
Add the IPC service.
***************************************************************************/
-static BOOL lp_add_ipc(const char *ipc_name, BOOL guest_ok)
+static BOOL lp_add_ipc(char *ipc_name, BOOL guest_ok)
{
pstring comment;
int i = add_a_service(&sDefault, ipc_name);
@@ -2278,7 +2087,7 @@ BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
Returns False if the parameter string is not recognised, else TRUE.
***************************************************************************/
-static int map_parameter(const char *pszParmName)
+static int map_parameter(char *pszParmName)
{
int iIndex;
@@ -2304,7 +2113,7 @@ static int map_parameter(const char *pszParmName)
represent a boolean.
***************************************************************************/
-static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
+static BOOL set_boolean(BOOL *pb, char *pszParmValue)
{
BOOL bRetval;
@@ -2354,8 +2163,6 @@ static void copy_service(service * pserviceDest, service * pserviceSource, BOOL
{
int i;
BOOL bcopyall = (pcopymapDest == NULL);
- param_opt_struct *data, *pdata, *paramo;
- BOOL not_added;
for (i = 0; parm_table[i].label; i++)
if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
@@ -2409,30 +2216,6 @@ static void copy_service(service * pserviceDest, service * pserviceSource, BOOL
(void *)pserviceSource->copymap,
sizeof(BOOL) * NUMPARAMETERS);
}
-
- data = pserviceSource->param_opt;
- while (data) {
- not_added = True;
- pdata = pserviceDest->param_opt;
- /* Traverse destination */
- while (pdata) {
- /* If we already have same option, override it */
- if (strcmp(pdata->key, data->key) == 0) {
- string_free(&pdata->value);
- pdata->value = strdup(data->value);
- not_added = False;
- break;
- }
- pdata = pdata->next;
- }
- if (not_added) {
- paramo = smb_xmalloc(sizeof(param_opt_struct));
- paramo->key = strdup(data->key);
- paramo->value = strdup(data->value);
- DLIST_ADD(pserviceDest->param_opt, paramo);
- }
- data = data->next;
- }
}
/***************************************************************************
@@ -2566,7 +2349,7 @@ BOOL lp_file_list_changed(void)
Note: We must *NOT* use string_set() here as ptr points to global_myname.
***************************************************************************/
-static BOOL handle_netbios_name(const char *pszParmValue, char **ptr)
+static BOOL handle_netbios_name(char *pszParmValue, char **ptr)
{
pstring netbios_name;
@@ -2582,17 +2365,17 @@ static BOOL handle_netbios_name(const char *pszParmValue, char **ptr)
return (True);
}
-static BOOL handle_workgroup(const char *pszParmValue, char **ptr)
+static BOOL handle_workgroup(char *pszParmValue, char **ptr)
{
return set_global_myworkgroup(pszParmValue);
}
-static BOOL handle_netbios_scope(const char *pszParmValue, char **ptr)
+static BOOL handle_netbios_scope(char *pszParmValue, char **ptr)
{
return set_global_scope(pszParmValue);
}
-static BOOL handle_netbios_aliases(const char *pszParmValue, char **ptr)
+static BOOL handle_netbios_aliases(char *pszParmValue, char **ptr)
{
Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
@@ -2652,7 +2435,7 @@ static BOOL source_env(char **lines)
Handle the source environment operation.
***************************************************************************/
-static BOOL handle_source_env(const char *pszParmValue, char **ptr)
+static BOOL handle_source_env(char *pszParmValue, char **ptr)
{
pstring fname;
char *p = fname;
@@ -2692,7 +2475,7 @@ static BOOL handle_source_env(const char *pszParmValue, char **ptr)
Handle the interpretation of the vfs object parameter.
*************************************************************************/
-static BOOL handle_vfs_object(const char *pszParmValue, char **ptr)
+static BOOL handle_vfs_object(char *pszParmValue, char **ptr)
{
/* Set string value */
@@ -2708,7 +2491,7 @@ static BOOL handle_vfs_object(const char *pszParmValue, char **ptr)
Handle the include operation.
***************************************************************************/
-static BOOL handle_include(const char *pszParmValue, char **ptr)
+static BOOL handle_include(char *pszParmValue, char **ptr)
{
pstring fname;
pstrcpy(fname, pszParmValue);
@@ -2731,7 +2514,7 @@ static BOOL handle_include(const char *pszParmValue, char **ptr)
Handle the interpretation of the copy parameter.
***************************************************************************/
-static BOOL handle_copy(const char *pszParmValue, char **ptr)
+static BOOL handle_copy(char *pszParmValue, char **ptr)
{
BOOL bRetval;
int iTemp;
@@ -2827,7 +2610,7 @@ BOOL lp_non_unix_account_range(uint32 *low, uint32 *high)
/* Do some simple checks on "winbind [ug]id" parameter values */
-static BOOL handle_winbind_uid(const char *pszParmValue, char **ptr)
+static BOOL handle_winbind_uid(char *pszParmValue, char **ptr)
{
uint32 low, high;
@@ -2844,7 +2627,7 @@ static BOOL handle_winbind_uid(const char *pszParmValue, char **ptr)
return True;
}
-static BOOL handle_winbind_gid(const char *pszParmValue, char **ptr)
+static BOOL handle_winbind_gid(char *pszParmValue, char **ptr)
{
uint32 low, high;
@@ -2865,7 +2648,7 @@ static BOOL handle_winbind_gid(const char *pszParmValue, char **ptr)
Do some simple checks on "non unix account range" parameter values.
***************************************************************************/
-static BOOL handle_non_unix_account_range(const char *pszParmValue, char **ptr)
+static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr)
{
uint32 low, high;
@@ -2886,7 +2669,7 @@ static BOOL handle_non_unix_account_range(const char *pszParmValue, char **ptr)
Handle the DEBUG level list.
***************************************************************************/
-static BOOL handle_debug_list( const char *pszParmValueIn, char **ptr )
+static BOOL handle_debug_list( char *pszParmValueIn, char **ptr )
{
pstring pszParmValue;
@@ -2899,7 +2682,7 @@ static BOOL handle_debug_list( const char *pszParmValueIn, char **ptr )
Handle the ldap machine suffix option.
***************************************************************************/
-static BOOL handle_ldap_machine_suffix( const char *pszParmValue, char **ptr)
+static BOOL handle_ldap_machine_suffix( char *pszParmValue, char **ptr)
{
pstring suffix;
@@ -2923,7 +2706,7 @@ static BOOL handle_ldap_machine_suffix( const char *pszParmValue, char **ptr)
Handle the ldap user suffix option.
***************************************************************************/
-static BOOL handle_ldap_user_suffix( const char *pszParmValue, char **ptr)
+static BOOL handle_ldap_user_suffix( char *pszParmValue, char **ptr)
{
pstring suffix;
@@ -2948,7 +2731,7 @@ static BOOL handle_ldap_user_suffix( const char *pszParmValue, char **ptr)
to be set as well.
***************************************************************************/
-static BOOL handle_ldap_suffix( const char *pszParmValue, char **ptr)
+static BOOL handle_ldap_suffix( char *pszParmValue, char **ptr)
{
pstring suffix;
pstring user_suffix;
@@ -2981,7 +2764,7 @@ static BOOL handle_ldap_suffix( const char *pszParmValue, char **ptr)
return True;
}
-static BOOL handle_acl_compatibility(const char *pszParmValue, char **ptr)
+static BOOL handle_acl_compatibility(char *pszParmValue, char **ptr)
{
if (strequal(pszParmValue, "auto"))
string_set(ptr, "");
@@ -3027,15 +2810,14 @@ void *lp_local_ptr(int snum, void *ptr)
then assume we are in the globals.
***************************************************************************/
-BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
+BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
{
int parmnum, i, slen;
void *parm_ptr = NULL; /* where we are going to store the result */
void *def_ptr = NULL;
pstring vfskey;
char *sep;
- param_opt_struct *paramo, *data;
- BOOL not_added;
+ param_opt_struct *paramo;
parmnum = map_parameter(pszParmName);
@@ -3043,35 +2825,15 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
if ((sep=strchr(pszParmName, ':')) != NULL) {
*sep = 0;
ZERO_STRUCT(vfskey);
- pstr_sprintf(vfskey, "%s:", pszParmName);
+ pstr_sprintf(vfskey, "%s:%s:",
+ (snum >= 0) ? lp_servicename(snum) : "global", pszParmName);
slen = strlen(vfskey);
safe_strcat(vfskey, sep+1, sizeof(pstring));
trim_string(vfskey+slen, " ", " ");
- not_added = True;
- data = (snum < 0) ? Globals.param_opt :
- ServicePtrs[snum]->param_opt;
- /* Traverse destination */
- while (data) {
- /* If we already have same option, override it */
- if (strcmp(data->key, vfskey) == 0) {
- string_free(&data->value);
- data->value = strdup(pszParmValue);
- not_added = False;
- break;
- }
- data = data->next;
- }
- if (not_added) {
- paramo = smb_xmalloc(sizeof(param_opt_struct));
- paramo->key = strdup(vfskey);
- paramo->value = strdup(pszParmValue);
- if (snum < 0) {
- DLIST_ADD(Globals.param_opt, paramo);
- } else {
- DLIST_ADD(ServicePtrs[snum]->param_opt, paramo);
- }
- }
-
+ paramo = smb_xmalloc(sizeof(param_opt_struct));
+ paramo->key = strdup(vfskey);
+ paramo->value = strdup(pszParmValue);
+ DLIST_ADD(param_opt, paramo);
*sep = ':';
return (True);
}
@@ -3187,7 +2949,7 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
Process a parameter.
***************************************************************************/
-static BOOL do_parameter(const char *pszParmName, const char *pszParmValue)
+static BOOL do_parameter(char *pszParmName, char *pszParmValue)
{
if (!bInGlobalSection && bGlobalOnly)
return (True);
@@ -3328,7 +3090,7 @@ void init_locals(void)
Returns True on success, False on failure.
***************************************************************************/
-static BOOL do_section(const char *pszSectionName)
+static BOOL do_section(char *pszSectionName)
{
BOOL bRetval;
BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
@@ -3420,6 +3182,7 @@ static void dump_globals(FILE *f)
{
int i;
param_opt_struct *data;
+ char *s;
fprintf(f, "# Global parameters\n[global]\n");
@@ -3433,11 +3196,14 @@ static void dump_globals(FILE *f)
print_parameter(&parm_table[i], parm_table[i].ptr, f);
fprintf(f, "\n");
}
- if (Globals.param_opt != NULL) {
- data = Globals.param_opt;
+ if (param_opt != NULL) {
+ data = param_opt;
while(data) {
- fprintf(f, "\t%s = %s\n", data->key, data->value);
- data = data->next;
+ if (((s=strstr(data->key, "global")) == data->key) &&
+ (*(s+strlen("global")) == ':')) {
+ fprintf(f, "\t%s = %s\n", s+strlen("global")+1, data->value);
+ }
+ data = data->next;
}
}
@@ -3464,6 +3230,7 @@ static void dump_a_service(service * pService, FILE * f)
{
int i;
param_opt_struct *data;
+ char *s, *sn;
if (pService != &sDefault)
fprintf(f, "\n[%s]\n", pService->szService);
@@ -3492,11 +3259,15 @@ static void dump_a_service(service * pService, FILE * f)
((char *)pService) + pdiff, f);
fprintf(f, "\n");
}
- if (pService->param_opt != NULL) {
- data = pService->param_opt;
+ if (param_opt != NULL) {
+ data = param_opt;
+ sn = (pService == &sDefault) ? "global" : pService->szService;
while(data) {
- fprintf(f, "\t%s = %s\n", data->key, data->value);
- data = data->next;
+ if (((s=strstr(data->key, sn)) == data->key) &&
+ (*(s+strlen(sn)) == ':')) {
+ fprintf(f, "\t%s = %s\n", s+strlen(sn)+1, data->value);
+ }
+ data = data->next;
}
}
}
@@ -3831,16 +3602,16 @@ BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
lp_save_defaults();
}
- if (Globals.param_opt != NULL) {
- data = Globals.param_opt;
+ if (param_opt != NULL) {
+ data = param_opt;
while (data) {
- string_free(&data->key);
- string_free(&data->value);
+ SAFE_FREE(data->key);
+ SAFE_FREE(data->value);
pdata = data->next;
SAFE_FREE(data);
data = pdata;
}
- Globals.param_opt = NULL;
+ param_opt = NULL;
}
/* We get sections first, so have to start 'behind' to make up */
@@ -4068,7 +3839,7 @@ void lp_remove_service(int snum)
Copy a service.
********************************************************************/
-void lp_copy_service(int snum, const char *new_name)
+void lp_copy_service(int snum, char *new_name)
{
char *oldname = lp_servicename(snum);
do_section(new_name);
diff --git a/source3/param/params.c b/source3/param/params.c
index 892e5476cc..bc93a1fedf 100644
--- a/source3/param/params.c
+++ b/source3/param/params.c
@@ -201,7 +201,7 @@ static int Continuation(char *line, int pos )
}
-static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) )
+static BOOL Section( myFILE *InFile, BOOL (*sfunc)(char *) )
/* ------------------------------------------------------------------------ **
* Scan a section name, and pass the name to function sfunc().
*
@@ -219,7 +219,7 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) )
int c;
int i;
int end;
- const char *func = "params.c:Section() -";
+ char *func = "params.c:Section() -";
i = 0; /* <i> is the offset of the next free byte in bufr[] and */
end = 0; /* <end> is the current "end of string" offset. In most */
@@ -297,7 +297,7 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) )
return( False );
} /* Section */
-static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *), int c )
+static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(char *, char *), int c )
/* ------------------------------------------------------------------------ **
* Scan a parameter name and value, and pass these two fields to pfunc().
*
@@ -325,7 +325,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *)
int i = 0; /* Position within bufr. */
int end = 0; /* bufr[end] is current end-of-string. */
int vstart = 0; /* Starting position of the parameter value. */
- const char *func = "params.c:Parameter() -";
+ char *func = "params.c:Parameter() -";
/* Read the parameter name. */
while( 0 == vstart ) /* Loop until we've found the start of the value. */
@@ -445,8 +445,8 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *)
} /* Parameter */
static BOOL Parse( myFILE *InFile,
- BOOL (*sfunc)(const char *),
- BOOL (*pfunc)(const char *, const char *) )
+ BOOL (*sfunc)(char *),
+ BOOL (*pfunc)(char *, char *) )
/* ------------------------------------------------------------------------ **
* Scan & parse the input.
*
@@ -505,7 +505,7 @@ static BOOL Parse( myFILE *InFile,
return( True );
} /* Parse */
-static myFILE *OpenConfFile( const char *FileName )
+static myFILE *OpenConfFile( char *FileName )
/* ------------------------------------------------------------------------ **
* Open a configuration file.
*
@@ -516,7 +516,7 @@ static myFILE *OpenConfFile( const char *FileName )
* ------------------------------------------------------------------------ **
*/
{
- const char *func = "params.c:OpenConfFile() -";
+ char *func = "params.c:OpenConfFile() -";
extern BOOL in_client;
int lvl = in_client?1:0;
myFILE *ret;
@@ -538,9 +538,9 @@ static myFILE *OpenConfFile( const char *FileName )
return( ret );
} /* OpenConfFile */
-BOOL pm_process( const char *FileName,
- BOOL (*sfunc)(const char *),
- BOOL (*pfunc)(const char *, const char *) )
+BOOL pm_process( char *FileName,
+ BOOL (*sfunc)(char *),
+ BOOL (*pfunc)(char *, char *) )
/* ------------------------------------------------------------------------ **
* Process the named parameter file.
*
@@ -557,7 +557,7 @@ BOOL pm_process( const char *FileName,
{
int result;
myFILE *InFile;
- const char *func = "params.c:pm_process() -";
+ char *func = "params.c:pm_process() -";
InFile = OpenConfFile( FileName ); /* Open the config file. */
if( NULL == InFile )