diff --git a/archinstall/lib/authentication/authentication_menu.py b/archinstall/lib/authentication/authentication_menu.py index e8852bbb74..b88853e4e5 100644 --- a/archinstall/lib/authentication/authentication_menu.py +++ b/archinstall/lib/authentication/authentication_menu.py @@ -35,20 +35,13 @@ def _define_menu_options(self) -> list[MenuItem]: return [ MenuItem( text=tr('U2F login setup'), - action=setup_u2f_login, + action=select_u2f_login, value=self._auth_config.u2f_config, preview_action=self._prev_u2f_login, - dependencies=[self._depends_on_u2f], key='u2f_config', ), ] - def _depends_on_u2f(self) -> bool: - devices = Fido2.get_fido2_devices() - if not devices: - return False - return True - def _prev_u2f_login(self, item: MenuItem) -> str | None: if item.value is not None: u2f_config: U2FLoginConfiguration = item.value @@ -60,10 +53,19 @@ def _prev_u2f_login(self, item: MenuItem) -> str | None: output += tr('Passwordless sudo: ') + (tr('Enabled') if u2f_config.passwordless_sudo else tr('Disabled')) return output + + devices = Fido2.get_fido2_devices() + if not devices: + return tr('No U2F devices found') + return None -def setup_u2f_login(preset: U2FLoginConfiguration) -> U2FLoginConfiguration | None: +def select_u2f_login(preset: U2FLoginConfiguration) -> U2FLoginConfiguration | None: + devices = Fido2.get_fido2_devices() + if not devices: + return None + items = [] for method in U2FLoginMethod: items.append(MenuItem(method.display_value(), value=method)) diff --git a/archinstall/lib/disk/fido.py b/archinstall/lib/disk/fido.py index b6676db41d..716ec9f80a 100644 --- a/archinstall/lib/disk/fido.py +++ b/archinstall/lib/disk/fido.py @@ -36,7 +36,10 @@ def get_fido2_devices(cls) -> list[Fido2Device]: fido_devices = clear_vt100_escape_codes_from_str(ret) - for line in fido_devices.split('\r\n'): + if not fido_devices: + return [] + + for line in fido_devices.splitlines(): path, details = line.replace(',', '').split(':', maxsplit=1) _, product, manufacturer = details.strip().split(' ', maxsplit=2) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 652482ed49..ac861f022c 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1506,7 +1506,7 @@ def _add_efistub_bootloader( parent_dev_path = device_handler.get_parent_device_path(boot_partition.safe_dev_path) - cmd_template = [ + cmd_template = ( 'efibootmgr', '--create', '--disk', @@ -1520,7 +1520,7 @@ def _add_efistub_bootloader( '--unicode', *cmdline, '--verbose', - ] + ) for kernel in self.kernels: # Setup the firmware entry