index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Daniel <blackrabbit256@gmail.com> | 2022-03-01 01:42:49 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 15:42:49 +0100 |
commit | 0fed839110983f024edda88c10d9cd55be9ae122 (patch) | |
tree | 61b4556294aa588c16291c14c9b171c720bde987 /archinstall/lib/user_interaction.py | |
parent | 7e19bf6e2ec2101b590405e6860007309661872b (diff) |
-rw-r--r-- | archinstall/lib/user_interaction.py | 45 |
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index aaf57143..e57fca8a 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -19,7 +19,7 @@ if TYPE_CHECKING: from .disk.partition import Partition from .disk import BlockDevice, suggest_single_disk_layout, suggest_multi_disk_layout, valid_parted_position, all_blockdevices -from .exceptions import RequirementError, UserError, DiskError +from .exceptions import RequirementError, DiskError from .hardware import AVAILABLE_GFX_DRIVERS, has_uefi, has_amd_graphics, has_intel_graphics, has_nvidia_graphics from .locale_helpers import list_keyboard_languages, list_timezones, list_locales from .networking import list_interfaces @@ -327,30 +327,15 @@ def ask_hostname(preset :str = None) -> str : return hostname -def ask_for_superuser_account(prompt: str = '', forced :bool = False) -> Dict[str, Dict[str, str]]: - prompt = prompt if prompt else _('Username for required superuser with sudo privileges: ') - while 1: - new_user = input(prompt).strip(' ') - - if not new_user and forced: - # TODO: make this text more generic? - # It's only used to create the first sudo user when root is disabled in guided.py - log(' * Since root is disabled, you need to create a least one superuser!', fg='red') - continue - elif not new_user and not forced: - raise UserError("No superuser was created.") - elif not check_for_correct_username(new_user): - continue +def ask_for_superuser_account(prompt: str) -> Dict[str, Dict[str, str]]: + prompt = prompt if prompt else str(_('Enter username for superuser with sudo privileges (leave blank for no superusers): ')) + superusers = ask_for_additional_users(prompt) + return superusers - prompt = str(_('Password for user "{}": ').format(new_user)) - password = get_password(prompt=prompt) - return {new_user: {"!password": password}} - -def ask_for_additional_users(prompt :str = '') -> tuple[dict[str, dict[str, str | None]], dict[str, dict[str, str | None]]]: +def ask_for_additional_users(prompt :str = '') -> Dict[str, Dict[str, str | None]]: prompt = prompt if prompt else _('Any additional users to install (leave blank for no users): ') users = {} - superusers = {} while 1: new_user = input(prompt).strip(' ') @@ -359,21 +344,11 @@ def ask_for_additional_users(prompt :str = '') -> tuple[dict[str, dict[str, str if not check_for_correct_username(new_user): continue - password = get_password(prompt=str(_('Password for user "{}": ').format(new_user))) - - choice = Menu( - str(_('Should this user be a superuser (sudoer)?')), - ['yes', 'no'], - skip=False, - default_option='no' - ).run() - - if choice == 'yes': - superusers[new_user] = {"!password": password} - else: - users[new_user] = {"!password": password} + password_prompt = str(_('Password for user "{}": ').format(new_user)) + password = get_password(prompt=password_prompt) + users[new_user] = {"!password": password} - return users, superusers + return users def ask_for_a_timezone(preset :str = None) -> str: |