summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c61
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c4
2 files changed, 63 insertions, 2 deletions
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index aaed14dd8c..662da0d971 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -4,6 +4,7 @@
provide hooks into smbd C calls from ejs scripts
Copyright (C) Andrew Tridgell 2005
+ Copyright (C) Jelmer Vernooij 2005
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -247,6 +248,64 @@ static int ejs_ldbErrstring(MprVarHandle eid, int argc, struct MprVar **argv)
return 0;
}
+/*
+ base64 encode
+ usage:
+ dataout = ldb.encode(datain)
+ */
+static int ejs_base64encode(MprVarHandle eid, int argc, struct MprVar **argv)
+{
+ char *ret;
+ DATA_BLOB *blob;
+
+ if (argc != 1) {
+ ejsSetErrorMsg(eid, "ldb.base64encode invalid argument count");
+ return -1;
+ }
+
+ blob = mprToDataBlob(argv[0]);
+ ret = ldb_base64_encode(mprMemCtx(), (char *)blob->data, blob->length);
+
+ if (!ret) {
+ mpr_Return(eid, mprCreateUndefinedVar());
+ } else {
+ mpr_Return(eid, mprString(ret));
+ }
+
+ talloc_free(ret);
+
+ return 0;
+}
+
+/*
+ base64 decode
+ usage:
+ dataout = ldb.decode(datain)
+ */
+static int ejs_base64decode(MprVarHandle eid, int argc, struct MprVar **argv)
+{
+ char *tmp;
+ int ret;
+
+ if (argc != 1) {
+ ejsSetErrorMsg(eid, "ldb.base64encode invalid argument count");
+ return -1;
+ }
+
+ tmp = talloc_strdup(mprMemCtx(), mprToString(argv[0]));
+ ret = ldb_base64_decode(tmp);
+ if (ret == -1) {
+ mpr_Return(eid, mprCreateUndefinedVar());
+ } else {
+ mpr_Return(eid, mprData((uint8_t *)tmp, ret));
+ }
+
+ talloc_free(tmp);
+
+ return 0;
+}
+
+
/*
perform an ldb modify
@@ -312,6 +371,8 @@ static int ejs_ldb_init(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetCFunction(ldb, "del", ejs_ldbDelete);
mprSetCFunction(ldb, "rename", ejs_ldbRename);
mprSetCFunction(ldb, "errstring", ejs_ldbErrstring);
+ mprSetCFunction(ldb, "encode", ejs_base64encode);
+ mprSetCFunction(ldb, "decode", ejs_base64decode);
mprSetVar(ldb, "SCOPE_BASE", mprCreateNumberVar(LDB_SCOPE_BASE));
mprSetVar(ldb, "SCOPE_ONE", mprCreateNumberVar(LDB_SCOPE_ONELEVEL));
mprSetVar(ldb, "SCOPE_SUBTREE", mprCreateNumberVar(LDB_SCOPE_SUBTREE));
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
index e6f6481060..eb37168bc8 100644
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ b/source4/scripting/ejs/smbcalls_samba3.c
@@ -343,8 +343,8 @@ static struct MprVar mprSamAccounts(struct samba3 *samba3)
mprSetVar(&m, "profile_path", mprString(a->profile_path));
mprSetVar(&m, "acct_desc", mprString(a->acct_desc));
mprSetVar(&m, "workstations", mprString(a->workstations));
-
- /* FIXME: lm_pw_ptr, nt_pw_ptr */
+ mprSetVar(&m, "lm_pw", mprData(a->lm_pw.hash, 16));
+ mprSetVar(&m, "nt_pw", mprData(a->nt_pw.hash, 16));
mprAddArray(&mpv, i, m);
}