summaryrefslogtreecommitdiffstats
path: root/source3/param/loadparm.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/param/loadparm.c')
-rw-r--r--source3/param/loadparm.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 9fa3030928..459528f237 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1172,20 +1172,12 @@ static bool is_synonym_of(int parm1, int parm2, bool *inverse);
* parametrical functions are quite simple
*/
static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service *service, const char *type,
- const char *option)
+ const char *option, struct parmlist_entry *global_opts)
{
- bool global_section = false;
char* param_key;
struct parmlist_entry *data;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- if (service == NULL) {
- data = Globals.param_opt;
- global_section = true;
- } else {
- data = service->param_opt;
- }
-
param_key = talloc_asprintf(mem_ctx, "%s:%s", type, option);
if (param_key == NULL) {
DEBUG(0,("asprintf failed!\n"));
@@ -1193,18 +1185,11 @@ static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service
return NULL;
}
- while (data) {
- if (strwicmp(data->key, param_key) == 0) {
- TALLOC_FREE(mem_ctx);
- return data;
- }
- data = data->next;
- }
-
- if (!global_section) {
- /* Try to fetch the same option but from globals */
- /* but only if we are not already working with Globals */
- data = Globals.param_opt;
+ /*
+ * Try to fetch the option from the service.
+ */
+ if (service != NULL) {
+ data = service->param_opt;
while (data) {
if (strwicmp(data->key, param_key) == 0) {
TALLOC_FREE(mem_ctx);
@@ -1214,6 +1199,19 @@ static struct parmlist_entry *get_parametrics_by_service(struct loadparm_service
}
}
+ /*
+ * Fall back to fetching from the globals.
+ */
+ data = global_opts;
+ while (data) {
+ if (strwicmp(data->key, param_key) == 0) {
+ TALLOC_FREE(mem_ctx);
+ return data;
+ }
+ data = data->next;
+ }
+
+
TALLOC_FREE(mem_ctx);
return NULL;
@@ -1230,9 +1228,10 @@ static struct parmlist_entry *get_parametrics(int snum, const char *type,
if (snum >= iNumServices) return NULL;
if (snum < 0) {
- return get_parametrics_by_service(NULL, type, option);
+ return get_parametrics_by_service(NULL, type, option, Globals.param_opt);
} else {
- return get_parametrics_by_service(ServicePtrs[snum], type, option);
+ return get_parametrics_by_service(ServicePtrs[snum],
+ type, option, Globals.param_opt);
}
}
@@ -1296,7 +1295,7 @@ const char *lp_parm_const_string_service(struct loadparm_service *service,
const char *type, const char *option,
const char *def)
{
- struct parmlist_entry *data = get_parametrics_by_service(service, type, option);
+ struct parmlist_entry *data = get_parametrics_by_service(service, type, option, Globals.param_opt);
if (data == NULL||data->value==NULL)
return def;