diff --git a/src/symbols/systemd/user_service.rs b/src/symbols/systemd/user_service.rs index fef5692..95af967 100644 --- a/src/symbols/systemd/user_service.rs +++ b/src/symbols/systemd/user_service.rs @@ -1,5 +1,5 @@ use crate::async_utils::sleep; -use crate::command_runner::{CommandRunner, SetuidCommandRunner}; +use crate::command_runner::{CommandRunner, StdCommandRunner, SetuidCommandRunner}; use crate::symbols::Symbol; use async_trait::async_trait; use std::error::Error; @@ -12,6 +12,7 @@ pub struct UserService<'a, S: AsRef, U: AsRef> { socket_path: S, service_name: &'a str, command_runner: SetuidCommandRunner, + root_command_runner: StdCommandRunner, } impl, U: AsRef> UserService<'static, S, U> { @@ -20,13 +21,14 @@ impl, U: AsRef> UserService<'static, S, U> { socket_path, service_name, command_runner: SetuidCommandRunner::new(user_name), + root_command_runner: StdCommandRunner, } } } impl, U: AsRef> UserService<'_, S, U> { async fn systemctl_wait_for_dbus(&self, args: &[&OsStr]) -> Result> { - let mut tries = 5; + let mut tries = 10; loop { let result = self.command_runner.run_with_args("systemctl", args).await?; if result.status.success() { @@ -34,14 +36,15 @@ impl, U: AsRef> UserService<'_, S, U> { } let raw_stderr = std::str::from_utf8(&result.stderr)?; let stderr = raw_stderr.trim_end(); - if stderr != "Failed to connect to bus: No such file or directory" { + if stderr != "Failed to connect to bus: No such file or directory" && + stderr != "Failed to connect to user scope bus via local transport: No such file or directory" { return Err(stderr.into()); } tries -= 1; if tries == 0 { return Err("Gave up waiting for dbus to appear".to_string().into()); } - sleep(Duration::from_millis(500)).await; + sleep(Duration::from_millis(100)).await; } } @@ -63,10 +66,10 @@ impl, U: AsRef> UserService<'_, S, U> { return Err( std::str::from_utf8( &self - .command_runner + .root_command_runner .get_output( "journalctl", - args!["--user", format!("--user-unit={}", self.service_name)], + args![ /*"--user", format!("--user-unit={}", self.service_name)*/ ], ) .await?, )?