Skip to content

Commit 13cdb08

Browse files
ckyrouaccgwalters
authored andcommitted
status: Check ostree version before enabling soft reboot
Add ostree version check to has_soft_reboot_capability() to ensure soft reboot is disabled when ostree < 2025.7 and ostree= karg is missing. This prevents attempting soft reboots on older ostree versions that have a bug when validating kargs during a factory reset. Signed-off-by: ckyrouac <[email protected]>
1 parent aff811f commit 13cdb08

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

crates/lib/src/status.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,25 @@ impl From<ImageReference> for OstreeImageReference {
9595

9696
/// Check if a deployment has soft reboot capability
9797
fn has_soft_reboot_capability(sysroot: &SysrootLock, deployment: &ostree::Deployment) -> bool {
98-
ostree_ext::systemd_has_soft_reboot() && sysroot.deployment_can_soft_reboot(deployment)
98+
if !ostree_ext::systemd_has_soft_reboot() {
99+
return false;
100+
}
101+
102+
// When the ostree version is < 2025.7 and the deployment is
103+
// missing the ostree= karg (happens during a factory reset),
104+
// there is a bug that causes deployment_can_soft_reboot to crash.
105+
// So in this case default to disabling soft reboot.
106+
let has_ostree_karg = deployment
107+
.bootconfig()
108+
.and_then(|bootcfg| bootcfg.get("options"))
109+
.map(|options| options.contains("ostree="))
110+
.unwrap_or(false);
111+
112+
if !ostree::check_version(2025, 7) && !has_ostree_karg {
113+
return false;
114+
}
115+
116+
sysroot.deployment_can_soft_reboot(deployment)
99117
}
100118

101119
/// Parse an ostree origin file (a keyfile) and extract the targeted

0 commit comments

Comments
 (0)