From a6b47a124db50d0b43d49a863b1efd0bc8f34177 Mon Sep 17 00:00:00 2001 From: Ron Waldon-Howe Date: Mon, 18 Nov 2024 17:57:40 +1100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Support=20`<(allow|deny)=20(send?= =?UTF-8?q?|recieve)=5Fmember=3D`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/dbus2/busd/issues/79#issuecomment-2482782721 --- src/config.rs | 38 ++++++++++++-------------------------- tests/config.rs | 22 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/config.rs b/src/config.rs index 3cc5d81..ecdaa77 100644 --- a/src/config.rs +++ b/src/config.rs @@ -274,14 +274,6 @@ impl TryFrom for OptionalOperation { return Err(Error::msg(format!("`send_destination_prefix` cannot be combined with `send_destination` in the same rule: {value:?}"))); } - // https://github.com/dbus2/busd/issues/79 - if value.receive_member.is_some() { - warn!("warning: busd does not implement `<(allow|deny) receive_member=...`: {value:?}"); - } - if value.send_member.is_some() { - warn!("warning: busd does not implement `<(allow|deny) send_member=...`: {value:?}"); - } - if has_connect { Ok(Some(Operation::Connect(ConnectOperation::from(value)))) } else if has_own { @@ -395,6 +387,7 @@ pub struct ReceiveOperation { pub error: Option, pub interface: Option, pub max_fds: Option, + pub member: Option, pub min_fds: Option, pub path: Option, pub sender: Option, @@ -406,6 +399,7 @@ impl From for ReceiveOperation { error: value.receive_error, interface: value.receive_interface, max_fds: value.max_fds, + member: value.receive_member, min_fds: value.min_fds, path: value.receive_path, sender: value.receive_sender, @@ -524,6 +518,7 @@ pub struct SendOperation { pub error: Option, pub interface: Option, pub max_fds: Option, + pub member: Option, pub min_fds: Option, pub path: Option, pub r#type: Option, @@ -554,6 +549,7 @@ impl From for SendOperation { error: value.send_error, interface: value.send_interface, max_fds: value.max_fds, + member: value.send_member, min_fds: value.min_fds, path: value.send_path, r#type: value.send_type, @@ -804,6 +800,7 @@ mod tests { send_destination="org.freedesktop.DBus" send_error="something bad" send_interface="org.freedesktop.systemd1.Activator" + send_member="DoSomething" send_path="/org/freedesktop" send_type="signal" max_fds="128" @@ -812,6 +809,7 @@ mod tests { - @@ -1005,6 +1005,7 @@ mod tests { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, r#type: None @@ -1016,21 +1017,6 @@ mod tests { // `` is completely ignored ], diff --git a/tests/config.rs b/tests/config.rs index 7b6f760..f228144 100644 --- a/tests/config.rs +++ b/tests/config.rs @@ -72,6 +72,7 @@ fn config_read_file_example_session_disable_stats_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Debug.Stats")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None @@ -99,6 +100,7 @@ fn config_read_file_example_system_enable_stats_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Debug.Stats")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None @@ -135,6 +137,7 @@ fn config_read_file_session_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -183,6 +186,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, r#type: Some(MessageType::MethodCall), @@ -196,6 +200,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, r#type: Some(MessageType::Signal), @@ -209,6 +214,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, r#type: Some(MessageType::MethodReturn), @@ -222,6 +228,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, r#type: Some(MessageType::Error), @@ -233,6 +240,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, sender: None, @@ -245,6 +253,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, sender: None, @@ -257,6 +266,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, sender: None, @@ -269,6 +279,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: None, max_fds: None, + member: None, min_fds: None, path: None, sender: None, @@ -283,6 +294,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -296,6 +308,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Introspectable")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -309,6 +322,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Properties")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -322,13 +336,13 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Containers1")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, }), ), ( - // TODO: this is a mistake, deny with send_member rule should be omitted Access::Deny, Operation::Send(SendOperation { broadcast: None, @@ -336,6 +350,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus")), max_fds: None, + member: Some(String::from("UpdateActivationEnvironment")), min_fds: None, path: None, r#type: None, @@ -349,6 +364,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Debug.Stats")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -362,6 +378,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.systemd1.Activator")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -377,6 +394,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.systemd1.Activator")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -393,6 +411,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Monitoring")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None, @@ -409,6 +428,7 @@ fn config_read_file_system_conf_ok() { error: None, interface: Some(String::from("org.freedesktop.DBus.Debug.Stats")), max_fds: None, + member: None, min_fds: None, path: None, r#type: None,