From c3d1e5ca0c9f8d6c59a6fd4252a6e275b35e06de Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 15 Dec 2009 16:41:37 +1100 Subject: s4:provision Give a more useful error message in guess_names The problem here is that as we start to get 'real users' they still decide to do silly things, like load empty but existing smb.conf files. Let's give them a better chance to discover what they did wrong. Andrew Bartlett --- source4/scripting/python/samba/provision.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 44ccaa8ef0..3e4e90a746 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -359,12 +359,16 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, if dnsdomain is None: dnsdomain = lp.get("realm") - assert dnsdomain is not None + if dnsdomain is None or dnsdomain == "": + raise ProvisioningError("guess_names: 'realm' not specified in supplied smb.conf!") + dnsdomain = dnsdomain.lower() if serverrole is None: serverrole = lp.get("server role") - assert serverrole is not None + if serverrole is None: + raise ProvisioningError("guess_names: 'server role' not specified in supplied smb.conf!") + serverrole = serverrole.lower() realm = dnsdomain.upper() @@ -372,10 +376,14 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, if lp.get("realm").upper() != realm: raise ProvisioningError("guess_names: Realm '%s' in smb.conf must match chosen realm '%s'!", lp.get("realm").upper(), realm) + if lp.get("server role").lower() != serverrole: + raise ProvisioningError("guess_names: server role '%s' in smb.conf must match chosen server role '%s'!", lp.get("server role").upper(), serverrole) + if serverrole == "domain controller": if domain is None: domain = lp.get("workgroup") - assert domain is not None + if domain is None: + raise ProvisioningError("guess_names: 'workgroup' not specified in supplied smb.conf!") domain = domain.upper() if lp.get("workgroup").upper() != domain: -- cgit