mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Improve dnsrecord-add interactive mode
When an invalid record type is entered during dnsrecord-add interactive mode, user is provided with a list of allowed values (record types). However, the provided list contains also unsupported record types (APL, DHCID, etc.) and any attempt to add such records would end with error. This patch limits the list to supported record types only. https://fedorahosted.org/freeipa/ticket/2378
This commit is contained in:
@@ -1376,6 +1376,8 @@ def __dns_record_options_iter():
|
|||||||
yield extra
|
yield extra
|
||||||
|
|
||||||
_dns_record_options = tuple(__dns_record_options_iter())
|
_dns_record_options = tuple(__dns_record_options_iter())
|
||||||
|
_dns_supported_record_types = tuple(record.rrtype for record in _dns_records \
|
||||||
|
if record.supported)
|
||||||
|
|
||||||
# dictionary of valid reverse zone -> number of address components
|
# dictionary of valid reverse zone -> number of address components
|
||||||
_valid_reverse_zones = {
|
_valid_reverse_zones = {
|
||||||
@@ -1938,9 +1940,12 @@ class dnsrecord_add(LDAPCreate):
|
|||||||
|
|
||||||
if not isinstance(param, DNSRecord):
|
if not isinstance(param, DNSRecord):
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except KeyError, ValueError:
|
|
||||||
all_types = u', '.join(_record_types)
|
if not param.supported:
|
||||||
self.Backend.textui.print_plain(_(u'Invalid type. Allowed values are: %s') % all_types)
|
raise ValueError()
|
||||||
|
except (KeyError, ValueError):
|
||||||
|
all_types = u', '.join(_dns_supported_record_types)
|
||||||
|
self.Backend.textui.print_plain(_(u'Invalid or unsupported type. Allowed values are: %s') % all_types)
|
||||||
continue
|
continue
|
||||||
ok = True
|
ok = True
|
||||||
|
|
||||||
@@ -1964,7 +1969,7 @@ class dnsrecord_add(LDAPCreate):
|
|||||||
# check if any record part was added
|
# check if any record part was added
|
||||||
try:
|
try:
|
||||||
rrparam = self.params[param.hint]
|
rrparam = self.params[param.hint]
|
||||||
except KeyError, AttributeError:
|
except (KeyError, AttributeError):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if rrparam.name in entry_attrs:
|
if rrparam.name in entry_attrs:
|
||||||
|
|||||||
Reference in New Issue
Block a user