Skip to content

Commit

Permalink
🦺 Support the <pidfile>path</pidfile> element
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeyrhyme committed Oct 27, 2024
1 parent e16b932 commit 33e6de3
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::path::PathBuf;

use anyhow::{Error, Result};
use quick_xml::{events::Event, Reader};
use serde::Deserialize;
Expand Down Expand Up @@ -28,7 +30,9 @@ pub struct BusConfig {
#[query(".keep_umask")]
// TODO: consider finding a way to make this `bool` instead of `Option<()>`
pub keep_umask: Option<()>,
/// If true, the bus daemon will log to syslog.
/// The bus daemon will write its pid to the specified file.
#[query(".pidfile")]
pub pidfile: Option<PathBuf>,
#[query(".syslog")]
// TODO: consider finding a way to make this `bool` instead of `Option<()>`
pub syslog: Option<()>,
Expand Down Expand Up @@ -175,6 +179,26 @@ mod tests {
);
}

#[test]
fn bus_config_parse_with_pidfile_ok() {
let input = r#"<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<pidfile>/var/run/busd.pid</pidfile>
</busconfig>
"#;

let busconfig = BusConfig::parse(input).expect("should parse XML input");

assert_eq!(
busconfig,
BusConfig {
pidfile: Some(PathBuf::from("/var/run/busd.pid")),
..Default::default()
}
);
}

#[test]
fn bus_config_parse_with_type_ok() {
let input = r#"<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
Expand Down

0 comments on commit 33e6de3

Please sign in to comment.