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
This commit is contained in:
Ana Hobden 2024-02-23 08:41:41 -08:00 committed by GitHub
parent 09ddc9be6b
commit 40740423ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,11 +79,15 @@ impl ConfigureInitService {
}, },
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
InitSystem::Systemd => { InitSystem::Systemd => {
// 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 // 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 // with systemd: https://www.freedesktop.org/software/systemd/man/sd_booted.html
if !Path::new("/run/systemd/system").exists() { if !Path::new("/run/systemd/system").exists() {
return Err(Self::error(ActionErrorKind::SystemdMissing)); return Err(Self::error(ActionErrorKind::SystemdMissing));
} }
}
if which::which("systemctl").is_err() { if which::which("systemctl").is_err() {
return Err(Self::error(ActionErrorKind::SystemdMissing)); return Err(Self::error(ActionErrorKind::SystemdMissing));