summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-08-29 00:48:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:34:53 -0500
commit176da2a2813aa00fed8a485548f98e61ffa9350c (patch)
tree0208fc40672291b5cf594c5f3368cbc828be1ec0 /source4
parentd152839e299e7e406bb938c5b413ad975a895d6f (diff)
downloadsamba-176da2a2813aa00fed8a485548f98e61ffa9350c.tar.gz
samba-176da2a2813aa00fed8a485548f98e61ffa9350c.tar.bz2
samba-176da2a2813aa00fed8a485548f98e61ffa9350c.zip
r9724: Rewrite samba3dump in JS. The summary works now, but the full output
is triggering some obscure EJS assert.. (This used to be commit 42605f4444998e3063ffd1bea17425ff825f6132)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/bin/samba3dump125
-rw-r--r--source4/scripting/ejs/smbcalls_creds.c20
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c500
3 files changed, 411 insertions, 234 deletions
diff --git a/source4/scripting/bin/samba3dump b/source4/scripting/bin/samba3dump
index 71937c27c7..059af26e7e 100644
--- a/source4/scripting/bin/samba3dump
+++ b/source4/scripting/bin/samba3dump
@@ -29,7 +29,7 @@ if (options.format != "summary" && options.format != "full") {
libinclude("base.js");
-if (ARGV.length != 3) {
+if (options.ARGV.length != 2) {
println("Usage: samba3dump <libdir> <smb.conf>");
return -1;
}
@@ -37,8 +37,7 @@ if (ARGV.length != 3) {
function print_header(txt)
{
printf("\n%s\n", txt);
- for (i = 0; txt[i]; i++) putchar('=');
- putchar('\n');
+ println("==========================================");
}
function print_samba3_policy(pol)
@@ -60,19 +59,19 @@ function print_samba3_sam(samba3)
{
print_header("SAM Database");
- for (i = 0; i < samba3.samaccount_count; i++) {
- printf("%d: %s\n", samba3.samaccounts[i].user_rid, samba3.samaccounts[i].username);
+ for (a in samba3.samaccounts) {
+ printf("%d: %s\n", a.user_rid, a.username);
}
}
function print_samba3_shares(samba3)
{
print_header("Configured shares");
- for (i = 0; i < samba3.share_count; i++) {
- printf("--- %s ---\n", samba3.shares[i].name);
+ for (s in samba3.shares) {
+ printf("--- %s ---\n", s.name);
- for (j = 0; j < samba3.shares[i].parameter_count; j++) {
- printf("\t%s = %s\n", samba3.shares[i].parameters[j].name, samba3.shares[i].parameters[j].value);
+ for (p in s.parameters) {
+ printf("\t%s = %s\n", p.name, p.value);
}
println("");
@@ -85,37 +84,37 @@ function print_samba3_secrets(secrets)
println("IPC Credentials:");
if (secrets.ipc_cred.username_obtained)
- printf(" User: %s\n", secrets.ipc_cred.username);
+ printf(" User: %s\n", secrets.ipc_cred.get_username);
if (secrets.ipc_cred.password_obtained)
- printf(" Password: %s\n", secrets.ipc_cred.password);
+ printf(" Password: %s\n", secrets.ipc_cred.get_password);
if (secrets.ipc_cred.domain_obtained)
- printf(" Domain: %s\n\n", secrets.ipc_cred.domain);
+ printf(" Domain: %s\n\n", secrets.ipc_cred.get_domain);
println("LDAP passwords:");
- for (i = 0; i < secrets.ldappw_count; i++) {
- printf("\t%s -> %s\n", secrets.ldappws[i].dn, secrets.ldappws[i].password);
+ for (pw in secrets.ldappws) {
+ printf("\t%s -> %s\n", pw.dn, pw.password);
}
println("");
println("Domains:");
- for (i = 0; i < secrets.domain_count; i++) {
- printf("\t--- %s ---\n", secrets.domains[i].name);
- printf("\tSID: %s\n", secrets.domains[i].sid);
- printf("\tGUID: %s\n", secrets.domains[i].guid);
- printf("\tPlaintext pwd: %s\n", secrets.domains[i].plaintext_pw);
- printf("\tLast Changed: %lu\n", secrets.domains[i].last_change_time);
- printf("\tSecure Channel Type: %d\n\n", secrets.domains[i].sec_channel_type);
+ for (d in secrets.domains) {
+ printf("\t--- %s ---\n", d.name);
+ printf("\tSID: %s\n", d.sid);
+ printf("\tGUID: %s\n", d.guid);
+ printf("\tPlaintext pwd: %s\n", d.plaintext_pw);
+ printf("\tLast Changed: %lu\n", d.last_change_time);
+ printf("\tSecure Channel Type: %d\n\n", d.sec_channel_type);
}
println("Trusted domains:");
- for (i = 0; i < secrets.trusted_domain_count; i++) {
- for (j = 0; j < secrets.trusted_domains[i].uni_name_len; j++) {
- printf("\t--- %s ---\n", secrets.trusted_domains[i].uni_name[j]);
+ for (td in secrets.trusted_domains) {
+ for (j = 0; j < td.uni_name_len; j++) {
+ printf("\t--- %s ---\n", td.uni_name[j]);
}
- printf("\tPassword: %s\n", secrets.trusted_domains[i].pass);
- printf("\tModified: %lu\n", secrets.trusted_domains[i].mod_time);
- printf("\tSID: %s\n", secrets.trusted_domains[i].domain_sid);
+ printf("\tPassword: %s\n", td.pass);
+ printf("\tModified: %lu\n", td.mod_time);
+ printf("\tSID: %s\n", td.domain_sid);
}
}
@@ -123,13 +122,10 @@ function print_samba3_regdb(regdb)
{
print_header("Registry");
- for (i = 0; i < regdb.key_count; i++) {
- printf("%s\n", regdb.keys[i].name);
- for (j = 0; j < regdb.keys[i].value_count; j++) {
- printf("\t%s: type %d, length %d\n",
- regdb.keys[i].values[j].name,
- regdb.keys[i].values[j].type,
- regdb.keys[i].values[j].data.length);
+ for (k in regdb.keys) {
+ printf("%s\n", k.name);
+ for (v in k.values) {
+ printf("\t%s: type %d, length %d\n", v.name, v.type, v.data.length);
}
}
}
@@ -138,31 +134,32 @@ function print_samba3_winsdb(samba3)
{
print_header("WINS Database");
- for (i = 0; i < samba3.winsdb_count; i++) {
- printf("%s, nb_flags: %x, type: %d, ttl: %lu, %d ips\n", samba3.winsdb_entries[i].name, samba3.winsdb_entries[i].nb_flags, samba3.winsdb_entries[i].type, samba3.winsdb_entries[i].ttl, samba3.winsdb_entries[i].ip_count);
+ for (e in samba3.winsentries) {
+ printf("%s, nb_flags: %x, type: %d, ttl: %lu, %d ips\n", e.name, e.nb_flags, e.type, e.ttl, e.ip_count);
}
}
-function print_samba3_groupdb(groupdb)
+function print_samba3_groupmappings(groupdb)
{
int i;
print_header("Group Mappings");
- for (i = 0; i < groupdb.groupmap_count; i++)
- {
- printf("\t--- Group: %s ---\n", groupdb.groupmappings[i].nt_name);
- printf("\tComment: %s\n", groupdb.groupmappings[i].comment);
- printf("\tGID: %d\n", groupdb.groupmappings[i].gid);
- printf("\tSID Name Use: %d\n", groupdb.groupmappings[i].sid_name_use);
- printf("\tSID: %s\n\n", groupdb.groupmappings[i].sid);
+ for (g in groupdb.groupmappings) {
+ printf("\t--- Group: %s ---\n", g.nt_name);
+ printf("\tComment: %s\n", g.comment);
+ printf("\tGID: %d\n", g.gid);
+ printf("\tSID Name Use: %d\n", g.sid_name_use);
+ printf("\tSID: %s\n\n", g.sid);
}
+}
- for (i = 0; i < groupdb.alias_count; i++)
- {
+function print_samba3_aliases(groupdb)
+{
+ for (a in groupdb.aliases) {
int j;
- printf("\t--- Alias: %s ---\n", groupdb.aliases[i].sid);
- for (j = 0; j < groupdb.aliases[i].member_count; j++) {
- printf("\t%s\n", groupdb.aliases[i].members[j]);
+ printf("\t--- Alias: %s ---\n", a.sid);
+ for (j = 0; j < a.member_count; j++) {
+ printf("\t%s\n", a.members[j]);
}
}
}
@@ -174,14 +171,13 @@ function print_samba3_idmapdb(idmapdb)
printf("User High Water Mark: %d\n", idmapdb.user_hwm);
printf("Group High Water Mark: %d\n\n", idmapdb.group_hwm);
- for (i = 0; i < idmapdb.mapping_count; i++) {
- printf("%s -> ",
- idmapdb.mappings[i].sid);
+ for (e in idmapdb.mappings) {
+ printf("%s -> ", e.sid);
- if (idmapdb.mappings[i].type == IDMAP_GROUP) {
- printf("GID %d", idmapdb.mappings[i].unix_id);
+ if (e.type == IDMAP_GROUP) {
+ printf("GID %d", e.unix_id);
} else {
- printf("UID %d", idmapdb.mappings[i].unix_id);
+ printf("UID %d", e.unix_id);
}
}
}
@@ -194,22 +190,23 @@ function print_samba3(samba3)
print_samba3_winsdb(samba3);
print_samba3_regdb(samba3.registry);
print_samba3_secrets(samba3.secrets);
- print_samba3_groupdb(samba3.group);
+ print_samba3_groupmappings(samba3);
+ print_samba3_aliases(samba3);
print_samba3_idmapdb(samba3.idmap);
}
function print_samba3_summary(samba3)
{
- printf("WINS db entries: %d\n", samba3.winsdb_count);
- printf("SAM Accounts: %d\n", samba3.samaccount_count);
- printf("Registry key count: %d\n", samba3.registry.key_count);
- printf("Shares (including [global]): %d\n", samba3.share_count);
- printf("Groupmap count: %d\n", samba3.group.groupmap_count);
- printf("Alias count: %d\n", samba3.group.alias_count);
- printf("Idmap count: %d\n", samba3.idmap.mapping_count);
+ printf("WINS db entries: %d\n", samba3.winsentries.length);
+ printf("SAM Accounts: %d\n", samba3.samaccounts.length);
+ printf("Registry key count: %d\n", samba3.registry.keys.length);
+ printf("Shares (including [global]): %d\n", samba3.shares.length);
+ printf("Groupmap count: %d\n", samba3.groupmappings.length);
+ printf("Alias count: %d\n", samba3.aliases.length);
+ printf("Idmap count: %d\n", samba3.idmapdb.mappings.length);
}
-samba3 = samba3_read(ARGV[1], ARGV[2]);
+samba3 = samba3_read(options.ARGV[0], options.ARGV[1]);
if (options.format == "summary") {
print_samba3_summary(samba3);
diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c
index 45da5895e4..cc2ccf8c47 100644
--- a/source4/scripting/ejs/smbcalls_creds.c
+++ b/source4/scripting/ejs/smbcalls_creds.c
@@ -185,10 +185,8 @@ static int ejs_creds_get_workstation(MprVarHandle eid, int argc, struct MprVar *
/*
initialise credentials ejs object
*/
-static int ejs_credentials_obj(MprVarHandle eid, int argc, struct MprVar **argv, struct cli_credentials *creds)
+static int ejs_credentials_obj(struct MprVar *obj, struct cli_credentials *creds)
{
- struct MprVar *obj = mprInitObject(eid, "credentials", argc, argv);
-
mprSetPtrChild(obj, "creds", creds);
/* setup our object methods */
@@ -207,19 +205,30 @@ static int ejs_credentials_obj(MprVarHandle eid, int argc, struct MprVar **argv,
}
+struct MprVar mprCredentials(struct cli_credentials *creds)
+{
+ struct MprVar mpv = mprObject("credentials");
+
+ ejs_credentials_obj(&mpv, creds);
+
+ return mpv;
+}
+
+
/*
initialise credentials ejs object
*/
static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv)
{
struct cli_credentials *creds;
+ struct MprVar *obj = mprInitObject(eid, "credentials", argc, argv);
creds = cli_credentials_init(mprMemCtx());
if (creds == NULL) {
return -1;
}
- return ejs_credentials_obj(eid, argc, argv, creds);
+ return ejs_credentials_obj(obj, creds);
}
/*
@@ -227,7 +236,8 @@ static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv
*/
int ejs_credentials_cmdline(int eid, int argc, struct MprVar **argv)
{
- return ejs_credentials_obj(eid, argc, argv, cmdline_credentials);
+ struct MprVar *obj = mprInitObject(eid, "credentials", argc, argv);
+ return ejs_credentials_obj(obj, cmdline_credentials);
}
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
index 0cb3a2160c..7a7175fe5c 100644
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ b/source4/scripting/ejs/smbcalls_samba3.c
@@ -25,206 +25,366 @@
#include "lib/appweb/ejs/ejs.h"
#include "lib/samba3/samba3.h"
+
#if 0
-struct samba3_samaccount {
- uint32_t logon_time,
- logoff_time,
- kickoff_time,
- bad_password_time,
- pass_last_set_time,
- pass_can_change_time,
- pass_must_change_time;
- char *username;
- char *domain;
- char *nt_username;
- char *dir_drive;
- char *unknown_str;
- char *munged_dial;
- char *fullname;
- char *homedir;
- char *logon_script;
- char *profile_path;
- char *acct_desc;
- char *workstations;
- uint32_t user_rid, group_rid, hours_len, unknown_6;
- uint16_t acct_ctrl, logon_divs;
- uint16_t bad_password_count, logon_count;
- uint8_t *lm_pw_ptr, *nt_pw_ptr;
- uint8_t *nt_pw_hist_ptr;
- uint8_t *hours;
-};
-struct samba3_groupmapping {
- gid_t gid;
- struct dom_sid *sid;
- int sid_name_use;
- const char *nt_name;
- const char *comment;
+struct samba3_secrets
+{
};
-struct samba3_alias {
- struct dom_sid *sid;
- uint32_t member_count;
- struct dom_sid **members;
-};
+#endif
-struct samba3_groupdb {
- uint32_t groupmap_count;
- struct samba3_groupmapping *groupmappings;
+static struct MprVar mprRegistry(struct samba3_regdb *reg)
+{
+ struct MprVar mpv = mprObject("registry"), ks, vs, k, v;
+ int i, j;
- uint32_t alias_count;
- struct samba3_alias *aliases;
-};
+ ks = mprObject("array");
+
+ for (i = 0; i < reg->key_count; i++) {
+ k = mprObject("regkey");
+
+ mprSetVar(&k, "name", mprString(reg->keys[i].name));
+
+ vs = mprObject("array");
+
+ for (j = 0; j < reg->keys[i].value_count; j++) {
+ v = mprObject("regval");
+
+ mprSetVar(&v, "name", mprString(reg->keys[i].values[j].name));
+ mprSetVar(&v, "type", mprCreateIntegerVar(reg->keys[i].values[j].type));
+ mprSetVar(&v, "data", mprDataBlob(reg->keys[i].values[j].data));
+
+ mprAddArray(&vs, j, v);
+ }
+
+ mprSetVar(&k, "values", vs);
+
+ mprAddArray(&ks, i, k);
+ }
+
+ mprSetVar(&mpv, "keys", ks);
+
+ return mpv;
+}
-struct samba3_idmap_mapping
+static struct MprVar mprPolicy(struct samba3_policy *pol)
{
- enum { IDMAP_GROUP, IDMAP_USER } type;
- uint32_t unix_id;
- struct dom_sid *sid;
-};
+ struct MprVar mpv = mprObject("policy");
+
+ mprSetVar(&mpv, "min_password_length", mprCreateIntegerVar(pol->min_password_length));
+ mprSetVar(&mpv, "password_history", mprCreateIntegerVar(pol->password_history));
+ mprSetVar(&mpv, "user_must_logon_to_change_password", mprCreateIntegerVar(pol->user_must_logon_to_change_password));
+ mprSetVar(&mpv, "maximum_password_age", mprCreateIntegerVar(pol->maximum_password_age));
+ mprSetVar(&mpv, "minimum_password_age", mprCreateIntegerVar(pol->minimum_password_age));
+ mprSetVar(&mpv, "lockout_duration", mprCreateIntegerVar(pol->lockout_duration));
+ mprSetVar(&mpv, "reset_count_minutes", mprCreateIntegerVar(pol->reset_count_minutes));
+ mprSetVar(&mpv, "bad_lockout_minutes", mprCreateIntegerVar(pol->bad_lockout_minutes));
+ mprSetVar(&mpv, "disconnect_time", mprCreateIntegerVar(pol->disconnect_time));
+ mprSetVar(&mpv, "refuse_machine_password_change", mprCreateIntegerVar(pol->refuse_machine_password_change));
+
+ return mpv;
+}
-struct samba3_idmapdb
+static struct MprVar mprIdmapDb(struct samba3_idmapdb *db)
{
- /* High water marks */
- uint32_t user_hwm;
- uint32_t group_hwm;
+ struct MprVar mpv = mprObject("idmapdb"), mps, mp;
+ int i;
- uint32_t mapping_count;
- struct samba3_idmap_mapping *mappings;
-};
+ mprSetVar(&mpv, "user_hwm", mprCreateIntegerVar(db->user_hwm));
+ mprSetVar(&mpv, "group_hwm", mprCreateIntegerVar(db->group_hwm));
-struct samba3_winsdb_entry
-{
- char *name;
- int nb_flags;
- int type;
- time_t ttl;
- uint32_t ip_count;
- struct ipv4_addr *ips;
-};
+ mps = mprObject("array");
+
+ for (i = 0; i < db->mapping_count; i++) {
+ char *tmp;
+ mp = mprObject("idmap");
+
+ mprSetVar(&mp, "type", mprCreateIntegerVar(db->mappings[i].type));
+ mprSetVar(&mp, "unix_id", mprCreateIntegerVar(db->mappings[i].unix_id));
+
+ tmp = dom_sid_string(NULL, db->mappings[i].sid);
+ mprSetVar(&mp, "sid", mprString(tmp));
+ talloc_free(tmp);
+
+ mprAddArray(&mps, i, mp);
+ }
+
+ mprSetVar(&mpv, "mappings", mps);
-struct samba3_policy
+ return mpv;
+}
+
+static struct MprVar mprGroupMappings(struct samba3_groupdb *db)
{
- uint32_t min_password_length;
- uint32_t password_history;
- uint32_t user_must_logon_to_change_password;
- uint32_t maximum_password_age;
- uint32_t minimum_password_age;
- uint32_t lockout_duration;
- uint32_t reset_count_minutes;
- uint32_t bad_lockout_minutes;
- uint32_t disconnect_time;
- uint32_t refuse_machine_password_change;
-};
+ struct MprVar mpv = mprObject("array"), g;
+ int i;
-struct samba3_regval {
- char *name;
- uint16_t type;
- DATA_BLOB data;
-};
+ for (i = 0; i < db->groupmap_count; i++) {
+ char *tmp;
+ g = mprObject("group");
-struct samba3_regkey {
- char *name;
-
- uint32_t value_count;
- struct samba3_regval *values;
+ mprSetVar(&g, "gid", mprCreateIntegerVar(db->groupmappings[i].gid));
- uint32_t subkey_count;
- char **subkeys;
-};
+ tmp = dom_sid_string(NULL, db->groupmappings[i].sid);
+ mprSetVar(&g, "sid", mprString(tmp));
+ talloc_free(tmp);
-struct samba3_regdb
+ mprSetVar(&g, "sid_name_use", mprCreateIntegerVar(db->groupmappings[i].sid_name_use));
+ mprSetVar(&g, "nt_name", mprString(db->groupmappings[i].nt_name));
+ mprSetVar(&g, "comment", mprString(db->groupmappings[i].comment));
+
+ mprAddArray(&mpv, i, g);
+ }
+
+ return mpv;
+}
+
+static struct MprVar mprAliases(struct samba3_groupdb *db)
{
- uint32_t key_count;
- struct samba3_regkey *keys;
-};
+ struct MprVar mpv = mprObject("array"), a, am;
+ int i, j;
-struct samba3_secrets
+ for (i = 0; i < db->alias_count; i++) {
+ char *tmp;
+ a = mprObject("alias");
+
+ tmp = dom_sid_string(NULL, db->aliases[i].sid);
+ mprSetVar(&a, "sid", mprString(tmp));
+ talloc_free(tmp);
+
+ am = mprObject("array");
+
+ for (j = 0; j < db->aliases[i].member_count; j++) {
+ tmp = dom_sid_string(NULL, db->aliases[i].members[j]);
+ mprAddArray(&am, j, mprString(tmp));
+ talloc_free(tmp);
+ }
+
+ mprSetVar(&a, "members", am);
+ }
+
+ return mpv;
+}
+
+static struct MprVar mprSecrets(struct samba3_secrets *sec)
{
- struct cli_credentials *ipc_cred;
+ struct MprVar mpv = mprObject("samba3_secrets"), es, e;
+ int i;
+
+ es = mprObject("array");
+
+ for (i = 0; i < sec->ldappw_count; i++) {
+ e = mprObject("ldappw");
+
+ mprSetVar(&e, "dn", mprString(sec->ldappws[i].dn));
+ mprSetVar(&e, "password", mprString(sec->ldappws[i].password));
+
+ mprAddArray(&es, i, e);
+ }
+
+ 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);
+ }
+
+ mprSetVar(&mpv, "domains", es);
+
+ es = mprObject("trusted_domains");
+
+ for (i = 0; i < sec->trusted_domain_count; i++) {
+ struct MprVar ns;
+ char *tmp;
+ int j;
+ e = mprObject("trusted_domain");
+
+ ns = mprObject("array");
+
+ for (j = 0; j < sec->trusted_domains[i].uni_name_len; j++) {
+ mprAddArray(&ns, j, mprString(sec->trusted_domains[i].uni_name[j]));
+ }
+
+ mprSetVar(&e, "uni_name", ns);
+
+ mprSetVar(&e, "pass", mprString(sec->trusted_domains[i].pass));
+ mprSetVar(&e, "mod_time", mprCreateIntegerVar(sec->trusted_domains[i].mod_time));
+
+ tmp = dom_sid_string(NULL, &sec->trusted_domains[i].domain_sid);
+ mprSetVar(&e, "domains_sid", mprString(tmp));
+ talloc_free(tmp);
+
+ mprAddArray(&es, i, e);
+ }
+
+ mprSetVar(&mpv, "trusted_domains", es);
- uint32_t ldappw_count;
- struct samba3_ldappw
- {
- char *dn;
- char *password;
- } *ldappws;
-
- uint32_t domain_count;
- struct samba3_domainsecrets
- {
- char *name;
- struct dom_sid sid;
- struct GUID guid;
- char *plaintext_pw;
- time_t last_change_time;
- struct {
- uint8_t hash[16];
- time_t mod_time;
- } hash_pw;;
- int sec_channel_type;
- } *domains;
-
- uint32_t trusted_domain_count;
- struct samba3_trusted_dom_pass {
- uint32_t uni_name_len;
- const char *uni_name[32]; /* unicode domain name */
- const char *pass; /* trust relationship's password */
- time_t mod_time;
- struct dom_sid domain_sid; /* remote domain's sid */
- } *trusted_domains;
-
- uint32_t afs_keyfile_count;
-
- struct samba3_afs_keyfile {
- uint32_t nkeys;
- struct {
- uint32_t kvno;
- char key[8];
- } entry[8];
- char *cell;
- } *afs_keyfiles;
-};
+ es = mprObject("array");
-struct samba3_parameter {
- char *name;
- char *value;
-};
+ for (i = 0; i < sec->afs_keyfile_count; i++) {
+ struct MprVar ks;
+ int j;
+ e = mprObject("afs_keyfile");
-struct samba3_share_info {
- char *name;
- struct security_descriptor secdesc;
+ mprSetVar(&e, "cell", mprString(sec->afs_keyfiles[i].cell));
- uint32_t parameter_count;
- struct samba3_parameter *parameters;
-};
+ ks = mprObject("array");
+
+ for (j = 0; j < 8; j++) {
+ struct MprVar k = mprObject("entry");
+
+ mprSetVar(&k, "kvno", mprCreateIntegerVar(sec->afs_keyfiles[i].entry[j].kvno));
+ mprSetVar(&k, "key", mprData((uint8_t*)sec->afs_keyfiles[i].entry[j].key, 8));
+
+ mprAddArray(&ks, j, k);
+ }
+
+ mprSetVar(&e, "entry", ks);
+
+ mprSetVar(&e, "nkeys", mprCreateIntegerVar(sec->afs_keyfiles[i].nkeys));
+
+ mprAddArray(&es, i, e);
+ }
+
+ mprSetVar(&mpv, "afs_keyfiles", es);
-struct samba3
+ mprSetVar(&mpv, "ipc_cred", mprCredentials(sec->ipc_cred));
+
+ return mpv;
+}
+
+static struct MprVar mprShares(struct samba3 *samba3)
{
- uint32_t winsdb_count;
- struct samba3_winsdb_entry *winsdb_entries;
-
- uint32_t samaccount_count;
- struct samba3_samaccount *samaccounts;
+ struct MprVar mpv = mprObject("array"), s, ps, p;
+ int i, j;
- uint32_t share_count;
- struct samba3_share_info *shares;
+ for (i = 0; i < samba3->share_count; i++) {
+ s = mprObject("share");
- struct samba3_secrets secrets;
- struct samba3_groupdb group;
- struct samba3_idmapdb idmap;
- struct samba3_policy policy;
- struct samba3_regdb registry;
-};
+ mprSetVar(&s, "name", mprString(samba3->shares[i].name));
-#endif
+ /* FIXME: secdesc */
+
+ ps = mprObject("array");
+
+ for (j = 0; j < samba3->shares[i].parameter_count; j++) {
+ p = mprObject("parameter");
+
+ mprSetVar(&p, "name", mprString(samba3->shares[i].parameters[j].name));
+ mprSetVar(&p, "value", mprString(samba3->shares[i].parameters[j].value));
+
+ mprAddArray(&ps, j, p);
+ }
+
+ mprSetVar(&s, "parameters", ps);
+ }
+
+ return mpv;
+}
+
+static struct MprVar mprSamAccounts(struct samba3 *samba3)
+{
+ struct MprVar mpv = mprObject("array"), m;
+ int i;
+
+ for (i = 0; i < samba3->samaccount_count; i++) {
+ struct samba3_samaccount *a = &samba3->samaccounts[i];
+
+ m = mprObject("samba3_samaccount");
+
+ mprSetVar(&m, "logon_time", mprCreateIntegerVar(a->logon_time));
+ mprSetVar(&m, "logoff_time", mprCreateIntegerVar(a->logoff_time));
+ mprSetVar(&m, "kickoff_time", mprCreateIntegerVar(a->kickoff_time));
+ mprSetVar(&m, "bad_password_time", mprCreateIntegerVar(a->bad_password_time));
+ mprSetVar(&m, "pass_last_set_time", mprCreateIntegerVar(a->pass_last_set_time));
+ mprSetVar(&m, "pass_can_change_time", mprCreateIntegerVar(a->pass_can_change_time));
+ mprSetVar(&m, "pass_must_change_time", mprCreateIntegerVar(a->pass_must_change_time));
+ mprSetVar(&m, "user_rid", mprCreateIntegerVar(a->user_rid));
+ mprSetVar(&m, "group_rid", mprCreateIntegerVar(a->group_rid));
+ mprSetVar(&m, "acct_ctrl", mprCreateIntegerVar(a->acct_ctrl));
+ mprSetVar(&m, "logon_divs", mprCreateIntegerVar(a->logon_divs));
+ mprSetVar(&m, "bad_password_count", mprCreateIntegerVar(a->bad_password_count));
+ mprSetVar(&m, "logon_count", mprCreateIntegerVar(a->logon_count));
+ mprSetVar(&m, "username", mprString(a->username));
+ mprSetVar(&m, "domain", mprString(a->domain));
+ mprSetVar(&m, "nt_username", mprString(a->nt_username));
+ mprSetVar(&m, "dir_drive", mprString(a->dir_drive));
+ mprSetVar(&m, "munged_dial", mprString(a->munged_dial));
+ mprSetVar(&m, "fullname", mprString(a->fullname));
+ mprSetVar(&m, "homedir", mprString(a->homedir));
+ mprSetVar(&m, "logon_script", mprString(a->logon_script));
+ 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 */
+
+ mprAddArray(&mpv, i, m);
+ }
+
+ return mpv;
+}
+
+static struct MprVar mprWinsEntries(struct samba3 *samba3)
+{
+ struct MprVar mpv = mprObject("array");
+ int i, j;
+
+ for (i = 0; i < samba3->winsdb_count; i++) {
+ struct MprVar w = mprObject("wins_entry"), ips;
+
+ mprSetVar(&w, "name", mprString(samba3->winsdb_entries[i].name));
+ mprSetVar(&w, "nb_flags", mprCreateIntegerVar(samba3->winsdb_entries[i].nb_flags));
+ mprSetVar(&w, "type", mprCreateIntegerVar(samba3->winsdb_entries[i].type));
+ mprSetVar(&w, "ttl", mprCreateIntegerVar(samba3->winsdb_entries[i].ttl));
+
+ ips = mprObject("array");
+
+ for (j = 0; j < samba3->winsdb_entries[i].ip_count; j++) {
+ mprAddArray(&ips, j, mprString(iface_n_ip(i)));
+ }
+
+ mprSetVar(&w, "ips", ips);
+
+ mprAddArray(&mpv, i, w);
+ }
+
+ return mpv;
+}
/*
initialise samba3 ejs subsystem
*/
static int ejs_samba3_read(MprVarHandle eid, int argc, struct MprVar **argv)
{
- struct MprVar *mpv = mprInitObject(eid, "samba3", argc, argv);
+ struct MprVar mpv = mprObject("samba3");
struct samba3 *samba3;
NTSTATUS status;
@@ -240,7 +400,17 @@ static int ejs_samba3_read(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- mprSetThisPtr(eid, "db", samba3);
+ mprSetVar(&mpv, "winsentries", mprWinsEntries(samba3));
+ mprSetVar(&mpv, "samaccounts", mprSamAccounts(samba3));
+ mprSetVar(&mpv, "shares", mprShares(samba3));
+ mprSetVar(&mpv, "secrets", mprSecrets(&samba3->secrets));
+ mprSetVar(&mpv, "groupmappings", mprGroupMappings(&samba3->group));
+ mprSetVar(&mpv, "aliases", mprAliases(&samba3->group));
+ mprSetVar(&mpv, "idmapdb", mprIdmapDb(&samba3->idmap));
+ mprSetVar(&mpv, "policy", mprPolicy(&samba3->policy));
+ mprSetVar(&mpv, "registry", mprRegistry(&samba3->registry));
+
+ mpr_Return(eid, mpv);
return 0;
}