diff options
author | Rob Crittenden <rcrit@ipa.greyoak.com> | 2008-08-06 13:00:36 -0400 |
---|---|---|
committer | Rob Crittenden <rcrit@ipa.greyoak.com> | 2008-08-07 11:21:33 -0400 |
commit | 110f60da8e8cbf2b83f66b4959857dc62b407f06 (patch) | |
tree | 17ad23d4b346d7e826f8e3755697c382ed5ac84e /ipa-python/ipaadminutil.py | |
parent | fbc74a0cb48e7c596eb5c03fd56c068a8e0ef29e (diff) | |
download | freeipa.git-110f60da8e8cbf2b83f66b4959857dc62b407f06.tar.gz freeipa.git-110f60da8e8cbf2b83f66b4959857dc62b407f06.tar.xz freeipa.git-110f60da8e8cbf2b83f66b4959857dc62b407f06.zip |
Change user and group validators to match shadow-utils
This sets the regex to [a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?
Also change the validators to return True/False
450613, 457124
Diffstat (limited to 'ipa-python/ipaadminutil.py')
-rw-r--r-- | ipa-python/ipaadminutil.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ipa-python/ipaadminutil.py b/ipa-python/ipaadminutil.py index d94ced4d..27337642 100644 --- a/ipa-python/ipaadminutil.py +++ b/ipa-python/ipaadminutil.py @@ -22,6 +22,7 @@ import tempfile import logging import subprocess import os +import ipa.ipavalidate as ipavalidate def select_user(counter, users): """counter is the number of User objects in users @@ -82,3 +83,11 @@ def select_group(counter, groups): print "Please enter a number between 1 and %s" % counter return groupindex + +def check_name(name): + """Helper to ensure that a user or group name is legal""" + + if (not ipavalidate.GoodName(name, notEmpty=True)): + raise ValueError("may only include letters, numbers, _, -, . and $") + + return |