s4-provision Always run slaptest to convert the config file
authorAndrew Bartlett <abartlet@samba.org>
Sat, 4 Dec 2010 02:47:05 +0000 (13:47 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 8 Dec 2010 04:19:12 +0000 (05:19 +0100)
If the directory exists, it does not mean that it is configured - we
may be on a re-run of the provision.

Andrew Bartlett

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Wed Dec  8 05:19:12 CET 2010 on sn-devel-104

source4/scripting/python/samba/provision/backend.py

index 809dd4f9ecfb3440ff4f5c392c86285e81c364a5..34f64e32aafdfe3f77effd6541d15320dbbcfee5 100644 (file)
@@ -540,29 +540,29 @@ class OpenLDAPBackend(LDAPBackend):
         # DN and simple bind
         self.credentials.set_username("samba-admin")
 
+        # Wipe the old sam.ldb databases away
+        shutil.rmtree(self.olcdir, True)
+        os.makedirs(self.olcdir, 0770)
+
         # If we were just looking for crashes up to this point, it's a
         # good time to exit before we realise we don't have OpenLDAP on
         # this system
         if self.ldap_dryrun_mode:
             sys.exit(0)
 
-        # Finally, convert the configuration into cn=config style!
-        if not os.path.isdir(self.olcdir):
-            os.makedirs(self.olcdir, 0770)
-
-            slapd_cmd = [self.slapd_path, "-Ttest", "-n", "0", "-f",
+        slapd_cmd = [self.slapd_path, "-Ttest", "-n", "0", "-f",
                          self.slapdconf, "-F", self.olcdir]
-            retcode = subprocess.call(slapd_cmd, close_fds=True, shell=False)
+        retcode = subprocess.call(slapd_cmd, close_fds=True, shell=False)
 
-            if retcode != 0:
-                self.logger.error("conversion from slapd.conf to cn=config failed slapd started with: %s" %  "\'" + "\' \'".join(slapd_cmd) + "\'")
-                raise ProvisioningError("conversion from slapd.conf to cn=config failed")
+        if retcode != 0:
+            self.logger.error("conversion from slapd.conf to cn=config failed slapd started with: %s" %  "\'" + "\' \'".join(slapd_cmd) + "\'")
+            raise ProvisioningError("conversion from slapd.conf to cn=config failed")
 
-            if not os.path.exists(os.path.join(self.olcdir, "cn=config.ldif")):
-                raise ProvisioningError("conversion from slapd.conf to cn=config failed")
+        if not os.path.exists(os.path.join(self.olcdir, "cn=config.ldif")):
+            raise ProvisioningError("conversion from slapd.conf to cn=config failed")
 
-            # Don't confuse the admin by leaving the slapd.conf around
-            os.remove(self.slapdconf)
+        # Don't confuse the admin by leaving the slapd.conf around
+        os.remove(self.slapdconf)
 
 
 class FDSBackend(LDAPBackend):