mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
host_del: fix removal of host records
Originally only the first A/AAAA record is removed, and one other record. This commit fixes it and all records are removed. https://fedorahosted.org/freeipa/ticket/5675 Reviewed-By: Petr Spacek <pspacek@redhat.com>
This commit is contained in:
@@ -35,7 +35,7 @@ from ipalib.plugins.service import (split_principal, validate_certificate,
|
|||||||
set_certificate_attrs, ticket_flags_params, update_krbticketflags,
|
set_certificate_attrs, ticket_flags_params, update_krbticketflags,
|
||||||
set_kerberos_attrs, rename_ipaallowedtoperform_from_ldap,
|
set_kerberos_attrs, rename_ipaallowedtoperform_from_ldap,
|
||||||
rename_ipaallowedtoperform_to_ldap, revoke_certs)
|
rename_ipaallowedtoperform_to_ldap, revoke_certs)
|
||||||
from ipalib.plugins.dns import (dns_container_exists, _record_types,
|
from ipalib.plugins.dns import (dns_container_exists, _record_attributes,
|
||||||
add_records_for_host_validation, add_records_for_host,
|
add_records_for_host_validation, add_records_for_host,
|
||||||
get_reverse_zone)
|
get_reverse_zone)
|
||||||
from ipalib import _, ngettext
|
from ipalib import _, ngettext
|
||||||
@@ -772,26 +772,15 @@ class host_del(LDAPDelete):
|
|||||||
# Get all forward resources for this host
|
# Get all forward resources for this host
|
||||||
records = api.Command['dnsrecord_find'](domain, idnsname=parts[0])['result']
|
records = api.Command['dnsrecord_find'](domain, idnsname=parts[0])['result']
|
||||||
for record in records:
|
for record in records:
|
||||||
if 'arecord' in record:
|
for attr in _record_attributes:
|
||||||
remove_fwd_ptr(record['arecord'][0], parts[0],
|
for val in record.get(attr, []):
|
||||||
domain, 'arecord')
|
if attr in ('arecord', 'aaaarecord'):
|
||||||
if 'aaaarecord' in record:
|
remove_fwd_ptr(val, parts[0], domain, attr)
|
||||||
remove_fwd_ptr(record['aaaarecord'][0], parts[0],
|
elif (val.endswith(parts[0]) or
|
||||||
domain, 'aaaarecord')
|
val.endswith(fqdn + '.')):
|
||||||
else:
|
delkw = {unicode(attr): val}
|
||||||
# Try to delete all other record types too
|
api.Command['dnsrecord_del'](
|
||||||
_attribute_types = [str('%srecord' % t.lower())
|
domain, record['idnsname'][0], **delkw)
|
||||||
for t in _record_types]
|
|
||||||
for attr in _attribute_types:
|
|
||||||
if attr not in ['arecord', 'aaaarecord'] and attr in record:
|
|
||||||
for val in record[attr]:
|
|
||||||
if (val.endswith(parts[0]) or
|
|
||||||
val.endswith(fqdn + '.')):
|
|
||||||
delkw = {unicode(attr): val}
|
|
||||||
api.Command['dnsrecord_del'](domain,
|
|
||||||
record['idnsname'][0],
|
|
||||||
**delkw)
|
|
||||||
break
|
|
||||||
|
|
||||||
if self.api.Command.ca_is_enabled()['result']:
|
if self.api.Command.ca_is_enabled()['result']:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user