Handle different failure modes when we wipe the db in provision
authorAndrew Bartlett <abartlet@samba.org>
Thu, 18 Dec 2008 06:17:56 +0000 (17:17 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 18 Dec 2008 06:17:56 +0000 (17:17 +1100)
We didn't handle the mode where we can't load the main sam.ldb due to
the modules being 'wrong', and when we did remove the file, we didn't
wipe the partitions.

source4/scripting/python/samba/provision.py

index 5da073c563c53888183c437036bf622e465448b9..95bff74e75d3c7aa175e867a9bc620827ef80b93 100644 (file)
@@ -432,17 +432,18 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
     """
     assert session_info is not None
 
-    samdb = SamDB(samdb_path, session_info=session_info, 
-                  credentials=credentials, lp=lp)
-
-    # Wipes the database
     try:
+        samdb = SamDB(samdb_path, session_info=session_info, 
+                      credentials=credentials, lp=lp)
+        # Wipes the database
         samdb.erase()
     except:
         os.unlink(samdb_path)
-
-    samdb = SamDB(samdb_path, session_info=session_info, 
-                  credentials=credentials, lp=lp)
+        samdb = SamDB(samdb_path, session_info=session_info, 
+                      credentials=credentials, lp=lp)
+         # Wipes the database
+        samdb.erase()
+        
 
     #Add modules to the list to activate them by default
     #beware often order is important