From 51286f2a6509c708fa44066ada03116698c0dc05 Mon Sep 17 00:00:00 2001 From: Ruslan Kiyanchuk Date: Sat, 3 Apr 2021 14:44:45 -0700 Subject: Fix undefined variables in installer --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a4321893..663288e5 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -98,7 +98,7 @@ class Installer(): self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) for step in missing_steps: self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning) - self.log(f"Detailed error logs can be found at: {log_path}", level=LOG_LEVELS.Warning) + self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=LOG_LEVELS.Warning) self.log(f"Submit this zip file as an issue to https://github.com/Torxed/archinstall/issues", level=LOG_LEVELS.Warning) self.sync_log_to_install_medium() return False @@ -149,7 +149,7 @@ class Installer(): fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{o}') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n') return True -- cgit v1.2.3-54-g00ecf From 992ee851d4d57cdd11f490123f94c2c23f8c1e76 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Sun, 4 Apr 2021 22:12:31 +0300 Subject: Add lowercase conversion for usernames --- archinstall/lib/user_interaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 8cdbbe8c..e5cdb670 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -49,7 +49,7 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '): def ask_for_superuser_account(prompt='Create a required super-user with sudo privileges: ', forced=False): while 1: - new_user = input(prompt).strip(' ') + new_user = input(prompt).strip(' ').lower() if not new_user and forced: # TODO: make this text more generic? @@ -67,7 +67,7 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan super_users = {} while 1: - new_user = input(prompt).strip(' ') + new_user = input(prompt).strip(' ').lower() if not new_user: break password = get_password(prompt=f'Password for user {new_user}: ') -- cgit v1.2.3-54-g00ecf From 5de1154ce9708f770bacae5faa2ef3c3eea4c2e2 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Mon, 5 Apr 2021 18:38:21 +0300 Subject: Replace lowercase conversion with correct checking --- archinstall/lib/user_interaction.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index e5cdb670..30008fad 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -1,4 +1,4 @@ -import getpass, pathlib, os, shutil +import getpass, pathlib, os, shutil, re from .exceptions import * from .profiles import Profile from .locale_helpers import search_keyboard_layout @@ -49,8 +49,15 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '): def ask_for_superuser_account(prompt='Create a required super-user with sudo privileges: ', forced=False): while 1: - new_user = input(prompt).strip(' ').lower() - + new_user = input(prompt).strip(' ') + + if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32: + log( + "The username you entered is invalid. Try again", + level=LOG_LEVELS.Warning, + fg='red' + ) + continue 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 @@ -67,9 +74,16 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan super_users = {} while 1: - new_user = input(prompt).strip(' ').lower() + new_user = input(prompt).strip(' ') if not new_user: break + if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32: + log( + "The username you entered is invalid. Try again", + level=LOG_LEVELS.Warning, + fg='red' + ) + continue password = get_password(prompt=f'Password for user {new_user}: ') if input("Should this user be a sudo (super) user (y/N): ").strip(' ').lower() in ('y', 'yes'): -- cgit v1.2.3-54-g00ecf From ed2187ee709e40e9da50cec9f0eaf45e77d6a8e9 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Mon, 5 Apr 2021 19:22:48 +0300 Subject: Update regex rule and move check to a function --- archinstall/lib/user_interaction.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 30008fad..a337066e 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -18,6 +18,16 @@ def get_terminal_width(): def get_longest_option(options): return max([len(x) for x in options]) +def check_for_correct_username(username): + if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32: + return True + log( + "The username you entered is invalid. Try again", + level=LOG_LEVELS.Warning, + fg='red' + ) + return False + def get_password(prompt="Enter a password: "): while (passwd := getpass.getpass(prompt)): passwd_verification = getpass.getpass(prompt='And one more time for verification: ') @@ -51,12 +61,7 @@ def ask_for_superuser_account(prompt='Create a required super-user with sudo pri while 1: new_user = input(prompt).strip(' ') - if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32: - log( - "The username you entered is invalid. Try again", - level=LOG_LEVELS.Warning, - fg='red' - ) + if not check_for_correct_username(new_user): continue if not new_user and forced: # TODO: make this text more generic? @@ -77,12 +82,7 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan new_user = input(prompt).strip(' ') if not new_user: break - if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32: - log( - "The username you entered is invalid. Try again", - level=LOG_LEVELS.Warning, - fg='red' - ) + if not check_for_correct_username(new_user): continue password = get_password(prompt=f'Password for user {new_user}: ') -- cgit v1.2.3-54-g00ecf From 1da9e52d52b1f88d5069392da29b8893377009e3 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 5 Apr 2021 22:06:25 +0200 Subject: Corrected for keymap before encrypt hook Also think that we should patch mkinitcpio, not replace it. Especially in the btrfs case where we simply just want to add `btrfs` to the `MODULES` section. --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 0fc9f969..d80f8aa6 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -306,14 +306,14 @@ class Installer(): mkinit.write('MODULES=(btrfs)\n') mkinit.write('BINARIES=(/usr/bin/btrfs)\n') mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect modconf block encrypt filesystems keymap keyboard fsck)\n') + mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') elif self.partition.encrypted: with open(f'{self.mountpoint}/etc/mkinitcpio.conf', 'w') as mkinit: mkinit.write('MODULES=()\n') mkinit.write('BINARIES=()\n') mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect modconf block encrypt filesystems keymap keyboard fsck)\n') + mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') self.helper_flags['base'] = True -- cgit v1.2.3-54-g00ecf From 924b369233e28c11c8bfec423fa25dc9d84e61de Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Mon, 5 Apr 2021 23:13:27 +0300 Subject: Fix incorrect behavior for empty sudo username --- archinstall/lib/user_interaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index a337066e..44c0cb13 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -61,8 +61,6 @@ def ask_for_superuser_account(prompt='Create a required super-user with sudo pri while 1: new_user = input(prompt).strip(' ') - if not check_for_correct_username(new_user): - continue 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 @@ -70,6 +68,8 @@ def ask_for_superuser_account(prompt='Create a required super-user with sudo pri continue elif not new_user and not forced: raise UserError("No superuser was created.") + elif not check_for_correct_username(new_user): + continue password = get_password(prompt=f'Password for user {new_user}: ') return {new_user: {"!password" : password}} -- cgit v1.2.3-54-g00ecf From 3da4dc8e3015479e64603987ae229f75e2146548 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 6 Apr 2021 18:30:20 +0200 Subject: Update installer.py --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 663288e5..9681f1ea 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -149,7 +149,7 @@ class Installer(): fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}') return True -- cgit v1.2.3-54-g00ecf From 275e60e1ddb5da281aab394492c68bed8d5abdcb Mon Sep 17 00:00:00 2001 From: Insanemal Date: Wed, 7 Apr 2021 13:44:04 +1000 Subject: Fix newline issue on fstab writes Forced the newline char fstab writes as Python appears to be selecting the incorrect newlines --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 8673bbee..1d277bc6 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -147,7 +147,7 @@ class Installer(): self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info) fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log - with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh: + with open(f"{self.mountpoint}/etc/fstab", 'ab',newline='\n') as fstab_fh: fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): -- cgit v1.2.3-54-g00ecf From e70aa5244bd07cdaa299df528f8ebd099b00bf64 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 8 Apr 2021 10:36:42 +0200 Subject: Corrected the new-line parameter --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 1d277bc6..16d48183 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -147,11 +147,11 @@ class Installer(): self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info) fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log - with open(f"{self.mountpoint}/etc/fstab", 'ab',newline='\n') as fstab_fh: + with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh: fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{fstab}') return True -- cgit v1.2.3-54-g00ecf