diff options
-rw-r--r-- | source4/scripting/python/samba/provision.py | 22 | ||||
-rw-r--r-- | source4/scripting/python/samba/provisionexceptions.py | 6 | ||||
-rwxr-xr-x | source4/setup/provision | 43 |
3 files changed, 42 insertions, 29 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index bac234cfac..0a2483790f 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -330,34 +330,36 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, if dnsdomain is None: dnsdomain = lp.get("realm") if dnsdomain is None or dnsdomain == "": - raise ProvisioningError("guess_names: 'realm' not specified in supplied smb.conf!") + raise ProvisioningError("guess_names: 'realm' not specified in supplied %s!", lp.configfile) dnsdomain = dnsdomain.lower() if serverrole is None: serverrole = lp.get("server role") if serverrole is None: - raise ProvisioningError("guess_names: 'server role' not specified in supplied smb.conf!") + raise ProvisioningError("guess_names: 'server role' not specified in supplied %s!" % lp.configfile) serverrole = serverrole.lower() realm = dnsdomain.upper() + if lp.get("realm") == "": + raise ProvisioningError("guess_names: 'realm =' was not specified in supplied %s. Please remove the smb.conf file and let provision generate it" % lp.configfile) + 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) + raise ProvisioningError("guess_names: 'realm=%s' in %s must match chosen realm '%s'! Please remove the smb.conf file and let provision generate it" % (lp.get("realm").upper(), realm, lp.configfile)) 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) + raise ProvisioningError("guess_names: 'server role=%s' in %s must match chosen server role '%s'! Please remove the smb.conf file and let provision generate it" % (lp.get("server role").upper(), serverrole, lp.configfile)) if serverrole == "domain controller": if domain is None: + # This will, for better or worse, default to 'WORKGROUP' domain = lp.get("workgroup") - if domain is None: - raise ProvisioningError("guess_names: 'workgroup' not specified in supplied smb.conf!") domain = domain.upper() if lp.get("workgroup").upper() != domain: - raise ProvisioningError("guess_names: Workgroup '%s' in smb.conf must match chosen domain '%s'!", lp.get("workgroup").upper(), domain) + raise ProvisioningError("guess_names: Workgroup '%s' in %s must match chosen domain '%s'! Please remove the %s file and let provision generate it" % (lp.get("workgroup").upper(), domain, lp.configfile)) if domaindn is None: domaindn = "DC=" + dnsdomain.replace(".", ",DC=") @@ -370,11 +372,11 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, raise InvalidNetbiosName(domain) if hostname.upper() == realm: - raise ProvisioningError("guess_names: Realm '%s' must not be equal to hostname '%s'!", realm, hostname) + raise ProvisioningError("guess_names: Realm '%s' must not be equal to hostname '%s'!" % (realm, hostname)) if netbiosname == realm: - raise ProvisioningError("guess_names: Realm '%s' must not be equal to netbios hostname '%s'!", realm, netbiosname) + raise ProvisioningError("guess_names: Realm '%s' must not be equal to netbios hostname '%s'!" % (realm, netbiosname)) if domain == realm: - raise ProvisioningError("guess_names: Realm '%s' must not be equal to short domain name '%s'!", realm, domain) + raise ProvisioningError("guess_names: Realm '%s' must not be equal to short domain name '%s'!" % (realm, domain)) if rootdn is None: rootdn = domaindn diff --git a/source4/scripting/python/samba/provisionexceptions.py b/source4/scripting/python/samba/provisionexceptions.py index 604853fc19..6159a02e95 100644 --- a/source4/scripting/python/samba/provisionexceptions.py +++ b/source4/scripting/python/samba/provisionexceptions.py @@ -25,8 +25,12 @@ class ProvisioningError(Exception): """A generic provision error.""" + def __init__(self, value): + self.value = value + def __str__(self): + return "ProvisioningError: " + self.value -class InvalidNetbiosName(Exception): +class InvalidNetbiosName(ProvisioningError): """A specified name was not a valid NetBIOS name.""" def __init__(self, name): super(InvalidNetbiosName, self).__init__("The name '%r' is not a valid NetBIOS name" % name) diff --git a/source4/setup/provision b/source4/setup/provision index 2b31c4cd56..66aab7ea62 100755 --- a/source4/setup/provision +++ b/source4/setup/provision @@ -37,6 +37,7 @@ from samba.auth import system_session import samba.getopt as options from samba.provision import provision, FILL_FULL, FILL_NT4SYNC, FILL_DRS, find_setup_dir from samba import DS_DOMAIN_FUNCTION_2003, DS_DOMAIN_FUNCTION_2008, DS_DOMAIN_FUNCTION_2008_R2 +from samba.provisionexceptions import ProvisioningError # how do we make this case insensitive?? @@ -225,21 +226,27 @@ elif opts.use_xattrs == "auto": session = system_session() -provision(setup_dir, message, - session, creds, smbconf=smbconf, targetdir=opts.targetdir, - samdb_fill=samdb_fill, realm=opts.realm, domain=opts.domain, - domainguid=opts.domain_guid, domainsid=opts.domain_sid, - policyguid=opts.policy_guid, policyguid_dc=opts.policy_guid_dc, - hostname=opts.host_name, - hostip=opts.host_ip, hostip6=opts.host_ip6, - ntdsguid=opts.ntds_guid, - invocationid=opts.invocationid, adminpass=opts.adminpass, - krbtgtpass=opts.krbtgtpass, machinepass=opts.machinepass, - dnspass=opts.dnspass, root=opts.root, nobody=opts.nobody, - wheel=opts.wheel, users=opts.users, - serverrole=server_role, dom_for_fun_level=dom_for_fun_level, - ldap_backend_extra_port=opts.ldap_backend_extra_port, - backend_type=opts.ldap_backend_type, - ldapadminpass=opts.ldapadminpass, ol_mmr_urls=opts.ol_mmr_urls, - slapd_path=opts.slapd_path, setup_ds_path=opts.setup_ds_path, - nosync=opts.nosync,ldap_dryrun_mode=opts.ldap_dryrun_mode,useeadb=eadb) +try: + provision(setup_dir, message, + session, creds, smbconf=smbconf, targetdir=opts.targetdir, + samdb_fill=samdb_fill, realm=opts.realm, domain=opts.domain, + domainguid=opts.domain_guid, domainsid=opts.domain_sid, + policyguid=opts.policy_guid, policyguid_dc=opts.policy_guid_dc, + hostname=opts.host_name, + hostip=opts.host_ip, hostip6=opts.host_ip6, + ntdsguid=opts.ntds_guid, + invocationid=opts.invocationid, adminpass=opts.adminpass, + krbtgtpass=opts.krbtgtpass, machinepass=opts.machinepass, + dnspass=opts.dnspass, root=opts.root, nobody=opts.nobody, + wheel=opts.wheel, users=opts.users, + serverrole=server_role, dom_for_fun_level=dom_for_fun_level, + ldap_backend_extra_port=opts.ldap_backend_extra_port, + backend_type=opts.ldap_backend_type, + ldapadminpass=opts.ldapadminpass, ol_mmr_urls=opts.ol_mmr_urls, + slapd_path=opts.slapd_path, setup_ds_path=opts.setup_ds_path, + nosync=opts.nosync,ldap_dryrun_mode=opts.ldap_dryrun_mode,useeadb=eadb) +except ProvisioningError as e: + print str(e) + exit(1) + + |