mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-27 16:46:42 -06:00
Prevent server and domain from being undefined or blank when we need them
Improve LDAP error reporting Don't return the str() of discovery values because it can return "None" 436130
This commit is contained in:
parent
d7e30fa7ee
commit
7fd656477a
@ -77,12 +77,11 @@ def main():
|
||||
ds = ipaclient.ipadiscovery.IPADiscovery()
|
||||
|
||||
ret = ds.search(domain=options.domain, server=options.server)
|
||||
srv = ""
|
||||
if ret == -10:
|
||||
print "Can't get the fully qualified name of this host"
|
||||
print "Please check that the client is properly configured"
|
||||
return ret
|
||||
if ret == -1:
|
||||
if ret == -1 or not ds.getDomainName():
|
||||
logging.debug("Domain not found")
|
||||
if options.domain:
|
||||
dom = options.domain
|
||||
@ -94,7 +93,8 @@ def main():
|
||||
while dom == "":
|
||||
dom = raw_input("Please provide your domain name (ex: example.com): ")
|
||||
ret = ds.search(domain=dom)
|
||||
if ret == -2:
|
||||
dom = ds.getDomainName()
|
||||
if ret == -2 or not ds.getServerName():
|
||||
dnsok = False
|
||||
logging.debug("IPA Server not found")
|
||||
if options.server:
|
||||
@ -103,11 +103,15 @@ def main():
|
||||
return ret
|
||||
else:
|
||||
print "Failed to find the IPA Server (DNS misconfigured?)"
|
||||
srv = ""
|
||||
while srv == "":
|
||||
srv = raw_input("Please provide your server name (ex: ipa.example.com): ")
|
||||
ret = ds.search(domain=dom, server=srv)
|
||||
srv = ds.getServerName()
|
||||
if ret != 0:
|
||||
print "Failed to verify that "+srv+" is an IPA Server, aborting!"
|
||||
print "Failed to verify that "+srv+" is an IPA Server."
|
||||
print "This may mean that the remote server is not up or is not reachable"
|
||||
print "due to network or firewall settings."
|
||||
return ret
|
||||
|
||||
if dnsok:
|
||||
|
@ -32,16 +32,16 @@ class IPADiscovery:
|
||||
self.basedn = None
|
||||
|
||||
def getServerName(self):
|
||||
return str(self.server)
|
||||
return self.server
|
||||
|
||||
def getDomainName(self):
|
||||
return str(self.domain)
|
||||
return self.domain
|
||||
|
||||
def getRealmName(self):
|
||||
return str(self.realm)
|
||||
return self.realm
|
||||
|
||||
def getBaseDN(self):
|
||||
return str(self.basedn)
|
||||
return self.basedn
|
||||
|
||||
def search(self, domain = "", server = ""):
|
||||
hostname = ""
|
||||
@ -100,8 +100,8 @@ class IPADiscovery:
|
||||
|
||||
logging.debug("[ipacheckldap]")
|
||||
# check ldap now
|
||||
ldapret = self.ipacheckldap(self.server, self.realm);
|
||||
|
||||
ldapret = self.ipacheckldap(self.server, self.realm)
|
||||
|
||||
if not ldapret:
|
||||
return -4 # not an IPA server (or broken config)
|
||||
|
||||
@ -178,7 +178,11 @@ class IPADiscovery:
|
||||
|
||||
except LDAPError, err:
|
||||
#no good
|
||||
logging.error("Ldap Error: "+str(err))
|
||||
if type(err.message) == dict:
|
||||
for (k, v) in err.message.iteritems():
|
||||
logging.error("LDAP Error: %s" % v )
|
||||
else:
|
||||
logging.error("LDAP Error: "+err.message)
|
||||
return []
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user