From 40740423ca31022b797e8696ccdd1a4d3d1b62c3 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Fri, 23 Feb 2024 08:41:41 -0800 Subject: [PATCH] Don't check `/run` for systemd if we're not starting the daemon (#853) * Don't check /run for systemd if we're not starting the daemon * Add a note about start_daemon and checking /run/systemd/system --- src/action/common/configure_init_service.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/action/common/configure_init_service.rs b/src/action/common/configure_init_service.rs index a6b109f..bd56859 100644 --- a/src/action/common/configure_init_service.rs +++ b/src/action/common/configure_init_service.rs @@ -79,10 +79,14 @@ impl ConfigureInitService { }, #[cfg(target_os = "linux")] InitSystem::Systemd => { - // If /run/systemd/system exists, we can be reasonably sure the machine is booted - // with systemd: https://www.freedesktop.org/software/systemd/man/sd_booted.html - if !Path::new("/run/systemd/system").exists() { - return Err(Self::error(ActionErrorKind::SystemdMissing)); + // If `no_start_daemon` is set, then we don't require a running systemd, + // so we don't need to check if `/run/systemd/system` exists. + if start_daemon { + // If /run/systemd/system exists, we can be reasonably sure the machine is booted + // with systemd: https://www.freedesktop.org/software/systemd/man/sd_booted.html + if !Path::new("/run/systemd/system").exists() { + return Err(Self::error(ActionErrorKind::SystemdMissing)); + } } if which::which("systemctl").is_err() {