[master/rhel7-branch] Show error on invalid username attempts in TUI. (#1171778)
Samantha N. Bueno
sbueno+anaconda at redhat.com
Wed May 27 17:17:05 UTC 2015
Previously, if a user entered an invalid username (e.g. "root"), no
error was shown and the username "root" was simply not created. This
could trouble users who were expecting a certain user to be created on
their systems, but saw no indication that there was a problem.
Resolves: rhbz#1171778
---
pyanaconda/ui/tui/spokes/user.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/ui/tui/spokes/user.py b/pyanaconda/ui/tui/spokes/user.py
index 1c24d6d..7ef5b5d 100644
--- a/pyanaconda/ui/tui/spokes/user.py
+++ b/pyanaconda/ui/tui/spokes/user.py
@@ -81,9 +81,16 @@ class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke):
# so that all of the properties are set at once
self.args._password = ""
+ self.errors = []
+
def refresh(self, args = None):
self.args._admin = "wheel" in self.args.groups
self.args._groups = ", ".join(self.args.groups)
+
+ # if we have any errors, display them
+ while len(self.errors) > 0:
+ print(self.errors.pop())
+
return EditTUISpoke.refresh(self, args)
@property
@@ -122,7 +129,9 @@ class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke):
def apply(self):
if self.args.gecos and not self.args.name:
username = guess_username(self.args.gecos)
- if USERNAME_VALID.match(username):
+ if not USERNAME_VALID.match(username):
+ self.errors.append(_("Invalid user name: %s.\n" % username))
+ else:
self.args.name = guess_username(self.args.gecos)
self.args.groups = [g.strip() for g in self.args._groups.split(",") if g]
--
2.1.0
More information about the anaconda-patches
mailing list