summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/loadparm.c36
-rw-r--r--source4/param/loadparm.h1
-rw-r--r--source4/param/param.h2
-rw-r--r--source4/param/share_classic.c6
4 files changed, 26 insertions, 19 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index f914d706cd..1582eb6075 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -66,6 +66,8 @@
static bool bLoaded = false;
+struct loadparm_context *global_loadparm = NULL;
+
#define standard_sub_basic talloc_strdup
static bool do_parameter(const char *, const char *, void *);
@@ -2293,6 +2295,8 @@ bool loadparm_init(struct loadparm_context *lp_ctx)
int i;
char *myname;
+ lp_ctx->bInGlobalSection = true;
+
DEBUG(3, ("Initialising global parameters\n"));
for (i = 0; parm_table[i].label; i++) {
@@ -2458,6 +2462,8 @@ bool lp_load(void)
struct param_opt *data;
struct loadparm_context *lp_ctx = &loadparm;
+ global_loadparm = lp_ctx;
+
bRetval = false;
if (lp_ctx->Globals.param_opt != NULL) {
@@ -2509,22 +2515,20 @@ bool lp_load(void)
Return the max number of services.
***************************************************************************/
-int lp_numservices(void)
+int lp_numservices(struct loadparm_context *lp_ctx)
{
- return loadparm.iNumServices;
+ return lp_ctx->iNumServices;
}
/***************************************************************************
Display the contents of the services array in human-readable form.
***************************************************************************/
-void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
+void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
+ int maxtoprint)
{
- struct loadparm_context *lp_ctx;
int iService;
- lp_ctx = &loadparm;
-
if (show_defaults)
defaults_saved = false;
@@ -2549,28 +2553,30 @@ void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service)
}
}
-struct loadparm_service *lp_servicebynum(int snum)
+struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
+ int snum)
{
- return loadparm.ServicePtrs[snum];
+ return lp_ctx->ServicePtrs[snum];
}
-struct loadparm_service *lp_service(const char *service_name)
+struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
+ const char *service_name)
{
int iService;
char *serviceName;
- for (iService = loadparm.iNumServices - 1; iService >= 0; iService--) {
- if (loadparm.ServicePtrs[iService] &&
- loadparm.ServicePtrs[iService]->szService) {
+ for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
+ if (lp_ctx->ServicePtrs[iService] &&
+ lp_ctx->ServicePtrs[iService]->szService) {
/*
* The substitution here is used to support %U is
* service names
*/
serviceName = standard_sub_basic(
- loadparm.ServicePtrs[iService],
- loadparm.ServicePtrs[iService]->szService);
+ lp_ctx->ServicePtrs[iService],
+ lp_ctx->ServicePtrs[iService]->szService);
if (strequal(serviceName, service_name))
- return loadparm.ServicePtrs[iService];
+ return lp_ctx->ServicePtrs[iService];
}
}
diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h
index d74f70aef0..7f8b375e9a 100644
--- a/source4/param/loadparm.h
+++ b/source4/param/loadparm.h
@@ -80,4 +80,3 @@ struct parm_struct {
#define HOMES_NAME "homes"
#endif
-
diff --git a/source4/param/param.h b/source4/param/param.h
index 22c32cb28f..caa5a763bb 100644
--- a/source4/param/param.h
+++ b/source4/param/param.h
@@ -62,4 +62,6 @@ struct loadparm_service;
#include "param/proto.h"
+extern struct loadparm_context *global_loadparm;
+
#endif /* _PARAM_H */
diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c
index df86e2be4f..c9786d06bd 100644
--- a/source4/param/share_classic.c
+++ b/source4/param/share_classic.c
@@ -268,7 +268,7 @@ static NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
int num_services;
const char **n;
- num_services = lp_numservices();
+ num_services = lp_numservices(global_loadparm);
n = talloc_array(mem_ctx, const char *, num_services);
if (!n) {
@@ -277,7 +277,7 @@ static NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
}
for (i = 0; i < num_services; i++) {
- n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum(i)));
+ n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum(global_loadparm, i)));
if (!n[i]) {
DEBUG(0,("ERROR: Out of memory!\n"));
talloc_free(n);
@@ -299,7 +299,7 @@ static NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
struct share_config *s;
struct loadparm_service *service;
- service = lp_service(name);
+ service = lp_service(global_loadparm, name);
if (service == NULL) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;