Far less cryptic traceback when you have an existing smb.conf
authorAndrew Bartlett <abartlet@samba.org>
Fri, 11 Apr 2008 09:04:43 +0000 (19:04 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 11 Apr 2008 09:04:43 +0000 (19:04 +1000)
When the user has an existing smb.conf, but no [netlogon] or [sysvol]
share, the provision script would trigger a traceback.  While we still
need to abort in this situation, we do so now with a useful error.

Andrew Bartlett
(This used to be commit 10a8b7ea487f9725f69b02c4dd9cf5e1f67a23ab)

source4/scripting/python/samba/provision.py

index 16b1eb2156984b82a47f723266e1aa3b9eafabe7..4f264b6fc9b05141fcb52e6aff74335e7536d111 100644 (file)
@@ -87,6 +87,7 @@ class ProvisionNames:
         self.domain = None
         self.hostname = None
         self.sitename = None
+        self.smbconf = None
     
 class ProvisionResult:
     def __init__(self):
@@ -262,6 +263,8 @@ def provision_paths_from_lp(lp, dnsdomain):
 
     paths.netlogon = lp.get("path", "netlogon")
 
+    paths.smbconf = lp.configfile()
+
     return paths
 
 
@@ -1009,12 +1012,24 @@ def provision(setup_dir, message, session_info,
                         ldap_backend_type=ldap_backend_type)
 
     if lp.get("server role") == "domain controller":
-       policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies", 
-                                  "{" + policyguid + "}")
-       os.makedirs(policy_path, 0755)
-       os.makedirs(os.path.join(policy_path, "Machine"), 0755)
-       os.makedirs(os.path.join(policy_path, "User"), 0755)
-       if not os.path.isdir(paths.netlogon):
+        if paths.netlogon is None:
+            message("Existing smb.conf does not have a [netlogon] share, but you are configuring a DC.")
+            message("Please either remove %s or see the template at %s" % 
+                    ( paths.smbconf, setup_path("provision.smb.conf.dc")))
+            assert(paths.netlogon is not None)
+
+        if paths.sysvol is None:
+            message("Existing smb.conf does not have a [sysvol] share, but you are configuring a DC.")
+            message("Please either remove %s or see the template at %s" % 
+                    (paths.smbconf, setup_path("provision.smb.conf.dc")))
+            assert(paths.sysvol is not None)            
+            
+        policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies", 
+                                   "{" + policyguid + "}")
+        os.makedirs(policy_path, 0755)
+        os.makedirs(os.path.join(policy_path, "Machine"), 0755)
+        os.makedirs(os.path.join(policy_path, "User"), 0755)
+        if not os.path.isdir(paths.netlogon):
             os.makedirs(paths.netlogon, 0755)
 
     if samdb_fill == FILL_FULL: