diff options
Diffstat (limited to 'ipaserver/install')
-rw-r--r-- | ipaserver/install/bindinstance.py | 25 | ||||
-rw-r--r-- | ipaserver/install/cainstance.py | 2 | ||||
-rw-r--r-- | ipaserver/install/dsinstance.py | 2 | ||||
-rw-r--r-- | ipaserver/install/service.py | 30 |
4 files changed, 11 insertions, 48 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index 09760d667..cece85ec6 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -202,23 +202,11 @@ def named_conf_set_directive(name, value, section=NAMED_SECTION_IPA, with open(NAMED_CONF, 'w') as f: f.write("".join(new_lines)) -def dns_container_exists(fqdn, suffix, dm_password=None, ldapi=False, realm=None): +def dns_container_exists(fqdn, suffix, dm_password=None, ldapi=False, realm=None, + autobind=ipaldap.AUTOBIND_DISABLED): """ Test whether the dns container exists. """ - - def object_exists(dn): # FIXME, this should be a IPAdmin/ldap2 method so it can be shared - """ - Test whether the given object exists in LDAP. - """ - assert isinstance(dn, DN) - try: - conn.get_entry(dn) - except errors.NotFound: - return False - else: - return True - assert isinstance(suffix, DN) try: # At install time we may need to use LDAPI to avoid chicken/egg @@ -228,14 +216,11 @@ def dns_container_exists(fqdn, suffix, dm_password=None, ldapi=False, realm=None else: conn = ipaldap.IPAdmin(host=fqdn, port=636, cacert=CACERT) - if dm_password: - conn.do_simple_bind(bindpw=dm_password) - else: - conn.do_sasl_gssapi_bind() + conn.do_bind(dm_password, autobind=autobind) except ldap.SERVER_DOWN: raise RuntimeError('LDAP server on %s is not responding. Is IPA installed?' % fqdn) - ret = object_exists(DN(('cn', 'dns'), suffix)) + ret = conn.entry_exists(DN(('cn', 'dns'), suffix)) conn.unbind() return ret @@ -446,7 +431,7 @@ class BindInstance(service.Service): service_desc="DNS", dm_password=dm_password, ldapi=False, - autobind=service.DISABLED + autobind=ipaldap.AUTOBIND_DISABLED ) self.dns_backup = DnsBackup(self) self.named_user = None diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py index 45c72198d..b0037dd56 100644 --- a/ipaserver/install/cainstance.py +++ b/ipaserver/install/cainstance.py @@ -271,7 +271,7 @@ class CADSInstance(service.Service): service_desc="directory server for the CA", dm_password=dm_password, ldapi=False, - autobind=service.DISABLED) + autobind=ipaldap.AUTOBIND_DISABLED) self.serverid = "PKI-IPA" self.realm = realm_name diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py index 0edd4ed63..6e79dc51f 100644 --- a/ipaserver/install/dsinstance.py +++ b/ipaserver/install/dsinstance.py @@ -192,7 +192,7 @@ class DsInstance(service.Service): service_desc="directory server", dm_password=dm_password, ldapi=False, - autobind=service.DISABLED + autobind=ipaldap.AUTOBIND_DISABLED ) self.nickname = 'Server-Cert' self.dm_password = dm_password diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py index 018c369ff..8fb802099 100644 --- a/ipaserver/install/service.py +++ b/ipaserver/install/service.py @@ -20,7 +20,6 @@ import sys import os, socket import tempfile -import pwd import time import datetime import traceback @@ -32,10 +31,6 @@ from ipalib import errors, certstore from ipaplatform import services from ipaplatform.paths import paths -# Autobind modes -AUTO = 1 -ENABLED = 2 -DISABLED = 3 # The service name as stored in cn=masters,cn=ipa,cn=etc. In the tuple # the first value is the *nix service name, the second the start order. @@ -74,7 +69,8 @@ def format_seconds(seconds): class Service(object): - def __init__(self, service_name, service_desc=None, sstore=None, dm_password=None, ldapi=True, autobind=AUTO): + def __init__(self, service_name, service_desc=None, sstore=None, dm_password=None, ldapi=True, + autobind=ipaldap.AUTOBIND_AUTO): self.service_name = service_name self.service_desc = service_desc self.service = services.service(service_name) @@ -110,26 +106,8 @@ class Service(object): conn = ipaldap.IPAdmin(ldapi=self.ldapi, realm=self.realm) else: conn = ipaldap.IPAdmin(self.fqdn, port=389) - if self.dm_password: - conn.do_simple_bind(bindpw=self.dm_password) - elif self.autobind in [AUTO, ENABLED]: - if os.getegid() == 0 and self.ldapi: - try: - # autobind - pw_name = pwd.getpwuid(os.geteuid()).pw_name - conn.do_external_bind(pw_name) - except errors.NotFound, e: - if self.autobind == AUTO: - # Fall back - conn.do_sasl_gssapi_bind() - else: - # autobind was required and failed, raise - # exception that it failed - raise e - else: - conn.do_sasl_gssapi_bind() - else: - conn.do_sasl_gssapi_bind() + + conn.do_bind(self.dm_password, autobind=self.autobind) except Exception, e: root_logger.debug("Could not connect to the Directory Server on %s: %s" % (self.fqdn, str(e))) raise |