diff options
author | Ondrej Hamada <ohamada@redhat.com> | 2012-03-27 15:15:20 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-03-28 16:23:37 +0200 |
commit | 5cfee2338d548035151926c5c235f3426fca0499 (patch) | |
tree | bfaf5b0b796d398386e971c1ba272bb748e91145 /ipalib/util.py | |
parent | 159e848d85779e8fb3a9b2ed84490423014bf609 (diff) | |
download | freeipa-5cfee2338d548035151926c5c235f3426fca0499.tar.gz freeipa-5cfee2338d548035151926c5c235f3426fca0499.tar.xz freeipa-5cfee2338d548035151926c5c235f3426fca0499.zip |
Netgroup nisdomain and hosts validation
nisdomain validation:
Added pattern to the 'nisdomain' parameter to validate the specified
nisdomain name. According to most common use cases the same pattern as
for netgroup should fit. Unit-tests added.
https://fedorahosted.org/freeipa/ticket/2448
'add_external_pre_callback' function was created to allow validation of
all external members. Validation is based on usage of objects primary
key parameter. The 'add_external_pre_callback' fucntion has to be called
directly from in the 'pre_callback' function. This change affects
netgroup, hbacrule and sudorule commands.
For hostname, the validator allows non-fqdn and underscore characters.
validate_hostname function in ipalib.util was modified and contains
additional option that allows hostname to contain underscore characters.
This option is disabled by default.
Unit-tests added.
https://fedorahosted.org/freeipa/ticket/2447
Diffstat (limited to 'ipalib/util.py')
-rw-r--r-- | ipalib/util.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ipalib/util.py b/ipalib/util.py index bbc0fa674..a79f41cc3 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -230,14 +230,14 @@ def validate_dns_label(dns_label, allow_underscore=False): '- must not be the DNS label character') \ % dict(underscore=underscore_err_msg)) -def validate_domain_name(domain_name): +def validate_domain_name(domain_name, allow_underscore=False): if domain_name.endswith('.'): domain_name = domain_name[:-1] domain_name = domain_name.split(".") # apply DNS name validator to every name part - map(lambda label:validate_dns_label(label), domain_name) + map(lambda label:validate_dns_label(label,allow_underscore), domain_name) if not domain_name[-1].isalpha(): # see RFC 1123 @@ -284,7 +284,7 @@ def validate_zonemgr(zonemgr): validate_domain_name(domain) -def validate_hostname(hostname, check_fqdn=True): +def validate_hostname(hostname, check_fqdn=True, allow_underscore=False): """ See RFC 952, 1123 :param hostname Checked value @@ -299,9 +299,9 @@ def validate_hostname(hostname, check_fqdn=True): if '.' not in hostname: if check_fqdn: raise ValueError(_('not fully qualified')) - validate_dns_label(hostname) + validate_dns_label(hostname,allow_underscore) else: - validate_domain_name(hostname) + validate_domain_name(hostname,allow_underscore) def validate_sshpubkey(ugettext, pubkey): try: |