Skip to content

Commit

Permalink
Merge pull request #265 from Luap99/systemd
Browse files Browse the repository at this point in the history
aardvark: only use systemd-run when systemd is available
  • Loading branch information
openshift-merge-robot authored Mar 23, 2022
2 parents 862a453 + 60a7d1d commit 4af309f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dns/aardvark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ use std::net::Ipv4Addr;
use std::path::Path;
use std::process::{Command, Stdio};

const SYSTEMD_CHECK_PATH: &str = "/run/systemd/system";
const SYSTEMD_RUN: &str = "systemd-run";

#[derive(Debug, Clone)]
pub struct AardvarkEntry {
pub network_name: String,
Expand Down Expand Up @@ -77,10 +80,10 @@ impl Aardvark {
log::debug!("Spawning aardvark server");

let mut aardvark_args = vec![];
let systemd_run = "systemd-run";
if Aardvark::is_executable_in_path(systemd_run) {
// only use systemd when it is booted, see sd_booted(3)
if Path::new(SYSTEMD_CHECK_PATH).exists() && Aardvark::is_executable_in_path(SYSTEMD_RUN) {
// TODO: This could be replaced by systemd-api.
aardvark_args = vec![systemd_run, "-q", "--scope"];
aardvark_args = vec![SYSTEMD_RUN, "-q", "--scope"];

if self.rootless {
aardvark_args.push("--user");
Expand Down

0 comments on commit 4af309f

Please sign in to comment.