summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/ejsrpc.c21
-rw-r--r--source4/scripting/ejs/ejsrpc.h2
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c19
-rw-r--r--source4/scripting/ejs/smbscript.c3
4 files changed, 16 insertions, 29 deletions
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index cd7e0c9211..f2c2b258e4 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -26,27 +26,6 @@
#include "librpc/gen_ndr/ndr_lsa.h"
#include "scripting/ejs/ejsrpc.h"
-NTSTATUS ejs_pull_rpc(int eid, const char *callname,
- struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull)
-{
- struct ejs_rpc *ejs = talloc(ptr, struct ejs_rpc);
- NT_STATUS_HAVE_NO_MEMORY(ejs);
- ejs->eid = eid;
- ejs->callname = callname;
- return ejs_pull(ejs, v, ptr);
-}
-
-
-NTSTATUS ejs_push_rpc(int eid, const char *callname,
- struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push)
-{
- struct ejs_rpc *ejs = talloc(ptr, struct ejs_rpc);
- NT_STATUS_HAVE_NO_MEMORY(ejs);
- ejs->eid = eid;
- ejs->callname = callname;
- return ejs_push(ejs, v, ptr);
-}
-
/*
set the switch var to be used by the next union switch
*/
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index 6914988bc8..e410535b6c 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -46,8 +46,6 @@ NTSTATUS smbcalls_register_ejs(const char *name,
int ejs_rpc_call(int eid, int argc, struct MprVar **argv, const char *callname,
ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push);
-NTSTATUS ejs_pull_rpc(int eid, const char *callname, struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull);
-NTSTATUS ejs_push_rpc(int eid, const char *callname, struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push);
NTSTATUS ejs_pull_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
NTSTATUS ejs_push_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 12b0d95e8e..8a5389fbab 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -105,6 +105,7 @@ done:
void *ptr;
struct rpc_request *req;
int callnum;
+ struct ejs_rpc *ejs;
if (argc != 2 ||
argv[0]->type != MPR_TYPE_OBJECT ||
@@ -132,15 +133,24 @@ done:
}
callnum = call - iface->calls;
+ ejs = talloc(mprMemCtx(), struct ejs_rpc);
+ if (ejs == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ ejs->eid = eid;
+ ejs->callname = callname;
+
/* allocate the C structure */
- ptr = talloc_zero_size(mprMemCtx(), call->struct_size);
+ ptr = talloc_zero_size(ejs, call->struct_size);
if (ptr == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
/* convert the mpr object into a C structure */
- status = ejs_pull_rpc(eid, callname, io, ptr, ejs_pull);
+ status = ejs_pull(ejs, io, ptr);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
@@ -154,7 +164,6 @@ done:
req = dcerpc_ndr_request_send(p, NULL, iface, callnum, ptr, ptr);
if (req == NULL) {
status = NT_STATUS_NO_MEMORY;
- talloc_free(ptr);
goto done;
}
status = dcerpc_ndr_request_recv(req);
@@ -164,10 +173,10 @@ done:
ndr_print_function_debug(call->ndr_print, call->name, NDR_OUT, ptr);
}
- status = ejs_push_rpc(eid, callname, io, ptr, ejs_push);
+ status = ejs_push(ejs, io, ptr);
- talloc_free(ptr);
done:
+ talloc_free(ejs);
ejsSetReturnValue(eid, mprNTSTATUS(status));
if (NT_STATUS_EQUAL(status, NT_STATUS_INTERNAL_ERROR)) {
return -1;
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index 244ae0b42a..f7556b5384 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -94,12 +94,13 @@ void ejs_exception(const char *reason)
for (i=1;argv[i];i++) {
argv_list = str_list_add(argv_list, argv[i]);
}
+ talloc_steal(mem_ctx, argv_list);
v = mprList("ARGV", argv_list);
mprSetPropertyValue(&v, "length", mprCreateIntegerVar(i-1));
mprCreateProperty(ejsGetGlobalObject(eid), "ARGV", &v);
/* load the script and advance past interpreter line*/
- script = file_load(fname, &script_size);
+ script = file_load(fname, &script_size, mem_ctx);
if ((script_size > 2) && script[0] == '#' && script[1] == '!') {
script += 2;