mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Improve zonemgr validator and normalizer
The validator has been improved to support better both SOA format (e-mail address in a domain name format, without '@') and standard e-mail format. Allow '\.' character in a SOA format encoding the standard '.' in the local-part of an e-mail. Normalization code has been moved to one common function. https://fedorahosted.org/freeipa/ticket/2053
This commit is contained in:
@@ -27,7 +27,7 @@ from ipalib import Command
|
||||
from ipalib import Flag, Bool, Int, List, Str, StrEnum
|
||||
from ipalib.plugins.baseldap import *
|
||||
from ipalib import _, ngettext
|
||||
from ipalib.util import validate_zonemgr, validate_hostname
|
||||
from ipalib.util import validate_zonemgr, normalize_zonemgr, validate_hostname
|
||||
from ipapython import dnsclient
|
||||
from ipapython.ipautil import valid_ip
|
||||
from ldap import explode_dn
|
||||
@@ -152,13 +152,6 @@ def _rname_validator(ugettext, zonemgr):
|
||||
return unicode(e)
|
||||
return None
|
||||
|
||||
# normalizer for admin email
|
||||
def _rname_normalizer(value):
|
||||
value = value.replace('@', '.')
|
||||
if not value.endswith('.'):
|
||||
value += '.'
|
||||
return value
|
||||
|
||||
def _create_zone_serial(**kwargs):
|
||||
"""Generate serial number for zones."""
|
||||
return int('%s01' % time.strftime('%Y%d%m'))
|
||||
@@ -678,7 +671,7 @@ class dnszone(LDAPObject):
|
||||
label=_('Administrator e-mail address'),
|
||||
doc=_('Administrator e-mail address'),
|
||||
default_from=lambda idnsname: 'root.%s' % idnsname,
|
||||
normalizer=_rname_normalizer,
|
||||
normalizer=normalize_zonemgr,
|
||||
),
|
||||
Int('idnssoaserial?',
|
||||
cli_name='serial',
|
||||
|
||||
Reference in New Issue
Block a user