mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Add SRV record target validator
Add missing SRV record target validator to filter out possible user errors. https://fedorahosted.org/freeipa/ticket/2308
This commit is contained in:
parent
cb4b2e6fac
commit
e1fecfaf6a
@ -888,6 +888,12 @@ class RPRecord(DNSRecord):
|
|||||||
rfc = 1183
|
rfc = 1183
|
||||||
supported = False
|
supported = False
|
||||||
|
|
||||||
|
def _srv_target_validator(ugettext, value):
|
||||||
|
if value == u'.':
|
||||||
|
# service not available
|
||||||
|
return
|
||||||
|
return _domain_name_validator(ugettext, value)
|
||||||
|
|
||||||
class SRVRecord(DNSRecord):
|
class SRVRecord(DNSRecord):
|
||||||
rrtype = 'SRV'
|
rrtype = 'SRV'
|
||||||
rfc = 2782
|
rfc = 2782
|
||||||
@ -908,6 +914,7 @@ class SRVRecord(DNSRecord):
|
|||||||
maxvalue=65535,
|
maxvalue=65535,
|
||||||
),
|
),
|
||||||
Str('target',
|
Str('target',
|
||||||
|
_srv_target_validator,
|
||||||
label=_('Target'),
|
label=_('Target'),
|
||||||
doc=_('The domain name of the target host or \'.\' if the service is decidedly not available at this domain'),
|
doc=_('The domain name of the target host or \'.\' if the service is decidedly not available at this domain'),
|
||||||
),
|
),
|
||||||
|
@ -565,6 +565,15 @@ class test_dns(Declarative):
|
|||||||
expected=errors.ValidationError(name='srvrecord', error=''),
|
expected=errors.ValidationError(name='srvrecord', error=''),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
dict(
|
||||||
|
desc='Try to add invalid SRV record via parts to zone %r using dnsrecord_add' % (dnszone1),
|
||||||
|
command=('dnsrecord_add', [dnszone1, u'_foo._tcp'], {'srv_part_priority': 0,
|
||||||
|
'srv_part_weight' : 0,
|
||||||
|
'srv_part_port' : 123,
|
||||||
|
'srv_part_target' : u'foo bar'}),
|
||||||
|
expected=errors.ValidationError(name='srv_part_target', error=''),
|
||||||
|
),
|
||||||
|
|
||||||
dict(
|
dict(
|
||||||
desc='Add SRV record to zone %r using dnsrecord_add' % (dnszone1),
|
desc='Add SRV record to zone %r using dnsrecord_add' % (dnszone1),
|
||||||
command=('dnsrecord_add', [dnszone1, u'_foo._tcp'], {'srvrecord': u"0 100 1234 %s" % dnszone1_mname}),
|
command=('dnsrecord_add', [dnszone1, u'_foo._tcp'], {'srvrecord': u"0 100 1234 %s" % dnszone1_mname}),
|
||||||
|
Loading…
Reference in New Issue
Block a user