diff options
-rw-r--r-- | iutil.py | 15 | ||||
-rw-r--r-- | textw/userauth.py | 11 |
2 files changed, 25 insertions, 1 deletions
@@ -218,4 +218,19 @@ def rmrf (path): os.unlink (path + '/' + file) os.rmdir (path) +def validUser (user): + if len (user) > 8: + return 0 + if not user[0] in string.letters: + return 0 + + for letter in user: + if (letter == ':' + or letter == ',' + or letter == '\n' + or ord (letter) < 33): + return 0 + + return 1 + diff --git a/textw/userauth.py b/textw/userauth.py index 769fd445b..daf962df4 100644 --- a/textw/userauth.py +++ b/textw/userauth.py @@ -2,7 +2,8 @@ from snack import * from textw.constants import * from text import _ - +import iutil + class RootPasswordWindow: def __call__ (self, screen, todo): toplevel = GridForm (screen, _("Root Password"), 1, 3) @@ -86,6 +87,14 @@ class UsersWindow: not len(userid.value()) and not len(fullname.value()): return INSTALL_OK + if (not iutil.validUser(userid.value())): + ButtonChoiceWindow(self.screen, _("Bad User ID"), + _("User IDs must be less than 8 " + "characters and contain only characters " + "A-Z, a-z, and 0-9."), + buttons = [ _("OK") ], width = 50) + continue + if not userid.value (): ButtonChoiceWindow(self.screen, _("Missing User ID"), _("You must provide a user ID"), |