summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-02-21 18:21:44 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-02-21 18:21:44 +0100
commite11c61bc5cd487dce06fc38bb0ee8c4e24b04e8c (patch)
tree5e7dd6c56c9886c4f8530faf92293d4a22684215 /source4
parent3c20b3eebafe46127a7b69cca573c6a128f8de89 (diff)
downloadsamba-e11c61bc5cd487dce06fc38bb0ee8c4e24b04e8c.tar.gz
samba-e11c61bc5cd487dce06fc38bb0ee8c4e24b04e8c.tar.bz2
samba-e11c61bc5cd487dce06fc38bb0ee8c4e24b04e8c.zip
Introduce mprLpCtx() similar to mprMemCtx() for loadparm_context used by
all EJS code. (This used to be commit 184988866fe8e740f58e3683eefcaa70f8b51d11)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/appweb/mpr/miniMpr.c7
-rw-r--r--source4/lib/appweb/mpr/miniMpr.h2
-rw-r--r--source4/scripting/ejs/ejsnet/net_ctx.c4
-rw-r--r--source4/scripting/ejs/smbcalls.c4
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c12
-rw-r--r--source4/scripting/ejs/smbcalls_cli.c8
-rw-r--r--source4/scripting/ejs/smbcalls_config.c22
-rw-r--r--source4/scripting/ejs/smbcalls_creds.c4
-rw-r--r--source4/scripting/ejs/smbcalls_data.c4
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c2
-rw-r--r--source4/scripting/ejs/smbcalls_nbt.c2
-rw-r--r--source4/scripting/ejs/smbcalls_reg.c2
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c6
-rw-r--r--source4/scripting/ejs/smbcalls_sys.c2
14 files changed, 45 insertions, 36 deletions
diff --git a/source4/lib/appweb/mpr/miniMpr.c b/source4/lib/appweb/mpr/miniMpr.c
index 949d64fcf1..52b23608aa 100644
--- a/source4/lib/appweb/mpr/miniMpr.c
+++ b/source4/lib/appweb/mpr/miniMpr.c
@@ -30,6 +30,7 @@
*/
#include "miniMpr.h"
+#include "param/param.h"
/************************************ Code ************************************/
#if !BLD_APPWEB
@@ -49,6 +50,12 @@ void *mprMemCtx(void)
return mpr_ctx;
}
+/* return the loadparm context being used for all ejs variables */
+struct loadparm_context *mprLpCtx(void)
+{
+ return global_loadparm;
+}
+
void mprFree(void *ptr)
{
talloc_free(ptr);
diff --git a/source4/lib/appweb/mpr/miniMpr.h b/source4/lib/appweb/mpr/miniMpr.h
index 836fdab9f2..15ce30c8df 100644
--- a/source4/lib/appweb/mpr/miniMpr.h
+++ b/source4/lib/appweb/mpr/miniMpr.h
@@ -272,6 +272,8 @@ extern int mprMemcpy(char *dest, int destMax, const char *src, int nbytes);
extern void mprSetCtx(void *ctx);
extern void *mprMemCtx(void);
+struct loadparm_context;
+extern struct loadparm_context *mprLpCtx(void);
/* This function needs to be provided by anyone using ejs */
void ejs_exception(const char *reason);
diff --git a/source4/scripting/ejs/ejsnet/net_ctx.c b/source4/scripting/ejs/ejsnet/net_ctx.c
index 396718367a..99be1c4ef8 100644
--- a/source4/scripting/ejs/ejsnet/net_ctx.c
+++ b/source4/scripting/ejs/ejsnet/net_ctx.c
@@ -52,7 +52,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
}
ev = event_context_find(event_mem_ctx);
- ctx = libnet_context_init(ev, global_loadparm);
+ ctx = libnet_context_init(ev, mprLpCtx());
/* IF we generated a new event context, it will be under here,
* and we need it to last as long as the libnet context, so
* make it a child */
@@ -68,7 +68,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
talloc_free(ctx);
return -1;
}
- cli_credentials_set_conf(creds, global_loadparm);
+ cli_credentials_set_conf(creds, mprLpCtx());
cli_credentials_set_anonymous(creds);
mprCreds = mprCredentials(creds);
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index 1f29fce002..63a80e17db 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -111,7 +111,7 @@ static int ejs_typeof_native(MprVarHandle eid, int argc, struct MprVar **argv)
static int ejs_libinclude(int eid, int argc, char **argv)
{
int i, j;
- const char **js_include = lp_js_include(global_loadparm);
+ const char **js_include = lp_js_include(mprLpCtx());
if (js_include == NULL || js_include[0] == NULL) {
ejsSetErrorMsg(eid, "js include path not set");
@@ -184,7 +184,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *))
smb_setup_ejs_param();
smb_setup_ejs_literal();
- shared_init = load_samba_modules(NULL, global_loadparm, "smbcalls");
+ shared_init = load_samba_modules(NULL, mprLpCtx(), "smbcalls");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index 89370890c8..908a009159 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -56,14 +56,14 @@ static int ejs_doauth(MprVarHandle eid,
} else {
/* Hope we can find the event context somewhere up there... */
ev = event_context_find(tmp_ctx);
- msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, global_loadparm),
- lp_iconv_convenience(global_loadparm), ev);
+ msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, mprLpCtx()),
+ lp_iconv_convenience(mprLpCtx()), ev);
}
if (auth_types) {
- nt_status = auth_context_create_methods(tmp_ctx, auth_types, ev, msg, global_loadparm, &auth_context);
+ nt_status = auth_context_create_methods(tmp_ctx, auth_types, ev, msg, mprLpCtx(), &auth_context);
} else {
- nt_status = auth_context_create(tmp_ctx, ev, msg, global_loadparm, &auth_context);
+ nt_status = auth_context_create(tmp_ctx, ev, msg, mprLpCtx(), &auth_context);
}
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
@@ -109,7 +109,7 @@ static int ejs_doauth(MprVarHandle eid,
goto done;
}
- nt_status = auth_generate_session_info(tmp_ctx, global_loadparm, server_info, &session_info);
+ nt_status = auth_generate_session_info(tmp_ctx, mprLpCtx(), server_info, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "report", mprString("Session Info generation failed"));
mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
@@ -222,7 +222,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
static int ejs_system_session(MprVarHandle eid, int argc, struct MprVar **argv)
{
struct MprVar *obj = mprInitObject(eid, "session_info", argc, argv);
- struct auth_session_info *session_info = system_session(mprMemCtx(), global_loadparm);
+ struct auth_session_info *session_info = system_session(mprMemCtx(), mprLpCtx());
if (session_info == NULL) {
return -1;
diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c
index 8295a0879f..4f2d52b25c 100644
--- a/source4/scripting/ejs/smbcalls_cli.c
+++ b/source4/scripting/ejs/smbcalls_cli.c
@@ -432,23 +432,23 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
/* Set up credentials */
creds = cli_credentials_init(NULL);
- cli_credentials_set_conf(creds, global_loadparm);
+ cli_credentials_set_conf(creds, mprLpCtx());
cli_credentials_parse_string(creds, argv[1], CRED_SPECIFIED);
/* Do connect */
io.in.dest_host = hostname;
- io.in.dest_ports = lp_smb_ports(global_loadparm);
+ io.in.dest_ports = lp_smb_ports(mprLpCtx());
io.in.called_name = strupper_talloc(mem_ctx, hostname);
io.in.service = sharename;
io.in.service_type = "?????";
io.in.credentials = creds;
io.in.fallback_to_anonymous = false;
- io.in.workgroup = lp_workgroup(global_loadparm);
+ io.in.workgroup = lp_workgroup(mprLpCtx());
lp_smbcli_options(global_loadparm, &io.in.options);
result = smb_composite_connect(&io, mem_ctx,
- lp_resolve_context(global_loadparm),
+ lp_resolve_context(mprLpCtx()),
NULL);
tree = io.out.tree;
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 07e0f479da..eb673b3a23 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -36,8 +36,8 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
const char **list = NULL;
if (argc != 0) return -1;
- for (i=0;i<lp_numservices(global_loadparm);i++) {
- list = str_list_add(list, lp_servicename(lp_servicebynum(global_loadparm, i)));
+ for (i=0;i<lp_numservices(mprLpCtx());i++) {
+ list = str_list_add(list, lp_servicename(lp_servicebynum(mprLpCtx(), i)));
}
talloc_steal(mprMemCtx(), list);
mpr_Return(eid, mprList("services", list));
@@ -68,7 +68,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
if (argc == 2) {
struct loadparm_service *service;
/* its a share parameter */
- service = lp_service(global_loadparm, argv[0]);
+ service = lp_service(mprLpCtx(), argv[0]);
if (service == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -84,7 +84,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(global_loadparm, service, type, option);
+ value = lp_get_parametric(mprLpCtx(), service, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -98,7 +98,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(global_loadparm, service, parm);
+ parm_ptr = lp_parm_ptr(mprLpCtx(), service, parm);
} else if (strchr(argv[0], ':')) {
/* its a global parametric option */
const char *type = talloc_strndup(mprMemCtx(),
@@ -109,7 +109,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(global_loadparm, NULL, type, option);
+ value = lp_get_parametric(mprLpCtx(), NULL, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -123,7 +123,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(global_loadparm, NULL, parm);
+ parm_ptr = lp_parm_ptr(mprLpCtx(), NULL, parm);
}
if (parm == NULL || parm_ptr == NULL) {
@@ -166,7 +166,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_lpFilename(MprVarHandle eid, int argc, char **argv)
{
- mpr_ReturnString(eid, lp_configfile(global_loadparm));
+ mpr_ReturnString(eid, lp_configfile(mprLpCtx()));
return 0;
}
@@ -184,7 +184,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
return -1;
}
- mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(global_loadparm, argv[0], argv[1])));
+ mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(mprLpCtx(), argv[0], argv[1])));
return 0;
}
@@ -196,9 +196,9 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
{
bool ret;
- const char *filename = lp_configfile(global_loadparm);
+ const char *filename = lp_configfile(mprLpCtx());
- ret = lp_load(global_loadparm, filename);
+ ret = lp_load(mprLpCtx(), filename);
mpr_Return(eid, mprCreateBoolVar(ret));
return 0;
}
diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c
index 6dfff8f925..fd73f0751f 100644
--- a/source4/scripting/ejs/smbcalls_creds.c
+++ b/source4/scripting/ejs/smbcalls_creds.c
@@ -192,7 +192,7 @@ static int ejs_creds_set_machine_account(MprVarHandle eid, int argc, struct MprV
return -1;
}
- if (NT_STATUS_IS_OK(cli_credentials_set_machine_account(creds, global_loadparm))) {
+ if (NT_STATUS_IS_OK(cli_credentials_set_machine_account(creds, mprLpCtx()))) {
mpr_Return(eid, mprCreateBoolVar(true));
} else {
mpr_Return(eid, mprCreateBoolVar(false));
@@ -248,7 +248,7 @@ static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv
return -1;
}
- cli_credentials_set_conf(creds, global_loadparm);
+ cli_credentials_set_conf(creds, mprLpCtx());
return ejs_credentials_obj(obj, creds);
}
diff --git a/source4/scripting/ejs/smbcalls_data.c b/source4/scripting/ejs/smbcalls_data.c
index 3ea41d46fb..19e1e173d6 100644
--- a/source4/scripting/ejs/smbcalls_data.c
+++ b/source4/scripting/ejs/smbcalls_data.c
@@ -177,7 +177,7 @@ static int ejs_regToVar(MprVarHandle eid, int argc, struct MprVar **argv)
case REG_EXPAND_SZ: {
char *s;
ssize_t len;
- len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
+ len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(mprLpCtx()), CH_UTF16, CH_UNIX,
blob->data, blob->length, (void **)&s);
if (len == -1) {
ejsSetErrorMsg(eid, "regToVar invalid REG_SZ string");
@@ -225,7 +225,7 @@ static int ejs_regToVar(MprVarHandle eid, int argc, struct MprVar **argv)
if (slen == 2 && b.length == 2 && SVAL(b.data, 0) == 0) {
break;
}
- len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
+ len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(mprLpCtx()), CH_UTF16, CH_UNIX,
b.data, slen, (void **)&s);
if (len == -1) {
ejsSetErrorMsg(eid, "regToVar invalid REG_MULTI_SZ string");
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index 7599cbf443..f47920b9bb 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -453,7 +453,7 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv)
dbfile = argv[0];
- ldb = ldb_wrap_connect(mprMemCtx(), global_loadparm, dbfile,
+ ldb = ldb_wrap_connect(mprMemCtx(), mprLpCtx(), dbfile,
session_info, creds,
0, (const char **)(argv+1));
if (ldb == NULL) {
diff --git a/source4/scripting/ejs/smbcalls_nbt.c b/source4/scripting/ejs/smbcalls_nbt.c
index c3679b1ec7..67a85414ca 100644
--- a/source4/scripting/ejs/smbcalls_nbt.c
+++ b/source4/scripting/ejs/smbcalls_nbt.c
@@ -70,7 +70,7 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
result = 0;
- nt_status = resolve_name(lp_resolve_context(global_loadparm), &name, tmp_ctx, &reply_addr, event_context_find(tmp_ctx));
+ nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, event_context_find(tmp_ctx));
if (NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(argv[0], "value", mprString(reply_addr));
diff --git a/source4/scripting/ejs/smbcalls_reg.c b/source4/scripting/ejs/smbcalls_reg.c
index 30e5357cfb..e20d91ad2e 100644
--- a/source4/scripting/ejs/smbcalls_reg.c
+++ b/source4/scripting/ejs/smbcalls_reg.c
@@ -70,7 +70,7 @@ static int ejs_reg_open(MprVarHandle eid, int argc, struct MprVar **argv)
struct registry_context *rctx;
WERROR error;
- error = reg_open_samba(mprMemCtx(), &rctx, global_loadparm, NULL, NULL);
+ error = reg_open_samba(mprMemCtx(), &rctx, mprLpCtx(), NULL, NULL);
SMB_ASSERT(W_ERROR_IS_OK(error));
mprSetPtrChild(reg, "registry", rctx);
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 44cfa16d7e..d1e49b4348 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -79,9 +79,9 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
allocate temporary server ids automatically */
for (i=0;i<10000;i++) {
p->msg_ctx = messaging_init(p,
- lp_messaging_path(p, global_loadparm),
+ lp_messaging_path(p, mprLpCtx()),
cluster_id(EJS_ID_BASE, i),
- lp_iconv_convenience(global_loadparm),
+ lp_iconv_convenience(mprLpCtx()),
ev);
if (p->msg_ctx) break;
}
@@ -161,7 +161,7 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
ev = event_context_find(mprMemCtx());
status = dcerpc_pipe_connect(this, &p, binding, iface, creds, ev,
- global_loadparm);
+ mprLpCtx());
if (!NT_STATUS_IS_OK(status)) goto done;
/* callers don't allocate ref vars in the ejs interface */
diff --git a/source4/scripting/ejs/smbcalls_sys.c b/source4/scripting/ejs/smbcalls_sys.c
index 72ddf90231..00599a55bc 100644
--- a/source4/scripting/ejs/smbcalls_sys.c
+++ b/source4/scripting/ejs/smbcalls_sys.c
@@ -36,7 +36,7 @@ static int ejs_sys_interfaces(MprVarHandle eid, int argc, struct MprVar **argv)
struct MprVar ret = mprArray("interfaces");
struct interface *ifaces;
- load_interfaces(NULL, lp_interfaces(global_loadparm), &ifaces);
+ load_interfaces(NULL, lp_interfaces(mprLpCtx()), &ifaces);
count = iface_count(ifaces);
for (i=0;i<count;i++) {