summaryrefslogtreecommitdiff
path: root/source4/scripting/libjs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-13 01:02:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:07 -0500
commitbcc3ce695e9290013ab7fab230a5b0ab27b65ac4 (patch)
treef3afc8e072a3743aa4667b6332776bfce441eaa5 /source4/scripting/libjs
parent68974a1c7205a4b06045217ed01a2f75ea8bccdd (diff)
downloadsamba-bcc3ce695e9290013ab7fab230a5b0ab27b65ac4.tar.gz
samba-bcc3ce695e9290013ab7fab230a5b0ab27b65ac4.tar.bz2
samba-bcc3ce695e9290013ab7fab230a5b0ab27b65ac4.zip
r10193: r11632@blu: tridge | 2005-08-30 23:08:27 +1000
if we fail to erase a ldb during provision by traversing and deleting records (an in-place erase) then just unlink it and start it again. This makes provisioning much more robust to changes in ldb that make it not backward compatible with old DBs. (This used to be commit 173655aec25c462b8b90b850df65ae6f95f44efb)
Diffstat (limited to 'source4/scripting/libjs')
-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);