Fix failure to re-provision.
authorAndrew Bartlett <abartlet@samba.org>
Mon, 3 Mar 2008 02:03:19 +0000 (13:03 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 3 Mar 2008 02:03:19 +0000 (13:03 +1100)
Somewhere in the conversion from ejs we lost calling the 'delete
partitions' code.  However, we have to be careful not to wipe
partitions when we are the second client connecting to an LDAP server.

Andrew Bartlett
(This used to be commit 272eb765b81e3eab216a07249334f9b7d20e530b)

source4/samba4-knownfail
source4/scripting/python/samba/__init__.py
source4/scripting/python/samba/provision.py

index e6a4ea1517e5d131bb98fef2b6296a9f0f81905b..66565ca6fc9cd445af816f3b5cdb1a404b6c72a4 100644 (file)
@@ -33,5 +33,4 @@ rpc.netlogon.*.GetTrustPasswords
 base.charset.*.Testing partial surrogate
 .*net.api.delshare.*                           # DelShare isn't implemented yet
 rap.*netservergetinfo
-samba4.blackbox.provision.py.reprovision # Fails with entry already exists
 local.torture.provision
index b041165800fc1de0c65ae41f613f71f59f4a2e9c..8d5f4250c957ec53860faeecea90daa64dcf5b33 100644 (file)
@@ -127,7 +127,7 @@ class Ldb(ldb.Ldb):
             try:
                 self.delete(msg.dn)
             except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
-                # Ignor eno such object errors
+                # Ignorno such object errors
                 pass
 
         res = self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", ["distinguishedName"])
@@ -151,7 +151,14 @@ class Ldb(ldb.Ldb):
                 previous_remaining = current_remaining
                 current_remaining = len(res2)
                 for msg in res2:
-                    self.delete(msg.dn)
+                    try:
+                        self.delete(msg.dn)
+                    # Ignore no such object errors
+                    except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+                        pass
+                    # Ignore not allowed on non leaf errors
+                    except ldb.LdbError, (LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, _):
+                        pass
 
     def load_ldif_file_add(self, ldif_path):
         """Load a LDIF file.
index e9aded205a334121c8646d864e1dfed53cf27168..ea2feb981bbfb3ea378cf30b1bfaa1e776199d34 100644 (file)
@@ -279,8 +279,6 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
     
     Alternatively, provision() may call this, and then populate the database.
     
-    :param erase: Remove the existing data present in the database.
-     
     :note: This will wipe the Sam Database!
     
     :note: This function always removes the local SAM LDB file. The erase 
@@ -289,10 +287,15 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
     """
     assert session_info is not None
 
-    if os.path.exists(samdb_path):
+    samdb = SamDB(samdb_path, session_info=session_info, 
+                  credentials=credentials, lp=lp)
+
+    # Wipes the database
+    try:
+        samdb.erase()
+    except:
         os.unlink(samdb_path)
 
-    # Also wipes the database
     samdb = SamDB(samdb_path, session_info=session_info, 
                   credentials=credentials, lp=lp)
 
@@ -547,7 +550,7 @@ def setup_self_join(samdb, configdn, schemadn, domaindn,
 
 def setup_samdb(path, setup_path, session_info, credentials, lp, 
                 schemadn, configdn, domaindn, dnsdomain, realm, 
-                netbiosname, message, hostname, rootdn, erase, 
+                netbiosname, message, hostname, rootdn, 
                 domainsid, aci, domainguid, policyguid, 
                 domainname, fill, adminpass, krbtgtpass, 
                 machinepass, hostguid, invocationid, dnspass,
@@ -560,6 +563,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
 
     assert serverrole in ("domain controller", "member server")
 
+    erase = (fill != FILL_DRS)    
+
     # Also wipes the database
     setup_samdb_partitions(path, setup_path, schemadn=schemadn, configdn=configdn, 
                            domaindn=domaindn, message=message, lp=lp,
@@ -726,7 +731,7 @@ def provision(lp, setup_dir, message, paths, session_info,
               hostguid=None, adminpass=None, krbtgtpass=None, domainguid=None, 
               policyguid=None, invocationid=None, machinepass=None, 
               dnspass=None, root=None, nobody=None, nogroup=None, users=None, 
-              wheel=None, backup=None, aci=None, serverrole=None, erase=False,
+              wheel=None, backup=None, aci=None, serverrole=None,
               ldap_backend=None, ldap_backend_type=None, sitename=DEFAULTSITE):
     """Provision samba4
     
@@ -873,7 +878,7 @@ def provision(lp, setup_dir, message, paths, session_info,
                         configdn=configdn, domaindn=domaindn,
                         dnsdomain=dnsdomain, netbiosname=netbiosname, 
                         realm=realm, message=message, hostname=hostname, 
-                        rootdn=rootdn, erase=erase, domainsid=domainsid, 
+                        rootdn=rootdn, domainsid=domainsid, 
                         aci=aci, domainguid=domainguid, policyguid=policyguid, 
                         domainname=domain, fill=samdb_fill, 
                         adminpass=adminpass, krbtgtpass=krbtgtpass,