-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd: Add Boot type to system information #19371
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,16 @@ function findMemoryDevices(udevdb, info) { | |
info.memory = memoryArray; | ||
} | ||
|
||
async function getBootType() { | ||
const secure_boot_file = cockpit.manifests.system.config.secure_boot_file; | ||
try { | ||
const result = await cockpit.file(secure_boot_file, { binary: true }).read(); | ||
return `EFI (Secure Boot ${result[4] === 1 ? "enabled" : "disabled"})`; | ||
} catch { | ||
return "BIOS or Legacy"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is okay, I can wait, and I understand about missing the design bit |
||
} | ||
} | ||
|
||
export default function detect() { | ||
const info = { system: {}, pci: [], memory: [] }; | ||
const tasks = []; | ||
|
@@ -154,6 +164,11 @@ export default function detect() { | |
return true; | ||
})); | ||
|
||
tasks.push(getBootType() | ||
.then(result => { | ||
info.system.boot_type = result; | ||
})); | ||
|
||
// Fallback if systemd < 248 | ||
if (info.memory.length === 0) { | ||
tasks.push(machine_info.memory_info() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -514,6 +514,9 @@ class TestSystemInfo(packagelib.PackageCase): | |
parsed_bios_date = m.execute("date --date $(cat /sys/class/dmi/id/bios_date) '+%B %-d, %Y'").strip() | ||
b.wait_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(3) dd', parsed_bios_date) | ||
|
||
# Boot Type | ||
b.wait_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(4) dd', "BIOS or Legacy") | ||
|
||
pci_selector = '#hwinfo #pci-listing' | ||
heading_selector = ' .pf-v5-c-card__title' | ||
# PCI | ||
|
@@ -610,7 +613,7 @@ model name\t: Professor NumberCrunch | |
|
||
b.reload() | ||
b.enter_page('/system/hwinfo') | ||
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(1) dd', "2x Professor NumberCrunch") | ||
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(2) dd', "2x Professor NumberCrunch") | ||
|
||
# /proc/cpuinfo on PowerPC; complete info | ||
m.write("/tmp/cpuinfo", """processor\t: 0 | ||
|
@@ -626,7 +629,7 @@ revision\t: 2.3 (pvr 004e 1203) | |
|
||
b.reload() | ||
b.enter_page('/system/hwinfo') | ||
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(1) dd', "2x POWER9 (architected), altivec supported") | ||
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(2) dd', "2x POWER9 (architected), altivec supported") | ||
|
||
# correct CPU count on overview | ||
b.go("/system") | ||
|
@@ -661,7 +664,7 @@ machine : 8561 | |
|
||
b.go('/system/hwinfo') | ||
b.enter_page('/system/hwinfo') | ||
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(1) dd', "2x IBM/S390") | ||
b.wait_in_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(2) dd', "2x IBM/S390") | ||
|
||
# umount mocked /sys/class/dmi/id | ||
m.execute("umount /sys/class/dmi/id") | ||
|
@@ -710,6 +713,26 @@ machine : 8561 | |
b.wait_text('#memory-listing tr:nth-of-type(2) td[data-label=Rank]', "Single rank") | ||
b.wait_in_text('#memory-listing tr:nth-of-type(2) td[data-label=Speed]', "2400 MT/s") | ||
|
||
# Pretend UEFI and Secure Boot is enabled | ||
m.execute("echo -en '\\x06\\x00\\x00\\x00\\x01' > /tmp/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c") | ||
self.write_file("/etc/cockpit/systemd.override.json", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. Now I understand. You're doing this to give the tests a hook to mock in a new value. How about a bind mount instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried, couldn't create the missing folder structure, if you have any proposal I am up for it. I am sure creating a VM and booting it with EFI enabled is overkill |
||
'{ "config": { "secure_boot_file": "/tmp/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c" } }') | ||
|
||
b.reload() | ||
b.go("/system/hwinfo") | ||
b.enter_page('/system/hwinfo') | ||
|
||
b.wait_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(4) dd', "EFI (Secure Boot enabled)") | ||
|
||
# Pretend UEFI and Secure Boot is disabled | ||
m.execute("echo -en '\\x06\\x00\\x00\\x00\\x00' > /tmp/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c") | ||
|
||
b.reload() | ||
b.go("/system/hwinfo") | ||
b.enter_page('/system/hwinfo') | ||
|
||
b.wait_text('#hwinfo-system-info-list .hwinfo-system-info-list-item:nth-of-type(2) .pf-v5-c-description-list__group:nth-of-type(4) dd', "EFI (Secure Boot disabled)") | ||
|
||
@ testlib.nondestructive | ||
def testCPUSecurityMitigationsDetect(self): | ||
b = self.browser | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the indirection? Storing this in the manifest seems very strange to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't able to create the folder structure for
/sys/firmware/efi/efivars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean you could just hardcode it directly in the JS... This is a well-known value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please do -- this isn't configuration.