summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-08-29 12:31:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:34:55 -0500
commit0549763600b26fadac443555e1cbec5680f91340 (patch)
tree9cf7587abd038fd83e050cc1aa4ce317cd4a6b6e /source4/scripting/ejs
parent054f206599e9d74de6429dc8f17d9c58342bcc98 (diff)
downloadsamba-0549763600b26fadac443555e1cbec5680f91340.tar.gz
samba-0549763600b26fadac443555e1cbec5680f91340.tar.bz2
samba-0549763600b26fadac443555e1cbec5680f91340.zip
r9735: More work on generating a valid Samba4 configuration using the
Samba3 data (both console and SWAT) (This used to be commit d569465dc4def55c27878028f2fc762960f453d8)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c121
1 files changed, 85 insertions, 36 deletions
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
index bad8a7e58e..66e1299566 100644
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ b/source4/scripting/ejs/smbcalls_samba3.c
@@ -26,14 +26,6 @@
#include "lib/samba3/samba3.h"
-#if 0
-
-struct samba3_secrets
-{
-};
-
-#endif
-
static struct MprVar mprRegistry(struct samba3_regdb *reg)
{
struct MprVar mpv = mprObject("registry"), ks, vs, k, v;
@@ -169,6 +161,37 @@ static struct MprVar mprAliases(struct samba3_groupdb *db)
return mpv;
}
+static struct MprVar mprDomainSecrets(struct samba3_domainsecrets *ds)
+{
+ struct MprVar v, e = mprObject("domainsecrets");
+ char *tmp;
+
+ mprSetVar(&e, "name", mprString(ds->name));
+
+ tmp = dom_sid_string(NULL, &ds->sid);
+ mprSetVar(&e, "sid", mprString(tmp));
+ talloc_free(tmp);
+
+ tmp = GUID_string(NULL, &ds->guid);
+ mprSetVar(&e, "guid", mprString(tmp));
+ talloc_free(tmp);
+
+ mprSetVar(&e, "plaintext_pw", mprString(ds->plaintext_pw));
+
+ mprSetVar(&e, "last_change_time", mprCreateIntegerVar(ds->last_change_time));
+ mprSetVar(&e, "sec_channel_type", mprCreateIntegerVar(ds->sec_channel_type));
+
+ v = mprObject("hash_pw");
+
+ mprSetVar(&v, "hash", mprData(ds->hash_pw.hash, 16));
+
+ mprSetVar(&v, "mod_time", mprCreateIntegerVar(ds->hash_pw.mod_time));
+
+ mprSetVar(&e, "hash_pw", v);
+
+ return e;
+}
+
static struct MprVar mprSecrets(struct samba3_secrets *sec)
{
struct MprVar mpv = mprObject("samba3_secrets"), es, e;
@@ -188,34 +211,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprSetVar(&mpv, "ldappws", es);
for (i = 0; i < sec->domain_count; i++) {
- char *tmp;
- struct MprVar v;
- e = mprObject("domainsecrets");
-
- mprSetVar(&e, "name", mprString(sec->domains[i].name));
-
- tmp = dom_sid_string(NULL, &sec->domains[i].sid);
- mprSetVar(&e, "sid", mprString(tmp));
- talloc_free(tmp);
-
- tmp = GUID_string(NULL, &sec->domains[i].guid);
- mprSetVar(&e, "guid", mprString(tmp));
- talloc_free(tmp);
-
- mprSetVar(&e, "plaintext_pw", mprString(sec->domains[i].plaintext_pw));
-
- mprSetVar(&e, "last_change_time", mprCreateIntegerVar(sec->domains[i].last_change_time));
- mprSetVar(&e, "sec_channel_type", mprCreateIntegerVar(sec->domains[i].sec_channel_type));
-
- v = mprObject("hash_pw");
-
- mprSetVar(&v, "hash", mprData(sec->domains[i].hash_pw.hash, 16));
-
- mprSetVar(&v, "mod_time", mprCreateIntegerVar(sec->domains[i].hash_pw.mod_time));
-
- mprSetVar(&e, "hash_pw", v);
-
- mprAddArray(&es, i, e);
+ mprAddArray(&es, i, mprDomainSecrets(&sec->domains[i]));
}
mprSetVar(&mpv, "domains", es);
@@ -381,6 +377,54 @@ static struct MprVar mprWinsEntries(struct samba3 *samba3)
return mpv;
}
+static int ejs_get_param(MprVarHandle eid, int argc, struct MprVar **argv)
+{
+ struct samba3 *samba3;
+ const char *tmp;
+
+ if (argc < 2) {
+ ejsSetErrorMsg(eid, "get_param invalid arguments");
+ return -1;
+ }
+
+ samba3 = mprGetThisPtr(eid, "samba3");
+ mprAssert(samba3);
+ tmp = samba3_get_param(samba3, mprToString(argv[0]), mprToString(argv[1]));
+
+ if (tmp == NULL) {
+ mpr_Return(eid, mprCreateUndefinedVar());
+ } else {
+ mpr_Return(eid, mprString(tmp));
+ }
+
+ return 0;
+}
+
+static int ejs_find_domainsecrets(MprVarHandle eid, int argc, struct MprVar **argv)
+{
+ struct samba3 *samba3 = NULL;
+ struct samba3_domainsecrets *sec;
+
+ if (argc < 1) {
+ ejsSetErrorMsg(eid, "find_domainsecrets invalid arguments");
+ return -1;
+ }
+
+ samba3 = mprGetThisPtr(eid, "samba3");
+ mprAssert(samba3);
+ sec = samba3_find_domainsecrets(samba3, mprToString(argv[0]));
+
+ if (sec == NULL) {
+ mpr_Return(eid, mprCreateUndefinedVar());
+ } else {
+ mpr_Return(eid, mprDomainSecrets(sec));
+ }
+
+ return 0;
+}
+
+
+
/*
initialise samba3 ejs subsystem
*/
@@ -402,6 +446,9 @@ static int ejs_samba3_read(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
+ mprAssert(samba3);
+
+ mprSetThisPtr(eid, "samba3", samba3);
mprSetVar(&mpv, "winsentries", mprWinsEntries(samba3));
mprSetVar(&mpv, "samaccounts", mprSamAccounts(samba3));
mprSetVar(&mpv, "shares", mprShares(samba3));
@@ -411,6 +458,8 @@ static int ejs_samba3_read(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetVar(&mpv, "idmapdb", mprIdmapDb(&samba3->idmap));
mprSetVar(&mpv, "policy", mprPolicy(&samba3->policy));
mprSetVar(&mpv, "registry", mprRegistry(&samba3->registry));
+ mprSetCFunction(&mpv, "get_param", ejs_get_param);
+ mprSetCFunction(&mpv, "find_domainsecrets", ejs_find_domainsecrets);
mpr_Return(eid, mpv);