From 0fed839110983f024edda88c10d9cd55be9ae122 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 1 Mar 2022 01:42:49 +1100 Subject: Rework the user/superuser configuration (#993) * Fix user/superuser config * Fix flake8 * Remove timezone check since we have a default value now * Remove unused Co-authored-by: Daniel Girtler Co-authored-by: Anton Hvornum --- archinstall/lib/menu/selection_menu.py | 39 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'archinstall/lib/menu') diff --git a/archinstall/lib/menu/selection_menu.py b/archinstall/lib/menu/selection_menu.py index a82e8a70..14278999 100644 --- a/archinstall/lib/menu/selection_menu.py +++ b/archinstall/lib/menu/selection_menu.py @@ -313,15 +313,6 @@ class GeneralMenu: if exec_ret_val and self._check_mandatory_status(): return False return True - """ old behaviour - # we allow for a callback after we get the result - self.post_callback(selector_name,result) - # we have a callback, by option, to determine if we can exit the menu. Only if ALL mandatory fields are written - if selector.exec_func: - if selector.exec_func(result) and self._check_mandatory_status(): - return False - """ - return True def _set_kb_language(self): """ general for ArchInstall""" @@ -474,9 +465,9 @@ class GlobalMenu(GeneralMenu): self._menu_options['!superusers'] = \ Selector( _('Specify superuser account'), - lambda x: self._create_superuser_account(), + lambda: self._create_superuser_account(), dependencies_not=['!root-password'], - display_func=lambda x: list(x.keys()) if x else '') + display_func=lambda x: self._display_superusers()) self._menu_options['!users'] = \ Selector( _('Specify user account'), @@ -564,8 +555,6 @@ class GlobalMenu(GeneralMenu): missing += 1 if not check('audio'): missing += 1 - if not check('timezone'): - missing += 1 if not check('!root-password') and not check('!superusers'): missing += 1 if not check('harddrives'): @@ -579,14 +568,6 @@ class GlobalMenu(GeneralMenu): def _set_root_password(self): prompt = str(_('Enter root password (leave blank to disable root): ')) password = get_password(prompt=prompt) - - # TODO: Do we really wanna wipe the !superusers and !users if root password is set? - # What if they set a superuser first, but then decides to set a root password? - if password is not None: - self._menu_options.get('!superusers').set_current_selection(None) - storage['arguments']['!users'] = {} - storage['arguments']['!superusers'] = {} - return password def _select_encrypted_password(self): @@ -640,11 +621,17 @@ class GlobalMenu(GeneralMenu): return profile def _create_superuser_account(self): - superuser = ask_for_superuser_account(str(_('Create a required super-user with sudo privileges: ')), forced=True) - return superuser + superusers = ask_for_superuser_account(str(_('Enter a username to create an additional superuser (leave blank to skip): '))) + return superusers if superusers else None def _create_user_account(self): - users, superusers = ask_for_additional_users(str(_('Enter a username to create an additional user (leave blank to skip): '))) - storage['arguments']['!superusers'] = {**storage['arguments'].get('!superusers', {}), **superusers} - + users = ask_for_additional_users(str(_('Enter a username to create an additional user (leave blank to skip): '))) return users + + def _display_superusers(self): + superusers = self._data_store.get('!superusers', {}) + + if self._menu_options.get('!root-password').has_selection(): + return list(superusers.keys()) if superusers else '[]' + else: + return list(superusers.keys()) if superusers else '' -- cgit v1.2.3-70-g09d2