summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/pidl/ejs.pm11
-rw-r--r--source4/librpc/config.mk5
-rw-r--r--source4/scripting/ejs/ejsrpc.h7
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c58
4 files changed, 63 insertions, 18 deletions
diff --git a/source4/build/pidl/ejs.pm b/source4/build/pidl/ejs.pm
index f67379526f..8420f8fa87 100644
--- a/source4/build/pidl/ejs.pm
+++ b/source4/build/pidl/ejs.pm
@@ -674,13 +674,16 @@ sub EjsInterface($)
pidl "void setup_ejs_$name(void)";
pidl "{";
+ indent;
foreach (@fns) {
pidl "ejsDefineCFunction(-1, \"dcerpc_$_\", ejs_$_, NULL, MPR_VAR_SCRIPT_HANDLE);";
}
+ 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 "\"") {
@@ -689,6 +692,14 @@ sub EjsInterface($)
pidl "ejs_set_constant_int(eid, \"$v\", $value);";
}
}
+ deindent;
+ pidl "}\n";
+
+ pidl "NTSTATUS ejs_init_$name(void)";
+ pidl "{";
+ indent;
+ pidl "return smbcalls_register_ejs(\"$name\", setup_ejs_$name, setup_ejs_constants_$name);";
+ deindent;
pidl "}";
}
diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk
index c7d45bcf4b..b0af157714 100644
--- a/source4/librpc/config.mk
+++ b/source4/librpc/config.mk
@@ -552,26 +552,31 @@ REQUIRED_SUBSYSTEMS = NDR_RAW RPC_RAW LIBSMB NDR_MISC NDR_DCERPC NDR_SCHANNEL ND
################################################
[SUBSYSTEM::RPC_EJS_ECHO]
+INIT_FUNCTION = ejs_init_rpcecho
OBJ_FILES = librpc/gen_ndr/ndr_echo_ejs.o
REQUIRED_SUBSYSTEMS = RPC NDR_ECHO
NOPROTO = YES
[SUBSYSTEM::RPC_EJS_MISC]
+INIT_FUNCTION = ejs_init_misc
OBJ_FILES = librpc/gen_ndr/ndr_misc_ejs.o
REQUIRED_SUBSYSTEMS = RPC NDR_MISC
NOPROTO = YES
[SUBSYSTEM::RPC_EJS_SAMR]
+INIT_FUNCTION = ejs_init_samr
OBJ_FILES = librpc/gen_ndr/ndr_samr_ejs.o
REQUIRED_SUBSYSTEMS = RPC NDR_SAMR
NOPROTO = YES
[SUBSYSTEM::RPC_EJS_SECURITY]
+INIT_FUNCTION = ejs_init_security
OBJ_FILES = librpc/gen_ndr/ndr_security_ejs.o
REQUIRED_SUBSYSTEMS = RPC LIB_SECURITY_NDR
NOPROTO = YES
[SUBSYSTEM::RPC_EJS_LSA]
+INIT_FUNCTION = ejs_init_lsarpc
OBJ_FILES = librpc/gen_ndr/ndr_lsa_ejs.o
REQUIRED_SUBSYSTEMS = RPC NDR_LSA
NOPROTO = YES
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index c45b66d385..44b4b7dd96 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -36,6 +36,13 @@ 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,
+ ejs_setup_t setup,
+ ejs_constants_t constants);
+
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);
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 3c3b8515f1..12b0d95e8e 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -25,6 +25,7 @@
#include "librpc/gen_ndr/ndr_echo.h"
#include "lib/cmdline/popt_common.h"
#include "scripting/ejs/ejsrpc.h"
+#include "dlinklist.h"
/*
connect to an rpc server
@@ -175,22 +176,46 @@ done:
}
+/* a list of registered ejs rpc modules */
+static struct ejs_register {
+ struct ejs_register *next, *prev;
+ const char *name;
+ ejs_setup_t setup;
+ ejs_constants_t constants;
+} *ejs_registered;
+
+/*
+ register a generated ejs module
+*/
+ NTSTATUS smbcalls_register_ejs(const char *name,
+ ejs_setup_t setup,
+ ejs_constants_t constants)
+{
+ struct ejs_register *r;
+ void *ctx = ejs_registered;
+ if (ctx == NULL) {
+ ctx = talloc_autofree_context();
+ }
+ r = talloc(ctx, struct ejs_register);
+ NT_STATUS_HAVE_NO_MEMORY(r);
+ r->name = name;
+ r->setup = setup;
+ r->constants = constants;
+ DLIST_ADD(ejs_registered, r);
+ return NT_STATUS_OK;
+}
+
/*
setup C functions that be called from ejs
*/
void smb_setup_ejs_rpc(void)
{
- void setup_ejs_rpcecho(void);
- void setup_ejs_samr(void);
- void setup_ejs_misc(void);
- void setup_ejs_security(void);
+ struct ejs_register *r;
ejsDefineCFunction(-1, "rpc_connect", ejs_rpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
-
- setup_ejs_rpcecho();
- setup_ejs_samr();
- setup_ejs_misc();
- setup_ejs_security();
+ for (r=ejs_registered;r;r=r->next) {
+ r->setup();
+ }
}
/*
@@ -198,18 +223,15 @@ void smb_setup_ejs_rpc(void)
*/
void smb_setup_ejs_rpc_constants(int eid)
{
+ struct ejs_register *r;
struct MprVar v;
- void setup_ejs_constants_rpcecho(int);
- void setup_ejs_constants_samr(int);
- void setup_ejs_constants_misc(int);
- void setup_ejs_constants_security(int);
+ for (r=ejs_registered;r;r=r->next) {
+ r->constants(eid);
+ }
- setup_ejs_constants_rpcecho(eid);
- setup_ejs_constants_samr(eid);
- setup_ejs_constants_misc(eid);
- setup_ejs_constants_security(eid);
-
v = mprCreatePtrVar(NULL, "NULL");
mprSetProperty(ejsGetGlobalObject(eid), "NULL", &v);
}
+
+