From 1086ea49e0d70da5627873753dc1febdd114d41b Mon Sep 17 00:00:00 2001 From: r-vdp Date: Thu, 23 Apr 2026 09:27:05 +0200 Subject: [PATCH] switch-to-configuration-ng: Fix ExecReload check for added key The branch handling "a key was added to an existing section" compared the section name against "Exec" (the .nspawn section header) instead of "Service", so adding ExecReload= to a [Service] that previously lacked it still triggered a restart instead of a reload. Add a unit test covering this path. --- .../sw/switch-to-configuration-ng/src/main.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs b/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs index 348f7cae5d65..fce4abcd997c 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs @@ -604,7 +604,7 @@ fn compare_units(current_unit: &UnitInfo, new_unit: &UnitInfo) -> UnitComparison return UnitComparison::UnequalNeedsRestart; } } - } else if section_name == "Exec" + } else if section_name == "Service" && ini_cmp.len() == 1 && ini_cmp.contains_key("ExecReload") { @@ -2668,6 +2668,23 @@ invalid ) == super::UnitComparison::UnequalNeedsReload ); + // ExecReload added to an existing [Service] section + assert!( + super::compare_units( + &HashMap::from([( + "Service".to_string(), + HashMap::from([("ExecStart".to_string(), vec!["x".to_string()])]) + )]), + &HashMap::from([( + "Service".to_string(), + HashMap::from([ + ("ExecStart".to_string(), vec!["x".to_string()]), + ("ExecReload".to_string(), vec!["y".to_string()]), + ]) + )]), + ) == super::UnitComparison::UnequalNeedsReload + ); + assert!( super::compare_units( &HashMap::from([(