summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-01-10 10:35:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:50:02 -0500
commit75ef0ba513489a85557cb486135d80286d620809 (patch)
treedfc696095f47deda33984b38d97475faa377f74b /source4
parent195f5c3635159013fa14fbe0d34283b8237b0667 (diff)
downloadsamba-75ef0ba513489a85557cb486135d80286d620809.tar.gz
samba-75ef0ba513489a85557cb486135d80286d620809.tar.bz2
samba-75ef0ba513489a85557cb486135d80286d620809.zip
r12823: Fix up the provison and newuser code in SWAT. This also cleans up the
main provision script a bit, as the argument list was getting out of control. (It has been replaced in part with an object). This also returns the session_info from the auth code into ejs. We still need access control allowing only root to re-provision. Andrew Bartlett (This used to be commit 002cdcf3cab6563909d31edc5d825e857dc0a732)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c6
-rw-r--r--source4/scripting/libjs/provision.js51
2 files changed, 35 insertions, 22 deletions
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index a1310ded9c..5c70b6908b 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -35,6 +35,7 @@ static int ejs_doauth(MprVarHandle eid,
struct auth_serversupplied_info *server_info = NULL;
struct auth_session_info *session_info = NULL;
struct auth_context *auth_context;
+ struct MprVar *session_info_obj;
const char *auth_types[] = { authtype, NULL };
NTSTATUS nt_status;
@@ -89,9 +90,12 @@ static int ejs_doauth(MprVarHandle eid,
goto done;
}
+ session_info_obj = mprInitObject(eid, "session_info", 0, NULL);
+
+ mprSetPtrChild(session_info_obj, "session_info", session_info);
talloc_steal(mprMemCtx(), session_info);
- mprSetThisPtr(eid, "session_info", session_info);
+ mprSetProperty(auth, "session_info", session_info_obj);
mprSetPropertyValue(auth, "result", mprCreateBoolVar(server_info->authenticated));
mprSetPropertyValue(auth, "username", mprString(server_info->account_name));
mprSetPropertyValue(auth, "domain", mprString(server_info->domain_name));
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index e71ea83523..8b1d93c056 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -12,11 +12,12 @@ sys = sys_init();
/*
return true if the current install seems to be OK
*/
-function install_ok()
+function install_ok(session_info, credentials)
{
var lp = loadparm_init();
var ldb = ldb_init();
- ldb.credentials = credentials_cmdline();
+ ldb.session_info = session_info;
+ ldb.credentials = credentials;
if (lp.get("realm") == "") {
return false;
}
@@ -24,7 +25,7 @@ function install_ok()
if (!ok) {
return false;
}
- var res = ldb.search("(name=Administrator)");
+ var res = ldb.search("(cn=Administrator)");
if (res.length != 1) {
return false;
}
@@ -175,28 +176,28 @@ function ldb_erase(ldb)
/*
setup a ldb in the private dir
*/
-function setup_ldb(ldif, session_info, credentials, dbname, subobj)
+function setup_ldb(ldif, info, dbname)
{
var erase = true;
var extra = "";
var ldb = ldb_init();
var lp = loadparm_init();
- ldb.session_info = session_info;
- ldb.credentials = credentials;
+ ldb.session_info = info.session_info;
+ ldb.credentials = info.credentials;
- if (arguments.length >= 6) {
- extra = arguments[5];
+ if (arguments.length >= 4) {
+ extra = arguments[3];
}
- if (arguments.length == 7) {
- erase = arguments[6];
+ if (arguments.length == 5) {
+ erase = arguments[4];
}
var src = lp.get("setup directory") + "/" + ldif;
var data = sys.file_load(src);
data = data + extra;
- data = substitute_var(data, subobj);
+ data = substitute_var(data, info.subobj);
ldb.filename = dbname;
@@ -211,12 +212,12 @@ function setup_ldb(ldif, session_info, credentials, dbname, subobj)
var add_ok = ldb.add(data);
if (!add_ok) {
- message("ldb load failed: " + ldb.errstring() + "\n");
+ info.message("ldb load failed: " + ldb.errstring() + "\n");
assert(add_ok);
}
var commit_ok = ldb.transaction_commit();
if (!commit_ok) {
- message("ldb commit failed: " + ldb.errstring() + "\n");
+ info.message("ldb commit failed: " + ldb.errstring() + "\n");
assert(add_ok);
}
}
@@ -265,6 +266,7 @@ function provision(subobj, message, blank, paths, session_info, credentials)
var data = "";
var lp = loadparm_init();
var sys = sys_init();
+ var info = new Object();
/*
some options need to be upper/lower case
@@ -286,6 +288,11 @@ function provision(subobj, message, blank, paths, session_info, credentials)
provision_next_usn = 1;
+ info.subobj = subobj;
+ info.message = message;
+ info.credentials = credentials;
+ info.session_info = session_info;
+
/* only install a new smb.conf if there isn't one there already */
var st = sys.stat(paths.smbconf);
if (st == undefined) {
@@ -294,7 +301,7 @@ function provision(subobj, message, blank, paths, session_info, credentials)
lp.reload();
}
message("Setting up secrets.ldb\n");
- setup_ldb("secrets.ldif", session_info, credentials, paths.secrets, subobj);
+ setup_ldb("secrets.ldif", info, paths.secrets);
message("Setting up DNS zone file\n");
setup_file("provision.zone",
paths.dns,
@@ -303,20 +310,22 @@ function provision(subobj, message, blank, paths, session_info, credentials)
var keytab_ok = credentials_update_all_keytabs();
assert(keytab_ok);
message("Setting up hklm.ldb\n");
- setup_ldb("hklm.ldif", session_info, credentials, paths.hklm, subobj);
+ setup_ldb("hklm.ldif", info, paths.hklm);
+
+
message("Setting up sam.ldb attributes\n");
- setup_ldb("provision_init.ldif", session_info, credentials, paths.samdb, subobj);
+ setup_ldb("provision_init.ldif", info, paths.samdb);
message("Setting up sam.ldb schema\n");
- setup_ldb("schema.ldif", session_info, credentials, paths.samdb, subobj, NULL, false);
+ setup_ldb("schema.ldif", info, paths.samdb, NULL, false);
message("Setting up display specifiers\n");
- setup_ldb("display_specifiers.ldif", session_info, credentials, paths.samdb, subobj, NULL, false);
+ setup_ldb("display_specifiers.ldif", info, paths.samdb, NULL, false);
message("Setting up sam.ldb templates\n");
- setup_ldb("provision_templates.ldif", session_info, credentials, paths.samdb, subobj, NULL, false);
+ setup_ldb("provision_templates.ldif", info, paths.samdb, NULL, false);
message("Setting up sam.ldb data\n");
- setup_ldb("provision.ldif", session_info, credentials, paths.samdb, subobj, NULL, false);
+ setup_ldb("provision.ldif", info, paths.samdb, NULL, false);
if (blank == false) {
message("Setting up sam.ldb users and groups\n");
- setup_ldb("provision_users.ldif", session_info, credentials, paths.samdb, subobj, data, false);
+ setup_ldb("provision_users.ldif", info, paths.samdb, data, false);
}
}