From bcc3ce695e9290013ab7fab230a5b0ab27b65ac4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 13 Sep 2005 01:02:06 +0000 Subject: 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) --- source4/scripting/libjs/provision.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/scripting/libjs') 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