diff options
author | Christian Breunig <christian@breunig.cc> | 2024-09-16 17:33:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 17:33:10 +0200 |
commit | 53fa5c9e93a45e2f8c78adf69652bc2f875cef53 (patch) | |
tree | e49d7d635809da09df83898e720f9b053e2dfb11 /python | |
parent | 27e2016952f8fdd01d59f73c67ac9b8a30b756b6 (diff) | |
parent | 07c4fe9ba4511f06bdd302cf37b3059ea86df8c6 (diff) | |
download | vyos-1x-53fa5c9e93a45e2f8c78adf69652bc2f875cef53.tar.gz vyos-1x-53fa5c9e93a45e2f8c78adf69652bc2f875cef53.zip |
Merge pull request #4020 from c-po/secure-boot
T861: op-mode: initial parts for UEFI secure boot CLI
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/system/grub.py | 2 | ||||
-rw-r--r-- | python/vyos/utils/boot.py | 6 | ||||
-rw-r--r-- | python/vyos/utils/system.py | 8 |
3 files changed, 14 insertions, 2 deletions
diff --git a/python/vyos/system/grub.py b/python/vyos/system/grub.py index daddb799a..de8303ee2 100644 --- a/python/vyos/system/grub.py +++ b/python/vyos/system/grub.py @@ -82,7 +82,7 @@ def install(drive_path: str, boot_dir: str, efi_dir: str, id: str = 'VyOS', chro f'{chroot_cmd} grub-install --no-floppy --recheck --target={efi_installation_arch}-efi \ --force-extra-removable --boot-directory={boot_dir} \ --efi-directory={efi_dir} --bootloader-id="{id}" \ - --no-uefi-secure-boot' + --uefi-secure-boot' ) diff --git a/python/vyos/utils/boot.py b/python/vyos/utils/boot.py index 3aecbec64..708bef14d 100644 --- a/python/vyos/utils/boot.py +++ b/python/vyos/utils/boot.py @@ -1,4 +1,4 @@ -# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io> +# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -33,3 +33,7 @@ def boot_configuration_success() -> bool: if int(res) == 0: return True return False + +def is_uefi_system() -> bool: + efi_fw_dir = '/sys/firmware/efi' + return os.path.exists(efi_fw_dir) and os.path.isdir(efi_fw_dir) diff --git a/python/vyos/utils/system.py b/python/vyos/utils/system.py index fca93d118..7b12efb14 100644 --- a/python/vyos/utils/system.py +++ b/python/vyos/utils/system.py @@ -139,3 +139,11 @@ def get_load_averages(): res[15] = float(matches["fifteen"]) / core_count return res + +def get_secure_boot_state() -> bool: + from vyos.utils.process import cmd + from vyos.utils.boot import is_uefi_system + if not is_uefi_system(): + return False + tmp = cmd('mokutil --sb-state') + return bool('enabled' in tmp) |