summaryrefslogtreecommitdiffstats
path: root/source4/scripting/libjs/provision.js
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/libjs/provision.js')
-rw-r--r--source4/scripting/libjs/provision.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index 33bfafac13..d700ecd539 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -122,6 +122,18 @@ function hostname()
}
+/* the ldb is in bad shape, possibly due to being built from an
+ incompatible previous version of the code, so delete it
+ completely */
+function ldb_delete(ldb)
+{
+ println("Deleting " + ldb.filename);
+ sys.unlink(ldb.filename);
+ ldb.close();
+ var ok = ldb.connect(ldb.filename);
+ assert(ok);
+}
+
/*
erase an ldb, removing all records
*/
@@ -138,10 +150,18 @@ function ldb_erase(ldb)
/* and the rest */
var res = ldb.search("(|(objectclass=*)(dn=*))", attrs);
var i;
+ if (typeof(res) == "undefined") {
+ ldb_delete(ldb);
+ return;
+ }
for (i=0;i<res.length;i++) {
ldb.del(res[i].dn);
}
res = ldb.search("(objectclass=*)", attrs);
+ if (res.length != 0) {
+ ldb_delete(ldb);
+ return;
+ }
assert(res.length == 0);
}
@@ -170,6 +190,8 @@ function setup_ldb(ldif, dbname, subobj)
data = data + extra;
data = substitute_var(data, subobj);
+ ldb.filename = dbname;
+
var ok = ldb.connect(dbname);
assert(ok);