summaryrefslogtreecommitdiff
path: root/bin
diff options
authorPMR <pmr@pmr-lander>2020-01-30 08:38:17 +0000
committerPMR <pmr@pmr-lander>2020-01-30 08:38:17 +0000
commit83b3db8612c6c1e2da42d5106b44f03d6fa22ead (patch)
treefb3eb4ea7c441fe3566c9c95caef4d624af7a0ed /bin
parent51cf09675bd1c5f1cab2869e08a9e8e57be36208 (diff)
parentef098d4eb81e3d62336f9c165e82ca0ca39e5fb6 (diff)
Merge #372737 from ~rodsmith/plainbox-provider-checkbox:add-firmware-reboot-test
Add a test to see if the firmware claims support for the EFI reboot-to-firmware-setup feature, which is present in most new UEFIs.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/boot_mode_test45
1 files changed, 35 insertions, 10 deletions
diff --git a/bin/boot_mode_test b/bin/boot_mode_test
index 7c9358c..e51a099 100755
--- a/bin/boot_mode_test
+++ b/bin/boot_mode_test
@@ -26,19 +26,16 @@ import logging
from argparse import ArgumentParser
-def version_check(check):
- """Check the installed Ubuntu version to see if it is older than 16.04
- (Xenial) and run the requested check
+def do_tests(check):
+ """Dispatcher for the requested tests.
:returns:
- 0 if if the installed version is older than 16.04 regardless of return
- code from the requested check
-
- return code from requested check if the installed version is 16.04 or
- newer.
+ return code from requested check.
"""
if check == 'efi':
return efi_boot_check()
+ elif check == 'reboot_firmware':
+ return reboot_to_firmware_check()
else:
return secure_boot_check()
@@ -59,6 +56,33 @@ def efi_boot_check():
return 1
+def reboot_to_firmware_check():
+ """Test that the computer supports the reboot-to-firmware feature.
+
+ :returns:
+ 0 if the feature IS supported (pass)
+ 1 if the feature is NOT supported (fail)
+ """
+ osis_dir = "/sys/firmware/efi/efivars/"
+ osis_var = osis_dir + \
+ "OsIndicationsSupported-8be4df61-93ca-11d2-aa0d-00e098032b8c"
+ if os.path.isdir(osis_dir):
+ if os.path.isfile(osis_var):
+ fw_info = open(osis_var).read()
+ if ord(fw_info[4]) & 1:
+ logging.info("PASS: Reboot-to-firmware feature is present.")
+ return 0
+ else:
+ logging.error("FAIL: Reboot-to-firmware feature is missing.")
+ return 1
+ else:
+ logging.info("FAIL: OsIndicationsSupported variable not present.")
+ return 1
+ else:
+ logging.info("FAIL: System did NOT boot in EFI mode.")
+ return 1
+
+
def secure_boot_check():
"""Test that the computer booted with Secure Boot active.
@@ -97,13 +121,14 @@ def secure_boot_check():
def main():
parser = ArgumentParser()
parser.add_argument('check',
- choices=['efi', 'secureboot'],
+ choices=['efi', 'secureboot', 'reboot_firmware'],
help='The type of check to perform')
args = parser.parse_args()
FORMAT = '%(levelname)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=FORMAT)
- return version_check(args.check)
+ return do_tests(args.check)
+
if __name__ == '__main__':
sys.exit(main())