mirror of
https://github.com/samba-team/samba.git
synced 2025-02-14 01:57:53 +03:00
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 commit is contained in:
parent
1f12364a0f
commit
173655aec2
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user