diff options
author | Rob Crittenden <rcritten@redhat.com> | 2010-03-29 11:31:10 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2010-03-30 09:41:17 -0400 |
commit | c3c850b1d795bec6d11e2dc00cd31676a97ba208 (patch) | |
tree | 49d12fafe5a6357732e757449406c7ab9a1f429c /ipalib | |
parent | c7a35f95c5f1835c131797124f95f22968fbf8d8 (diff) | |
download | freeipa-c3c850b1d795bec6d11e2dc00cd31676a97ba208.tar.gz freeipa-c3c850b1d795bec6d11e2dc00cd31676a97ba208.tar.xz freeipa-c3c850b1d795bec6d11e2dc00cd31676a97ba208.zip |
Deleting a non-fully-qualified hostname should still delete its services
We were being left with orphan services if the host entry was not removed
using the FQDN.
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugins/host.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index d72f53051..320cf34f7 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -40,7 +40,7 @@ def validate_host(ugettext, fqdn): Require at least one dot in the hostname (to support localhost.localdomain) """ if fqdn.find('.') == -1: - return 'Fully-qualified hostname required' + return _('Fully-qualified hostname required') return None @@ -181,11 +181,17 @@ class host_del(LDAPDelete): msg_summary = _('Deleted host "%(value)s"') def pre_callback(self, ldap, dn, *keys, **options): + # If we aren't given a fqdn, find it + if validate_host(None, keys[-1]) is not None: + hostentry = api.Command['host_show'](keys[-1])['result'] + fqdn = hostentry['fqdn'][0] + else: + fqdn = keys[-1] # Remove all service records for this host truncated = True while truncated: try: - ret = api.Command['service_find'](keys[-1]) + ret = api.Command['service_find'](fqdn) truncated = ret['truncated'] services = ret['result'] except errors.NotFound: @@ -194,7 +200,7 @@ class host_del(LDAPDelete): for entry_attrs in services: principal = entry_attrs['krbprincipalname'][0] (service, hostname, realm) = split_principal(principal) - if hostname.lower() == keys[-1]: + if hostname.lower() == fqdn: api.Command['service_del'](principal) return dn |