|
|
@ -8,28 +8,23 @@ use std::path::Path; |
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct UserService<'a, S: AsRef<Path>, U: AsRef<str>, R: CommandRunner> {
|
|
|
|
pub struct UserService<'a, S: AsRef<Path>, U: AsRef<str>> {
|
|
|
|
socket_path: S,
|
|
|
|
service_name: &'a str,
|
|
|
|
command_runner: SetuidCommandRunner<'a, U, R>,
|
|
|
|
command_runner: SetuidCommandRunner<U>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<S: AsRef<Path>, U: AsRef<str>, R: CommandRunner> UserService<'static, S, U, R> {
|
|
|
|
pub fn new(
|
|
|
|
socket_path: S,
|
|
|
|
user_name: U,
|
|
|
|
service_name: &'static str,
|
|
|
|
command_runner: &'static R,
|
|
|
|
) -> Self {
|
|
|
|
impl<S: AsRef<Path>, U: AsRef<str>> UserService<'static, S, U> {
|
|
|
|
pub fn new(socket_path: S, user_name: U, service_name: &'static str) -> Self {
|
|
|
|
Self {
|
|
|
|
socket_path,
|
|
|
|
service_name,
|
|
|
|
command_runner: SetuidCommandRunner::new(user_name, command_runner),
|
|
|
|
command_runner: SetuidCommandRunner::new(user_name),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<S: AsRef<Path>, U: AsRef<str>, R: CommandRunner> UserService<'_, S, U, R> {
|
|
|
|
impl<S: AsRef<Path>, U: AsRef<str>> UserService<'_, S, U> {
|
|
|
|
async fn systemctl_wait_for_dbus(&self, args: &[&OsStr]) -> Result<String, Box<dyn Error>> {
|
|
|
|
let mut tries = 5;
|
|
|
|
loop {
|
|
|
@ -85,7 +80,7 @@ impl<S: AsRef<Path>, U: AsRef<str>, R: CommandRunner> UserService<'_, S, U, R> { |
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
|
impl<S: AsRef<Path>, U: AsRef<str>, R: CommandRunner> Symbol for UserService<'_, S, U, R> {
|
|
|
|
impl<S: AsRef<Path>, U: AsRef<str>> Symbol for UserService<'_, S, U> {
|
|
|
|
async fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
|
|
|
|
self.check_if_service().await
|
|
|
|
}
|
|
|
|