summaryrefslogtreecommitdiff
path: root/source4/scripting/libjs
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-08-30 16:09:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:35:03 -0500
commitcf016f972b931b54c155ca8e6df485e05c37b034 (patch)
tree61a716f6c30ec08f01d22a0d68dcef951132f5c0 /source4/scripting/libjs
parent9f4b32996c1c97122b198a13216c35ad40f6ea2d (diff)
downloadsamba-cf016f972b931b54c155ca8e6df485e05c37b034.tar.gz
samba-cf016f972b931b54c155ca8e6df485e05c37b034.tar.bz2
samba-cf016f972b931b54c155ca8e6df485e05c37b034.zip
r9805: Add 'data' property to param EJS object
Write out new smb.conf file. Parameters that have disappeared between Samba 3 and 4 will optionally be prefixed with 'samba3:' (This used to be commit 27eefbd9059fe0a3daca15a71da7b4cb88ed22ec)
Diffstat (limited to 'source4/scripting/libjs')
-rw-r--r--source4/scripting/libjs/upgrade.js68
1 files changed, 49 insertions, 19 deletions
diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js
index aa94dbbbc4..0e12d7c345 100644
--- a/source4/scripting/libjs/upgrade.js
+++ b/source4/scripting/libjs/upgrade.js
@@ -274,7 +274,7 @@ function upgrade_provision(samba3)
return subobj;
}
-var keep = new Array(
+smbconf_keep = new Array(
"dos charset",
"unix charset",
"display charset",
@@ -371,43 +371,70 @@ var keep = new Array(
"host msdfs",
"winbind separator");
-function upgrade_smbconf(samba3)
+/*
+ Remove configuration variables not present in Samba4
+ oldconf: Old configuration structure
+ mark: Whether removed configuration variables should be
+ kept in the new configuration as "samba3:<name>"
+ */
+function upgrade_smbconf(oldconf,mark)
{
- //FIXME
-}
+ var data = oldconf.data();
+ var newconf = param_init();
+
+ for (var s in data) {
+ for (var p in data[s]) {
+ var keep = false;
+ for (var k in smbconf_keep) {
+ if (smbconf_keep[k] == p) {
+ keep = true;
+ break;
+ }
+ }
-function save_smbconf(path,smbconf)
-{
- var data = "
-# Generated by upgrade.js";
-
- for (var i in smbconf.shares) {
- var s = smbconf.shares[i];
- data = data + "\n[" + s.name + "]\n";
- for (var j in s.parameters) {
- var p = s.parameters[j];
- data = data + "\t" + p.name + " = " + p + "\n";
+ if (keep) {
+ newconf.set(s, p, oldconf.get(s, p));
+ } else if (mark) {
+ newconf.set(s, "samba3:"+p, oldconf.get(s,p));
+ }
}
}
-
- sys.file_save(path,data);
+
+ return newconf;
}
function upgrade(subobj, samba3, message)
{
var ret = 0;
+ var lp = loadparm_init();
var samdb = ldb_init();
var ok = samdb.connect("sam.ldb");
assert(ok);
+ message("Writing configuration\n");
+ var newconf = upgrade_smbconf(samba3.configuration,true);
+ newconf.save(lp.get("config file"));
+
message("Importing account policies\n");
var ldif = upgrade_sam_policy(samba3,subobj.BASEDN);
ok = samdb.modify(ldif);
assert(ok);
+ // figure out ldapurl, if applicable
var ldapurl = undefined;
+ var pdb = samba3.configuration.get_list("passdb backends");
+ if (pdb != undefined) {
+ for (var b in pdb) {
+ if (substr(pdb[b], 0, 7) == "ldapsam") {
+ ldapurl = substr(pdb[b], 8);
+ }
+ }
+ }
- // FIXME: figure out ldapurl
+ // URL was not specified in passdb backend but ldap /is/ used
+ if (ldapurl == "") {
+ ldapurl = "ldap://" + samba3.configuration.get("ldap server");
+ }
// Enable samba3sam module if original passdb backend was ldap
if (ldapurl != undefined) {
@@ -417,7 +444,7 @@ dn: @MAP=samba3sam
samdb.add(ldif);
samdb.modify("dn: @MODULES
-@LIST: samldb,timestamps,objectguid,rdn_name");
+@LIST: samldb,timestamps,objectguid,rdn_name,samba3sam");
}
message("Importing users\n");
@@ -473,5 +500,8 @@ dn: @MAP=samba3sam
ok = winsdb.add(ldif);
assert(ok);
+ message("Reloading smb.conf\n");
+ lp.reload();
+
return ret;
}