diff options
-rw-r--r-- | source4/build/pidl/Parse/Pidl/Samba/EJS.pm | 20 | ||||
-rw-r--r-- | source4/lib/appweb/ejs/ejsProcs.c | 1 | ||||
-rw-r--r-- | source4/scripting/ejs/ejsrpc.c | 19 | ||||
-rw-r--r-- | source4/scripting/ejs/ejsrpc.h | 7 | ||||
-rw-r--r-- | source4/scripting/ejs/smbcalls.c | 7 | ||||
-rw-r--r-- | source4/scripting/ejs/smbcalls.h | 1 | ||||
-rw-r--r-- | source4/scripting/ejs/smbcalls_rpc.c | 30 | ||||
-rw-r--r-- | source4/scripting/ejs/smbscript.c | 2 | ||||
-rw-r--r-- | source4/scripting/libjs/samr.js | 29 | ||||
-rw-r--r-- | source4/web_server/http.c | 2 | ||||
-rwxr-xr-x | testprogs/ejs/echo.js | 38 | ||||
-rwxr-xr-x | testprogs/ejs/nbtstats | 5 |
12 files changed, 54 insertions, 107 deletions
diff --git a/source4/build/pidl/Parse/Pidl/Samba/EJS.pm b/source4/build/pidl/Parse/Pidl/Samba/EJS.pm index d2d8b41507..0aa8de7c93 100644 --- a/source4/build/pidl/Parse/Pidl/Samba/EJS.pm +++ b/source4/build/pidl/Parse/Pidl/Samba/EJS.pm @@ -689,33 +689,30 @@ sub EjsInterface($$) EjsConst($d); } - pidl "void setup_ejs_$name(void)"; + pidl "static int ejs_$name\_init(int eid, int argc, struct MprVar **argv)"; pidl "{"; indent; + pidl "struct MprVar obj = mprObject(\"$name\");"; foreach (@fns) { - pidl "ejsDefineCFunction(-1, \"dcerpc_$_\", ejs_$_, NULL, MPR_VAR_SCRIPT_HANDLE);"; + pidl "mprSetCFunction(&obj, \"$_\", ejs_$_);"; } - deindent; - pidl "}\n"; - - pidl "void setup_ejs_constants_$name(int eid)"; - pidl "{"; - indent; foreach my $v (keys %constants) { my $value = $constants{$v}; if (substr($value, 0, 1) eq "\"") { - pidl "ejs_set_constant_string(eid, \"$v\", $value);"; + pidl "mprSetVar(&obj, \"$v\", mprString($value));"; } else { - pidl "ejs_set_constant_int(eid, \"$v\", $value);"; + pidl "mprSetVar(&obj, \"$v\", mprCreateNumberVar($value));"; } } + pidl "mpr_Return(eid, obj);"; + pidl "return 0;"; deindent; pidl "}\n"; pidl "NTSTATUS ejs_init_$name(void)"; pidl "{"; indent; - pidl "return smbcalls_register_ejs(\"$name\", setup_ejs_$name, setup_ejs_constants_$name);"; + pidl "return smbcalls_register_ejs(\"$name\_init\", ejs_$name\_init);"; deindent; pidl "}"; } @@ -734,6 +731,7 @@ sub Parse($$) #include \"includes.h\" #include \"lib/appweb/ejs/ejs.h\" #include \"scripting/ejs/ejsrpc.h\" +#include \"scripting/ejs/smbcalls.h\" #include \"librpc/gen_ndr/ndr_misc_ejs.h\" #include \"$hdr\" #include \"$ejs_hdr\" diff --git a/source4/lib/appweb/ejs/ejsProcs.c b/source4/lib/appweb/ejs/ejsProcs.c index c01f411161..adef6e898a 100644 --- a/source4/lib/appweb/ejs/ejsProcs.c +++ b/source4/lib/appweb/ejs/ejsProcs.c @@ -629,6 +629,7 @@ int ejsDefineStandardProperties(MprVar *obj) mprCreatePropertyValue(obj, "undefined", mprCreateUndefinedVar()); mprCreatePropertyValue(obj, "true", mprCreateBoolVar(1)); mprCreatePropertyValue(obj, "false", mprCreateBoolVar(0)); + mprCreatePropertyValue(obj, "NULL", mprCreatePtrVar(NULL)); #if BLD_FEATURE_LEGACY_API /* diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c index e152c8fcd1..08bc4a94ba 100644 --- a/source4/scripting/ejs/ejsrpc.c +++ b/source4/scripting/ejs/ejsrpc.c @@ -229,25 +229,6 @@ NTSTATUS ejs_push_string(struct ejs_rpc *ejs, return mprSetVar(v, name, mprString(s)); } -/* - setup a constant int -*/ -void ejs_set_constant_int(int eid, const char *name, int value) -{ - struct MprVar *v = ejsGetGlobalObject(eid); - mprSetVar(v, name, mprCreateIntegerVar(value)); -} - -/* - setup a constant string -*/ -void ejs_set_constant_string(int eid, const char *name, const char *value) -{ - struct MprVar *v = ejsGetGlobalObject(eid); - mprSetVar(v, name, mprCreateStringVar(value, False)); -} - - NTSTATUS ejs_pull_dom_sid(struct ejs_rpc *ejs, struct MprVar *v, const char *name, struct dom_sid *r) { diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h index e4b623750d..dbd147fe1d 100644 --- a/source4/scripting/ejs/ejsrpc.h +++ b/source4/scripting/ejs/ejsrpc.h @@ -36,12 +36,8 @@ typedef NTSTATUS (*ejs_push_function_t)(struct ejs_rpc *, struct MprVar *, const NTSTATUS ejs_panic(struct ejs_rpc *ejs, const char *why); void ejs_set_switch(struct ejs_rpc *ejs, uint32_t switch_var); -typedef void (*ejs_setup_t)(void); -typedef void (*ejs_constants_t)(int); +NTSTATUS smbcalls_register_ejs(const char *name, MprCFunction fn); -NTSTATUS smbcalls_register_ejs(const char *name, - ejs_setup_t setup, - ejs_constants_t constants); int ejs_rpc_call(int eid, int argc, struct MprVar **argv, const struct dcerpc_interface_table *iface, int callnum, @@ -120,3 +116,4 @@ BOOL ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name); #define ejs_push_dom_sid2 ejs_push_dom_sid #define ejs_pull_NTTIME_hyper ejs_pull_NTTIME #define ejs_push_NTTIME_hyper ejs_push_NTTIME + diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 49bcc64c96..59e5b17034 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -132,10 +132,3 @@ void smb_setup_ejs_functions(void) ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); } -/* - setup constants that can be used from ejs -*/ -void smb_setup_ejs_constants(int eid) -{ - smb_setup_ejs_rpc_constants(eid); -} diff --git a/source4/scripting/ejs/smbcalls.h b/source4/scripting/ejs/smbcalls.h index aa5c27b4f5..927c3ccf2f 100644 --- a/source4/scripting/ejs/smbcalls.h +++ b/source4/scripting/ejs/smbcalls.h @@ -28,4 +28,3 @@ NTSTATUS mprGetVar(struct MprVar **v, const char *name); void mprAddArray(struct MprVar *var, int i, struct MprVar v); void mprSetCFunction(struct MprVar *obj, const char *name, MprCFunction fn); void mprSetStringCFunction(struct MprVar *obj, const char *name, MprStringCFunction fn); - diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c index ccb2026446..8e7bf57972 100644 --- a/source4/scripting/ejs/smbcalls_rpc.c +++ b/source4/scripting/ejs/smbcalls_rpc.c @@ -361,16 +361,13 @@ done: static struct ejs_register { struct ejs_register *next, *prev; const char *name; - ejs_setup_t setup; - ejs_constants_t constants; + MprCFunction fn; } *ejs_registered; /* register a generated ejs module */ - NTSTATUS smbcalls_register_ejs(const char *name, - ejs_setup_t setup, - ejs_constants_t constants) + NTSTATUS smbcalls_register_ejs(const char *name, MprCFunction fn) { struct ejs_register *r; void *ctx = ejs_registered; @@ -380,8 +377,7 @@ static struct ejs_register { r = talloc(ctx, struct ejs_register); NT_STATUS_HAVE_NO_MEMORY(r); r->name = name; - r->setup = setup; - r->constants = constants; + r->fn = fn; DLIST_ADD(ejs_registered, r); return NT_STATUS_OK; } @@ -396,24 +392,6 @@ void smb_setup_ejs_rpc(void) ejsDefineCFunction(-1, "rpc_connect", ejs_rpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "irpc_connect", ejs_irpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE); for (r=ejs_registered;r;r=r->next) { - r->setup(); + ejsDefineCFunction(-1, r->name, r->fn, NULL, MPR_VAR_SCRIPT_HANDLE); } } - -/* - setup constants for rpc calls -*/ -void smb_setup_ejs_rpc_constants(int eid) -{ - struct ejs_register *r; - struct MprVar v; - - for (r=ejs_registered;r;r=r->next) { - r->constants(eid); - } - - v = mprCreatePtrVar(NULL); - mprSetProperty(ejsGetGlobalObject(eid), "NULL", &v); -} - - diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index d71d084779..8359629a85 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -71,8 +71,6 @@ void ejs_exception(const char *reason) exit(127); } - smb_setup_ejs_constants(eid); - /* setup ARGV[] in the ejs environment */ for (i=1;argv[i];i++) { argv_list = str_list_add(argv_list, argv[i]); diff --git a/source4/scripting/libjs/samr.js b/source4/scripting/libjs/samr.js index a1f79b541a..2363dde686 100644 --- a/source4/scripting/libjs/samr.js +++ b/source4/scripting/libjs/samr.js @@ -18,7 +18,7 @@ function samArray(output) if (output.sam == NULL) { return list; } - var entries = output.sam.entries; + var i, entries = output.sam.entries; for (i=0;i<output.num_entries;i++) { list[i] = new Object(); list[i].name = entries[i].name; @@ -32,10 +32,12 @@ function samArray(output) */ function samrConnect(conn) { + conn.samr = samr_init(); + conn.sec = security_init(); var io = irpcObj(); io.input.system_name = NULL; - io.input.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - status = dcerpc_samr_Connect(conn, io); + io.input.access_mask = conn.sec.SEC_FLAG_MAXIMUM_ALLOWED; + var status = conn.samr.samr_Connect2(conn, io); check_status_ok(status); return io.output.connect_handle; } @@ -47,7 +49,7 @@ function samrClose(conn, handle) { var io = irpcObj(); io.input.handle = handle; - status = dcerpc_samr_Close(conn, io); + var status = conn.samr.samr_Close(conn, io); check_status_ok(status); } @@ -59,7 +61,7 @@ function samrLookupDomain(conn, handle, domain) var io = irpcObj(); io.input.connect_handle = handle; io.input.domain_name = domain; - status = dcerpc_samr_LookupDomain(conn, io); + var status = conn.samr.samr_LookupDomain(conn, io); check_status_ok(status); return io.output.sid; } @@ -71,9 +73,9 @@ function samrOpenDomain(conn, handle, sid) { var io = irpcObj(); io.input.connect_handle = handle; - io.input.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + io.input.access_mask = conn.sec.SEC_FLAG_MAXIMUM_ALLOWED; io.input.sid = sid; - status = dcerpc_samr_OpenDomain(conn, io); + var status = conn.samr.samr_OpenDomain(conn, io); check_status_ok(status); return io.output.domain_handle; } @@ -85,9 +87,9 @@ function samrOpenUser(conn, handle, rid) { var io = irpcObj(); io.input.domain_handle = handle; - io.input.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + io.input.access_mask = conn.sec.SEC_FLAG_MAXIMUM_ALLOWED; io.input.rid = rid; - status = dcerpc_samr_OpenUser(conn, io); + var status = conn.samr.samr_OpenUser(conn, io); check_status_ok(status); return io.output.user_handle; } @@ -102,7 +104,7 @@ function samrEnumDomainUsers(conn, dom_handle) io.input.resume_handle = 0; io.input.acct_flags = 0; io.input.max_size = -1; - status = dcerpc_samr_EnumDomainUsers(conn, io); + var status = conn.samr.samr_EnumDomainUsers(conn, io); check_status_ok(status); return samArray(io.output); } @@ -117,7 +119,7 @@ function samrEnumDomainGroups(conn, dom_handle) io.input.resume_handle = 0; io.input.acct_flags = 0; io.input.max_size = -1; - status = dcerpc_samr_EnumDomainGroups(conn, io); + var status = conn.samr.samr_EnumDomainGroups(conn, io); check_status_ok(status); return samArray(io.output); } @@ -131,7 +133,7 @@ function samrEnumDomains(conn, handle) io.input.connect_handle = handle; io.input.resume_handle = 0; io.input.buf_size = -1; - status = dcerpc_samr_EnumDomains(conn, io); + var status = conn.samr.samr_EnumDomains(conn, io); check_status_ok(status); return samArray(io.output); } @@ -144,7 +146,7 @@ function samrQueryUserInfo(conn, user_handle, level) var r, io = irpcObj(); io.input.user_handle = user_handle; io.input.level = level; - status = dcerpc_samr_QueryUserInfo(conn, io); + var status = conn.samr.samr_QueryUserInfo(conn, io); check_status_ok(status); return io.output.info.info3; } @@ -167,4 +169,3 @@ function samrFillUserInfo(conn, dom_handle, users, level) } } - diff --git a/source4/web_server/http.c b/source4/web_server/http.c index d6d8196ced..ec4b7770a6 100644 --- a/source4/web_server/http.c +++ b/source4/web_server/http.c @@ -822,8 +822,6 @@ void http_process_input(struct websrv_context *web) esp->req = espCreateRequest(web, web->input.url, esp->variables); if (esp->req == NULL) goto internal_error; - smb_setup_ejs_constants(esp->req->eid); - /* work out the mime type */ p = strrchr(web->input.url, '.'); if (p == NULL) { diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js index e5b0b2b1bf..d464f8623e 100755 --- a/testprogs/ejs/echo.js +++ b/testprogs/ejs/echo.js @@ -16,6 +16,8 @@ if (ok == false) { libinclude("base.js"); +echo = rpcecho_init(); + /* generate a ramp as an integer array */ @@ -40,7 +42,7 @@ function test_AddOne(conn) for (i=0;i<10;i++) { io.input.in_data = i; - status = dcerpc_echo_AddOne(conn, io); + status = echo.echo_AddOne(conn, io); check_status_ok(status); assert(io.output.out_data == i + 1); } @@ -58,7 +60,7 @@ function test_EchoData(conn) for (i=0; i<30; i=i+5) { io.input.len = i; io.input.in_data = ramp_array(i); - status = dcerpc_echo_EchoData(conn, io); + status = echo.echo_EchoData(conn, io); check_status_ok(status); check_array_equal(io.input.in_data, io.output.out_data); } @@ -77,7 +79,7 @@ function test_SinkData(conn) for (i=0; i<30; i=i+5) { io.input.len = i; io.input.data = ramp_array(i); - status = dcerpc_echo_SinkData(conn, io); + status = echo.echo_SinkData(conn, io); check_status_ok(status); } } @@ -94,7 +96,7 @@ function test_SourceData(conn) for (i=0; i<30; i=i+5) { io.input.len = i; - status = dcerpc_echo_SourceData(conn, io); + status = echo.echo_SourceData(conn, io); check_status_ok(status); correct = ramp_array(i); check_array_equal(correct, io.output.data); @@ -112,7 +114,7 @@ function test_TestCall(conn) print("Testing echo_TestCall\n"); io.input.s1 = "my test string"; - status = dcerpc_echo_TestCall(conn, io); + status = echo.echo_TestCall(conn, io); check_status_ok(status); assert("this is a test string" == io.output.s2); } @@ -128,7 +130,7 @@ function test_TestCall2(conn) for (i=1;i<=7;i++) { io.input.level = i; - status = dcerpc_echo_TestCall2(conn, io); + status = echo.echo_TestCall2(conn, io); check_status_ok(status); } } @@ -143,7 +145,7 @@ function test_TestSleep(conn) print("Testing echo_TestSleep\n"); io.input.seconds = 1; - status = dcerpc_echo_TestSleep(conn, io); + status = echo.echo_TestSleep(conn, io); check_status_ok(status); } @@ -156,18 +158,18 @@ function test_TestEnum(conn) print("Testing echo_TestEnum\n"); - io.input.foo1 = ECHO_ENUM1; + io.input.foo1 = echo.ECHO_ENUM1; io.input.foo2 = new Object(); - io.input.foo2.e1 = ECHO_ENUM1; - io.input.foo2.e2 = ECHO_ENUM1_32; + io.input.foo2.e1 = echo.ECHO_ENUM1; + io.input.foo2.e2 = echo.ECHO_ENUM1_32; io.input.foo3 = new Object(); - io.input.foo3.e1 = ECHO_ENUM2; - status = dcerpc_echo_TestEnum(conn, io); + io.input.foo3.e1 = echo.ECHO_ENUM2; + status = echo.echo_TestEnum(conn, io); check_status_ok(status); - assert(io.output.foo1 == ECHO_ENUM1); - assert(io.output.foo2.e1 == ECHO_ENUM2); - assert(io.output.foo2.e2 == ECHO_ENUM1_32); - assert(io.output.foo3.e1 == ECHO_ENUM2); + assert(io.output.foo1 == echo.ECHO_ENUM1); + assert(io.output.foo2.e1 == echo.ECHO_ENUM2); + assert(io.output.foo2.e2 == echo.ECHO_ENUM1_32); + assert(io.output.foo3.e1 == echo.ECHO_ENUM2); } /* @@ -182,7 +184,7 @@ function test_TestSurrounding(conn) io.input.data = new Object(); io.input.data.x = 10; io.input.data.surrounding = ramp_array(10); - status = dcerpc_echo_TestSurrounding(conn, io); + status = echo.echo_TestSurrounding(conn, io); check_status_ok(status); assert(io.output.data.surrounding.length == 20); check_array_zero(io.output.data.surrounding); @@ -198,7 +200,7 @@ function test_TestDoublePointer(conn) print("Testing echo_TestDoublePointer\n"); io.input.data = 7; - status = dcerpc_echo_TestDoublePointer(conn, io); + status = echo.echo_TestDoublePointer(conn, io); check_status_ok(status); assert(io.input.data == io.input.data); } diff --git a/testprogs/ejs/nbtstats b/testprogs/ejs/nbtstats index fe93a728cd..20bc781f03 100755 --- a/testprogs/ejs/nbtstats +++ b/testprogs/ejs/nbtstats @@ -14,14 +14,15 @@ if (ok == false) { } var conn = new Object(); +var irpc = irpc_init(); status = irpc_connect(conn, "nbt_server"); assert(status.is_ok == true); io = new Object(); io.input = new Object(); -io.input.level = NBTD_INFO_STATISTICS; -status = dcerpc_nbtd_information(conn, io); +io.input.level = irpc.NBTD_INFO_STATISTICS; +status = irpc.nbtd_information(conn, io); assert(status.is_ok == true); assert(io.results.length == 1); |