From cd70689b0642d41dcbdb826df4fc9f79b1ef899e Mon Sep 17 00:00:00 2001 From: "M. Vefa Bicakci" Date: Fri, 19 Oct 2018 08:02:12 +0200 Subject: [PATCH] anaconda: Modify user configuration spoke for QubesOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frédéric Pierret --- pyanaconda/ui/gui/spokes/user.glade | 96 +++++++------------------------------ pyanaconda/ui/gui/spokes/user.py | 57 +++------------------- pyanaconda/ui/tui/spokes/user.py | 21 ++------ 3 files changed, 28 insertions(+), 146 deletions(-) diff --git a/pyanaconda/ui/gui/spokes/user.glade b/pyanaconda/ui/gui/spokes/user.glade index 2873ff2d9..e6700657d 100644 --- a/pyanaconda/ui/gui/spokes/user.glade +++ b/pyanaconda/ui/gui/spokes/user.glade @@ -1,5 +1,5 @@ - + @@ -53,33 +53,15 @@ False 8 9 - - - True - False - 1 - 10 - _Full name - True - t_fullname - - - - - - 0 - 0 - - True False - 1 10 _User name True t_username + 1 @@ -89,29 +71,12 @@ 1 - - - True - True - False - - - - Full Name - - - - - 1 - 0 - - True True - + User Name @@ -127,11 +92,11 @@ True False - 1 10 _Password True t_password + 1 @@ -145,11 +110,11 @@ True False - 1 10 _Confirm password True t_verifypassword + 1 @@ -166,7 +131,7 @@ False - + Password @@ -184,7 +149,7 @@ True False - + Confirm Password @@ -200,9 +165,9 @@ True False - 0 <b>Tip:</b> Keep your user name shorter than 32 characters and do not use spaces. True + 0 1 @@ -268,45 +233,16 @@ - - _Make this user administrator - True - True - False - True - 0 - True - - - - 1 - 3 - + - - True - False - - - _Advanced... - True - False - True - True - True - - - - 0 - 0 - - - - - 1 - 8 - + + + + + + + diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py index e954292c7..dac6ba3e5 100644 --- a/pyanaconda/ui/gui/spokes/user.py +++ b/pyanaconda/ui/gui/spokes/user.py @@ -38,7 +38,7 @@ from pyanaconda.constants import ANACONDA_ENVIRON, FIRSTBOOT_ENVIRON,\ PW_ASCII_CHARS, PASSWORD_ASCII from pyanaconda.regexes import GECOS_VALID, GROUPNAME_VALID, GROUPLIST_FANCY_PARSE -__all__ = ["UserSpoke", "AdvancedUserDialog"] +__all__ = ["UserSpoke"] class AdvancedUserDialog(GUIObject, GUIDialogInputCheckHandler): """ @@ -214,7 +214,7 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): builderObjects = ["userCreationWindow"] mainWidgetName = "userCreationWindow" - focusWidgetName = "t_fullname" + focusWidgetName = "t_username" uiFile = "spokes/user.glade" helpFile = "UserSpoke.xml" @@ -252,14 +252,16 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): else: self._user = self.data.UserData() + self._wheel = self.data.GroupData(name="wheel") + self._qubes = self.data.GroupData(name="qubes") + + self._groupDict = {"wheel": self._wheel, "qubes": self._qubes} + # placeholders for the text boxes - self.fullname = self.builder.get_object("t_fullname") self.username = self.builder.get_object("t_username") self.pw = self.builder.get_object("t_password") self.confirm = self.builder.get_object("t_verifypassword") - self.admin = self.builder.get_object("c_admin") self.usepassword = self.builder.get_object("c_usepassword") - self.b_advanced = self.builder.get_object("b_advanced") # Counters for checks that ask the user to click Done to confirm self._waiveStrengthClicks = 0 @@ -306,8 +308,6 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): self.add_check(self.username, self._checkUsername) - self.add_re_check(self.fullname, GECOS_VALID, _("Full name cannot contain colon characters")) - # Modify the GUI based on the kickstart and policy information # This needs to happen after the input checks have been created, since # the Gtk signal handlers use the input check variables. @@ -323,9 +323,6 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): # User isn't allowed to change whether password is required or not self.usepassword.set_sensitive(False) - self._advanced = AdvancedUserDialog(self._user, self.data) - self._advanced.initialize() - # set the visibility of the password entries set_password_visibility(self.pw, False) set_password_visibility(self.confirm, False) @@ -336,8 +333,6 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): check.enabled = True self.username.set_text(self._user.name) - self.fullname.set_text(self._user.gecos) - self.admin.set_active("wheel" in self._user.groups) self.pw.emit("changed") self.confirm.emit("changed") @@ -378,7 +373,6 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): self._password_kickstarted = False self._user.name = self.username.get_text() - self._user.gecos = self.fullname.get_text() if "wheel" not in self._user.groups: self._user.groups.append("wheel") @@ -469,34 +463,10 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): def username_changed(self, editable, data=None): """Called by Gtk on all username changes.""" - # Disable the advanced user dialog button when no username is set - if editable.get_text(): - self.b_advanced.set_sensitive(True) - else: - self.b_advanced.set_sensitive(False) - # Re-run the password checks against the new username self.pw.emit("changed") self.confirm.emit("changed") - def full_name_changed(self, editable, data=None): - """Called by Gtk callback when the full name field changes.""" - - if self.guesser: - fullname = editable.get_text() - username = guess_username(fullname) - - with blockedHandler(self.username, self.on_username_set_by_user): - self.username.set_text(username) - - def on_admin_toggled(self, togglebutton, data=None): - # Add or remove "wheel" from the grouplist on changes to the admin checkbox - if togglebutton.get_active(): - if "wheel" not in self._user.groups: - self._user.groups.append("wheel") - elif "wheel" in self._user.groups: - self._user.groups.remove("wheel") - def _checkPasswordEmpty(self, inputcheck): """Check whether a password has been specified at all. @@ -612,19 +582,6 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler): else: return msg or _("Invalid user name") - def on_advanced_clicked(self, _button, data=None): - """Handler for the Advanced.. button. It starts the Advanced dialog - for setting homedit, uid, gid and groups. - """ - - self._user.name = self.username.get_text() - - self._advanced.refresh() - with self.main_window.enlightbox(self._advanced.window): - self._advanced.run() - - self.admin.set_active("wheel" in self._user.groups) - def on_back_clicked(self, button): # If the failed check is for non-ASCII characters, # add a click to the counter and check again diff --git a/pyanaconda/ui/tui/spokes/user.py b/pyanaconda/ui/tui/spokes/user.py index 1005852db..834b82cbf 100644 --- a/pyanaconda/ui/tui/spokes/user.py +++ b/pyanaconda/ui/tui/spokes/user.py @@ -40,11 +40,9 @@ class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke): edit_fields = [ Entry("Create user", "_create", EditTUISpoke.CHECK, True), - Entry("Fullname", "gecos", GECOS_VALID, lambda self, args: args._create), Entry("Username", "name", check_username, lambda self, args: args._create), Entry("Use password", "_use_password", EditTUISpoke.CHECK, lambda self, args: args._create), Entry("Password", "_password", EditTUISpoke.PASSWORD, lambda self, args: args._use_password and args._create), - Entry("Administrator", "_admin", EditTUISpoke.CHECK, lambda self, args: args._create), Entry("Groups", "_groups", GROUPLIST_SIMPLE_VALID, lambda self, args: args._create) ] @@ -84,7 +82,6 @@ class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke): 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 @@ -146,22 +143,14 @@ class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke): return EditTUISpoke.input(self, args, key) def apply(self): - if self.args.gecos and not self.args.name: - username = guess_username(self.args.gecos) - valid, msg = check_username(username) - if not valid: - self.errors.append(_("Invalid user name: %(name)s.\n%(error_message)s") - % {"name": username, "error_message": msg}) - else: - self.args.name = guess_username(self.args.gecos) - self.args.groups = [g.strip() for g in self.args._groups.split(",") if g] - # Add or remove the user from wheel group - if self.args._admin and "wheel" not in self.args.groups: + # Add the user to the wheel and qubes groups + if "wheel" not in self.args.groups: self.args.groups.append("wheel") - elif not self.args._admin and "wheel" in self.args.groups: - self.args.groups.remove("wheel") + + if "qubes" not in self.args.groups: + self.args.groups.append("qubes") # Add or remove the user from userlist as needed if self.args._create and (self.args not in self.data.user.userList and self.args.name): -- 2.14.4