Fix multiple uninstallation of server

"ipa-server-install --uninstall" no longer fails with error message
"'Env' object has no attribute 'basedn'" when executed on a system that
has no freeIPA server installation.

Fixes: https://pagure.io/freeipa/issue/7063
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Felipe Volpone <fbarreto@redhat.com>
This commit is contained in:
Christian Heimes committed 2018-02-15 14:02:03 +01:00
1 parent 0ee3a26711
commit 0cc2a6cae0
3 files changed
+24 -8

No files matched your search

+2
View File
@@ -74,6 +74,8 @@ steps:
- ipa-run-tests ${tests_ignore} -k-test_dns_soa ${tests_verbose} ${path}
- '! grep -n -C5 BytesWarning /var/log/httpd/error_log'
- ipa-server-install --uninstall -U
# second uninstall to verify that --uninstall without installation works
- ipa-server-install --uninstall -U
tests:
ignore:
- test_integration
+10
View File
@@ -576,6 +576,16 @@ class Env(object):
if 'log' not in self:
self.log = self._join('logdir', '%s.log' % self.context)
# Workaround for ipa-server-install --uninstall. When no config file
# is available, we set realm, domain, and basedn to RFC 2606 reserved
# suffix to suppress attribute errors during uninstallation.
if (self.in_server and self.context == 'installer' and
not getattr(self, 'config_loaded', False)):
if 'realm' not in self:
self.realm = 'UNCONFIGURED.INVALID'
if 'domain' not in self:
self.domain = self.realm.lower()
if 'basedn' not in self and 'domain' in self:
self.basedn = DN(*(('dc', dc) for dc in self.domain.split('.')))
+12 -8
View File
@@ -207,12 +207,15 @@ class IPAKEMKeys(KEMKeysStore):
def __init__(self, config=None, ipaconf=paths.IPA_DEFAULT_CONF):
super(IPAKEMKeys, self).__init__(config)
conf = ConfigParser()
conf.read(ipaconf)
self.host = conf.get('global', 'host')
self.realm = conf.get('global', 'realm')
self.host = None
self.realm = None
self.ldap_uri = config.get('ldap_uri', None)
if self.ldap_uri is None:
self.ldap_uri = conf.get('global', 'ldap_uri', raw=True)
if conf.read(ipaconf):
self.host = conf.get('global', 'host')
self.realm = conf.get('global', 'realm')
if self.ldap_uri is None:
self.ldap_uri = conf.get('global', 'ldap_uri', raw=True)
self._server_keys = None
def find_key(self, kid, usage):
@@ -259,9 +262,10 @@ class IPAKEMKeys(KEMKeysStore):
"""
self.remove_server_keys_file()
principal = '%s/%s@%s' % (servicename, self.host, self.realm)
ldapconn = KEMLdap(self.ldap_uri)
ldapconn.del_key(KEY_USAGE_SIG, principal)
ldapconn.del_key(KEY_USAGE_ENC, principal)
if self.ldap_uri is not None:
ldapconn = KEMLdap(self.ldap_uri)
ldapconn.del_key(KEY_USAGE_SIG, principal)
ldapconn.del_key(KEY_USAGE_ENC, principal)
@property
def server_keys(self):