Skip to content

Commit

Permalink
🦺 Support the <allow_anonymous> element
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeyrhyme committed Oct 27, 2024
1 parent 33e6de3 commit 45b4e04
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ const EXPECTED_DOCTYPE_PARTS: &[&str] = &[
/// implements [`dbus-daemon`'s Configuration File](https://dbus.freedesktop.org/doc/dbus-daemon.1.html#configuration_file)
#[derive(Clone, Debug, Default, Deserialize, DeserializeQuery, PartialEq)]
pub struct BusConfig {
/// If true, the bus daemon becomes a real daemon (forks into the background, etc.).
/// If `Some`, connections that authenticated using the ANONYMOUS mechanism will be authorized to connect.
/// This option has no practical effect unless the ANONYMOUS mechanism has also been enabled using the `auth` option.
#[query(".allow_anonymous")]
// TODO: consider finding a way to make this `bool` instead of `Option<()>`
pub allow_anonymous: Option<()>,
/// If `Some`, the bus daemon becomes a real daemon (forks into the background, etc.).
#[query(".fork")]
// TODO: consider finding a way to make this `bool` instead of `Option<()>`
pub fork: Option<()>,
/// If true, the bus daemon keeps its original umask when forking.
/// If `Some`, the bus daemon keeps its original umask when forking.
/// This may be useful to avoid affecting the behavior of child processes.
#[query(".keep_umask")]
// TODO: consider finding a way to make this `bool` instead of `Option<()>`
pub keep_umask: Option<()>,
/// The bus daemon will write its pid to the specified file.
#[query(".pidfile")]
pub pidfile: Option<PathBuf>,
/// If `Some`, the bus daemon will log to syslog.
#[query(".syslog")]
// TODO: consider finding a way to make this `bool` instead of `Option<()>`
pub syslog: Option<()>,
Expand Down Expand Up @@ -156,10 +162,11 @@ mod tests {
}

#[test]
fn bus_config_parse_with_fork_and_keep_umask_and_syslog_ok() {
fn bus_config_parse_with_allow_anonymous_and_fork_and_keep_umask_and_syslog_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>
<allow_anonymous />
<fork />
<keep_umask/>
<syslog />
Expand All @@ -171,6 +178,7 @@ mod tests {
assert_eq!(
busconfig,
BusConfig {
allow_anonymous: Some(()),
fork: Some(()),
keep_umask: Some(()),
syslog: Some(()),
Expand Down

0 comments on commit 45b4e04

Please sign in to comment.