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
This commit is contained in:
Rob Crittenden
2008-08-06 13:00:36 -04:00
parent fbc74a0cb4
commit 110f60da8e
12 changed files with 171 additions and 79 deletions

View File

@@ -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