summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/python/samba/provision.py46
-rw-r--r--source4/scripting/python/samba/provisionbackend.py7
2 files changed, 12 insertions, 41 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index f3af30ce39..d797dc9d21 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -39,7 +39,6 @@ import samba
import subprocess
import ldb
-import shutil
from auth import system_session, admin_session
from samba import version, Ldb, substitute_var, valid_netbios_name, setup_file
@@ -518,33 +517,12 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
# just want to wipe and re-initialise the database, not start it up
try:
- samdb = Ldb(url=samdb_path, session_info=session_info,
- lp=lp, options=["modules:"])
- res = samdb.search(base="@PARTITION", scope=SCOPE_BASE, attrs=["partition"], expression="partition=*")
- if len(res) == 1:
- try:
- old_partitions = res[0]["partition"]
- except KeyError:
- pass
-
- if old_partitions is not None:
- new_partitions = [];
- for old_partition in old_partitions:
- new_partition = old_partition
- if old_partition.endswith(".ldb"):
- p = old_partition.split(":")[0]
- dn = ldb.Dn(schema.ldb, p)
- new_partition = dn.get_casefold()
- new_partitions.append(new_partition)
-
- # Wipes the database
- samdb.erase_except_schema_controlled()
- except LdbError:
os.unlink(samdb_path)
- samdb = Ldb(url=samdb_path, session_info=session_info,
- lp=lp, options=["modules:"])
- # Wipes the database
- samdb.erase_except_schema_controlled()
+ except OSError:
+ pass
+
+ samdb = Ldb(url=samdb_path, session_info=session_info,
+ lp=lp, options=["modules:"])
#Add modules to the list to activate them by default
#beware often order is important
@@ -628,13 +606,6 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
})
- if new_partitions is not None:
- m = ldb.Message()
- m.dn = ldb.Dn(samdb, "@PARTITION")
-
- m["partition"] = ldb.MessageElement(new_partitions, ldb.FLAG_MOD_ADD, "partition")
- samdb.modify(m)
-
samdb.load_ldif_file_add(setup_path("provision_init.ldif"))
message("Setting up sam.ldb rootDSE")
@@ -949,13 +920,6 @@ def setup_samdb(path, setup_path, session_info, provision_backend, lp,
samdb.transaction_start()
try:
- message("Erasing data from partitions")
- # Load the schema (again). This time it will force a reindex,
- # and will therefore make the erase_partitions() below
- # computationally sane
- samdb.set_schema_from_ldb(schema.ldb)
- samdb.erase_partitions()
-
# Set the domain functionality levels onto the database.
# Various module (the password_hash module in particular) need
# to know what level of AD we are emulating.
diff --git a/source4/scripting/python/samba/provisionbackend.py b/source4/scripting/python/samba/provisionbackend.py
index fc1bac673d..8f1b94f1bd 100644
--- a/source4/scripting/python/samba/provisionbackend.py
+++ b/source4/scripting/python/samba/provisionbackend.py
@@ -30,6 +30,7 @@ import os
import sys
import uuid
import time
+import shutil
from samba import read_and_sub_file
from samba import Ldb
@@ -80,6 +81,9 @@ class ProvisionBackend(object):
if self.type is "ldb":
self.credentials = None
self.secrets_credentials = None
+
+ # Wipe the old sam.ldb databases away
+ shutil.rmtree(paths.samdb + ".d", True)
return
self.ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.ldapdir, "ldapi"), safe="")
@@ -230,6 +234,9 @@ def provision_openldap_backend(result, setup_path=None, names=None,
slapd_path=None, nosync=False,
ldap_dryrun_mode=False):
+ # Wipe the directories so we can start
+ shutil.rmtree(os.path.join(result.paths.ldapdir, "db"), True)
+
#Allow the test scripts to turn off fsync() for OpenLDAP as for TDB and LDB
nosync_config = ""
if nosync: