summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/ejs/config.mk2
-rw-r--r--source4/scripting/ejs/ejsrpc.c108
-rw-r--r--source4/scripting/ejs/ejsrpc.h25
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c13
4 files changed, 143 insertions, 5 deletions
diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk
index 0c0caa9ef0..f56b75e537 100644
--- a/source4/scripting/ejs/config.mk
+++ b/source4/scripting/ejs/config.mk
@@ -3,7 +3,7 @@
[SUBSYSTEM::EJSRPC]
OBJ_FILES = \
scripting/ejs/ejsrpc.o
-REQUIRED_SUBSYSTEMS = RPC_EJS_ECHO
+REQUIRED_SUBSYSTEMS = RPC_EJS_ECHO RPC_EJS_SAMR RPC_EJS_MISC RPC_EJS_SECURITY RPC_EJS_LSA
NOPROTO = YES
# End SUBSYSTEM EJSRPC
#######################
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index 6536b94ca4..ab0f64d5aa 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "lib/ejs/ejs.h"
#include "scripting/ejs/ejsrpc.h"
+#include "librpc/gen_ndr/ndr_security.h"
NTSTATUS ejs_pull_rpc(int eid, const char *callname,
struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull)
@@ -235,6 +236,63 @@ NTSTATUS ejs_push_hyper(struct ejs_rpc *ejs,
return mprSetVar(v, name, mprCreateIntegerVar(*r));
}
+NTSTATUS ejs_pull_dlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, uint64_t *r)
+{
+ struct MprVar *var;
+ var = mprGetVar(v, name);
+ if (var == NULL) {
+ DEBUG(1,("ejs_pull_dlong: unable to find '%s'\n", name));
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ }
+ *r = mprVarToInteger(var);
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ejs_push_dlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const uint64_t *r)
+{
+ return mprSetVar(v, name, mprCreateIntegerVar(*r));
+}
+
+NTSTATUS ejs_pull_udlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, uint64_t *r)
+{
+ struct MprVar *var;
+ var = mprGetVar(v, name);
+ if (var == NULL) {
+ DEBUG(1,("ejs_pull_udlong: unable to find '%s'\n", name));
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ }
+ *r = mprVarToInteger(var);
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ejs_push_udlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const uint64_t *r)
+{
+ return mprSetVar(v, name, mprCreateIntegerVar(*r));
+}
+
+NTSTATUS ejs_pull_NTTIME(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, uint64_t *r)
+{
+ struct MprVar *var;
+ var = mprGetVar(v, name);
+ if (var == NULL) {
+ DEBUG(1,("ejs_pull_NTTIME: unable to find '%s'\n", name));
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ }
+ *r = mprVarToInteger(var);
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ejs_push_NTTIME(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const uint64_t *r)
+{
+ return mprSetVar(v, name, mprCreateIntegerVar(*r));
+}
+
/*
pull a enum from a mpr variable to a C element
@@ -265,7 +323,7 @@ NTSTATUS ejs_push_enum(struct ejs_rpc *ejs,
pull a string
*/
NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, char **s)
+ struct MprVar *v, const char *name, const char **s)
{
struct MprVar *var;
var = mprGetVar(v, name);
@@ -273,8 +331,7 @@ NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
DEBUG(1,("ejs_pull_string: unable to find '%s'\n", name));
return NT_STATUS_INVALID_PARAMETER_MIX;
}
- *s = talloc_strdup(ejs, mprToString(var));
- NT_STATUS_HAVE_NO_MEMORY(*s);
+ *s = mprToString(var);
return NT_STATUS_OK;
}
@@ -304,3 +361,48 @@ 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)
+{
+ struct MprVar *var;
+ struct dom_sid *sid;
+ var = mprGetVar(v, name);
+ if (var == NULL) {
+ DEBUG(1,("ejs_pull_dom_sid: unable to find '%s'\n", name));
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ }
+ sid = dom_sid_parse_talloc(ejs, mprToString(var));
+ NT_STATUS_HAVE_NO_MEMORY(sid);
+ *r = *sid;
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ejs_push_dom_sid(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const struct dom_sid *r)
+{
+ char *sidstr = dom_sid_string(ejs, r);
+ NT_STATUS_HAVE_NO_MEMORY(sidstr);
+ return mprSetVar(v, name, mprCreateStringVar(sidstr, True));
+}
+
+NTSTATUS ejs_pull_GUID(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, struct GUID *r)
+{
+ struct MprVar *var;
+ var = mprGetVar(v, name);
+ if (var == NULL) {
+ DEBUG(1,("ejs_pull_GUID: unable to find '%s'\n", name));
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ }
+ return GUID_from_string(mprToString(var), r);
+}
+
+NTSTATUS ejs_push_GUID(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const struct GUID *r)
+{
+ char *guid = GUID_string(ejs, r);
+ NT_STATUS_HAVE_NO_MEMORY(guid);
+ return mprSetVar(v, name, mprCreateStringVar(guid, True));
+}
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index 0435b52365..624a5fad3d 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -60,17 +60,34 @@ NTSTATUS ejs_pull_hyper(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, uint64_t *r);
NTSTATUS ejs_push_hyper(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const uint64_t *r);
+NTSTATUS ejs_pull_dlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, uint64_t *r);
+NTSTATUS ejs_push_dlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const uint64_t *r);
+NTSTATUS ejs_pull_udlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, uint64_t *r);
+NTSTATUS ejs_push_udlong(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const uint64_t *r);
+NTSTATUS ejs_pull_NTTIME(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, uint64_t *r);
+NTSTATUS ejs_push_NTTIME(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const uint64_t *r);
NTSTATUS ejs_pull_enum(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, unsigned *r);
NTSTATUS ejs_push_enum(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const unsigned *r);
NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, char **s);
+ struct MprVar *v, const char *name, const char **s);
NTSTATUS ejs_push_string(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const char *s);
void ejs_set_constant_int(int eid, const char *name, int value);
void ejs_set_constant_string(int eid, const char *name, const char *value);
+NTSTATUS ejs_pull_dom_sid(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, struct dom_sid *r);
+NTSTATUS ejs_push_dom_sid(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const struct dom_sid *r);
+
#define EJS_ALLOC_SIZE(ejs, s, size) do { \
(s) = talloc_size(ejs, size); \
if (!(s)) return ejs_panic(ejs, "out of memory"); \
@@ -84,3 +101,9 @@ void ejs_set_constant_string(int eid, const char *name, const char *value);
} while (0)
#define EJS_ALLOC_N(ejs, s, n) EJS_ALLOC_N_SIZE(ejs, s, n, sizeof(*(s)))
+
+/* some types are equivalent for ejs */
+#define ejs_pull_dom_sid2 ejs_pull_dom_sid
+#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_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index f8ea37b754..17f1716b2e 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -170,8 +170,12 @@ done:
void smb_setup_ejs_rpc(void)
{
void setup_ejs_rpcecho(void);
+ void setup_ejs_samr(void);
+ void setup_ejs_misc(void);
ejsDefineCFunction(-1, "rpc_connect", ejs_rpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
setup_ejs_rpcecho();
+ setup_ejs_samr();
+ setup_ejs_misc();
}
/*
@@ -179,6 +183,15 @@ void smb_setup_ejs_rpc(void)
*/
void smb_setup_ejs_rpc_constants(int eid)
{
+ struct MprVar v;
+
void setup_ejs_constants_rpcecho(int);
+ void setup_ejs_constants_samr(int);
+ void setup_ejs_constants_misc(int);
setup_ejs_constants_rpcecho(eid);
+ setup_ejs_constants_samr(eid);
+ setup_ejs_constants_misc(eid);
+
+ v = mprCreatePtrVar(NULL, "NULL");
+ mprSetProperty(ejsGetGlobalObject(eid), "NULL", &v);
}