forked from dbus2/busd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Extract XML-specific data structures
- Loading branch information
1 parent
01a703d
commit 7bb570e
Showing
2 changed files
with
151 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
use std::path::PathBuf; | ||
|
||
use serde::Deserialize; | ||
|
||
use super::{BusType, MessageType}; | ||
|
||
/// The bus configuration. | ||
/// | ||
/// This is currently only loaded from the [XML configuration files] defined by the specification. | ||
/// We plan to add support for other formats (e.g JSON) in the future. | ||
/// | ||
/// [XML configuration files]: https://dbus.freedesktop.org/doc/dbus-daemon.1.html#configuration_file | ||
#[derive(Clone, Debug, Default, Deserialize, PartialEq)] | ||
pub struct Document { | ||
#[serde(rename = "$value", default)] | ||
pub busconfig: Vec<Element>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum Element { | ||
AllowAnonymous, | ||
Auth(String), | ||
Fork, | ||
KeepUmask, | ||
// TODO: support `<include ignore_missing=(yes|no) if_selinux_enabled=(yes|no) | ||
// selinux_root_relative=(yes|no)>` TODO: support `<includedir>` | ||
Listen(String), | ||
Limit, | ||
Pidfile(PathBuf), | ||
Policy(PolicyElement), | ||
Servicedir(PathBuf), | ||
Servicehelper(PathBuf), | ||
/// Requests a standard set of session service directories. | ||
/// Its effect is similar to specifying a series of <servicedir/> elements for each of the data | ||
/// directories, in the order given here. | ||
StandardSessionServicedirs, | ||
/// Specifies the standard system-wide activation directories that should be searched for | ||
/// service files. | ||
StandardSystemServicedirs, | ||
Syslog, | ||
Type(TypeElement), | ||
User(String), | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum PolicyContext { | ||
Default, | ||
Mandatory, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, PartialEq)] | ||
pub struct PolicyElement { | ||
#[serde(rename = "@at_console")] | ||
pub at_console: Option<String>, | ||
#[serde(rename = "@context")] | ||
pub context: Option<PolicyContext>, | ||
#[serde(rename = "@group")] | ||
pub group: Option<String>, | ||
#[serde(rename = "$value", default)] | ||
pub rules: Vec<RuleElement>, | ||
#[serde(rename = "@user")] | ||
pub user: Option<String>, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, PartialEq)] | ||
pub struct RuleAttributes { | ||
#[serde(rename = "@max_fds")] | ||
pub max_fds: Option<u32>, | ||
#[serde(rename = "@min_fds")] | ||
pub min_fds: Option<u32>, | ||
|
||
#[serde(rename = "@receive_error")] | ||
pub receive_error: Option<String>, | ||
#[serde(rename = "@receive_interface")] | ||
pub receive_interface: Option<String>, | ||
/// deprecated and ignored | ||
#[serde(rename = "@receive_member")] | ||
pub receive_member: Option<String>, | ||
#[serde(rename = "@receive_path")] | ||
pub receive_path: Option<String>, | ||
#[serde(rename = "@receive_sender")] | ||
pub receive_sender: Option<String>, | ||
#[serde(rename = "@receive_type")] | ||
pub receive_type: Option<MessageType>, | ||
|
||
#[serde(rename = "@send_broadcast")] | ||
pub send_broadcast: Option<bool>, | ||
#[serde(rename = "@send_destination")] | ||
pub send_destination: Option<String>, | ||
#[serde(rename = "@send_destination_prefix")] | ||
pub send_destination_prefix: Option<String>, | ||
#[serde(rename = "@send_error")] | ||
pub send_error: Option<String>, | ||
#[serde(rename = "@send_interface")] | ||
pub send_interface: Option<String>, | ||
/// deprecated and ignored: https://github.com/dbus2/busd/issues/79 | ||
#[serde(rename = "@send_member")] | ||
pub send_member: Option<String>, | ||
#[serde(rename = "@send_path")] | ||
pub send_path: Option<String>, | ||
#[serde(rename = "@send_type")] | ||
pub send_type: Option<MessageType>, | ||
|
||
/// deprecated and ignored | ||
#[serde(rename = "@receive_requested_reply")] | ||
pub receive_requested_reply: Option<bool>, | ||
/// deprecated and ignored | ||
#[serde(rename = "@send_requested_reply")] | ||
pub send_requested_reply: Option<bool>, | ||
|
||
/// deprecated and ignored | ||
#[serde(rename = "@eavesdrop")] | ||
pub eavesdrop: Option<bool>, | ||
|
||
#[serde(rename = "@own")] | ||
pub own: Option<String>, | ||
#[serde(rename = "@own_prefix")] | ||
pub own_prefix: Option<String>, | ||
|
||
#[serde(rename = "@group")] | ||
pub group: Option<String>, | ||
#[serde(rename = "@user")] | ||
pub user: Option<String>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum RuleElement { | ||
Allow(RuleAttributes), | ||
Deny(RuleAttributes), | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq)] | ||
pub struct TypeElement { | ||
#[serde(rename = "$text")] | ||
pub r#type: BusType, | ||
} |