[pve-devel] [PATCH installer v3 07/20] common: setup: deserialize `secure_boot` property from runtime env

Christoph Heiss c.heiss at proxmox.com
Wed Aug 21 11:40:09 CEST 2024


Needed for the post-hook functionality, which sends this information as
part of its information set.

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Changes v2 -> v3:
  * no changes

Changes v1 -> v2:
  * new patch

 Proxmox/Install/RunEnv.pm             |  1 +
 proxmox-installer-common/src/setup.rs | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/Proxmox/Install/RunEnv.pm b/Proxmox/Install/RunEnv.pm
index 13ee8d8..e6f5893 100644
--- a/Proxmox/Install/RunEnv.pm
+++ b/Proxmox/Install/RunEnv.pm
@@ -236,6 +236,7 @@ my sub detect_country_tracing_to : prototype($$) {
 #     kernel_cmdline = <contents of /proc/cmdline>,
 #     total_memory = <memory size in MiB>,
 #     hvm_supported = <1 if the CPU supports hardware-accelerated virtualization>,
+#     secure_boot = <1 if SecureBoot is enabled>,
 #     boot_type = <either 'efi' or 'bios'>,
 #     disks => <see Proxmox::Sys::Block::hd_list()>,
 #     network => {
diff --git a/proxmox-installer-common/src/setup.rs b/proxmox-installer-common/src/setup.rs
index 51d8711..d5bdc9e 100644
--- a/proxmox-installer-common/src/setup.rs
+++ b/proxmox-installer-common/src/setup.rs
@@ -236,6 +236,14 @@ where
     Ok(val != 0)
 }
 
+fn deserialize_bool_from_int_maybe<'de, D>(deserializer: D) -> Result<Option<bool>, D::Error>
+where
+    D: Deserializer<'de>,
+{
+    let val: Option<u32> = Deserialize::deserialize(deserializer)?;
+    Ok(val.map(|v| v != 0))
+}
+
 fn deserialize_cczones_map<'de, D>(
     deserializer: D,
 ) -> Result<HashMap<String, Vec<String>>, D::Error>
@@ -333,6 +341,10 @@ pub struct RuntimeInfo {
     /// Whether the CPU supports hardware-accelerated virtualization
     #[serde(deserialize_with = "deserialize_bool_from_int")]
     pub hvm_supported: bool,
+
+    /// Whether the system was booted with SecureBoot enabled
+    #[serde(default, deserialize_with = "deserialize_bool_from_int_maybe")]
+    pub secure_boot: Option<bool>,
 }
 
 #[derive(Copy, Clone, Eq, Deserialize, PartialEq)]
-- 
2.45.2





More information about the pve-devel mailing list