diff options
author | Christian Heimes <cheimes@redhat.com> | 2018-02-07 14:22:06 +0100 |
---|---|---|
committer | Christian Heimes <cheimes@redhat.com> | 2018-02-15 14:02:03 +0100 |
commit | 0cc2a6cae01043f0aba32319ac8c6475780b6d7f (patch) | |
tree | 80942384094cb83b037cb11729f6689bbed1acaa | |
parent | 0ee3a267112dfafe12726fb185a4ce260c67aff7 (diff) | |
download | freeipa-0cc2a6cae01043f0aba32319ac8c6475780b6d7f.tar.gz freeipa-0cc2a6cae01043f0aba32319ac8c6475780b6d7f.tar.xz freeipa-0cc2a6cae01043f0aba32319ac8c6475780b6d7f.zip |
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>
-rw-r--r-- | .test_runner_config.yaml | 2 | ||||
-rw-r--r-- | ipalib/config.py | 10 | ||||
-rw-r--r-- | ipaserver/secrets/kem.py | 20 |
3 files changed, 24 insertions, 8 deletions
diff --git a/.test_runner_config.yaml b/.test_runner_config.yaml index 59cb2a451..7bdbe9859 100644 --- a/.test_runner_config.yaml +++ b/.test_runner_config.yaml @@ -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 diff --git a/ipalib/config.py b/ipalib/config.py index 4ee10d2a8..52b032a25 100644 --- a/ipalib/config.py +++ b/ipalib/config.py @@ -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('.'))) diff --git a/ipaserver/secrets/kem.py b/ipaserver/secrets/kem.py index 5521c4772..ad932b6b6 100644 --- a/ipaserver/secrets/kem.py +++ b/ipaserver/secrets/kem.py @@ -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): |