diff options
author | Tomas Babej <tbabej@redhat.com> | 2014-05-14 12:52:26 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2014-06-25 20:14:49 +0200 |
commit | a228d7a3cb32b14ff24b47adb14d896d317f6312 (patch) | |
tree | 3edbf0018942f36d28d56b317e5941c908bd1c6c /ipalib/util.py | |
parent | 5a1207cb6ee6dd4314ae95e6637ee6859d5fda1a (diff) | |
download | freeipa-a228d7a3cb32b14ff24b47adb14d896d317f6312.tar.gz freeipa-a228d7a3cb32b14ff24b47adb14d896d317f6312.tar.xz freeipa-a228d7a3cb32b14ff24b47adb14d896d317f6312.zip |
sudorule: Allow using hostmasks for setting allowed hosts
Adds a new --hostmasks option to sudorule-add-host and sudorule-remove-host
commands, which allows setting a range of hosts specified by a hostmask.
https://fedorahosted.org/freeipa/ticket/4274
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'ipalib/util.py')
-rw-r--r-- | ipalib/util.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ipalib/util.py b/ipalib/util.py index 265957949..ef759d8d1 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -32,6 +32,7 @@ from types import NoneType from weakref import WeakKeyDictionary from dns import resolver, rdatatype from dns.exception import DNSException +from netaddr.core import AddrFormatError from ipalib import errors from ipalib.text import _ @@ -544,3 +545,9 @@ def validate_rdn_param(ugettext, value): except Exception, e: return str(e) return None + +def validate_hostmask(ugettext, hostmask): + try: + netaddr.IPNetwork(hostmask) + except (ValueError, AddrFormatError): + return _('invalid hostmask') |