From 64df5df446c66ed1be3b4dcf974d552b489ec596 Mon Sep 17 00:00:00 2001 From: harryoooooooooo Date: Tue, 5 Dec 2023 12:09:46 +0800 Subject: [PATCH] Add unix fd support for in-args Enable the methods to receive unix fd list with a keyword-only parameter `dbus_unix_fd_list`. The methods shall extract the fd handle from the parameters, and get fd through `dbus_unix_fd_list.get(handle)`. See sample usage on https://crrev.com/c/5053020 --- pydbus/registration.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pydbus/registration.py b/pydbus/registration.py index f531539..157d076 100644 --- a/pydbus/registration.py +++ b/pydbus/registration.py @@ -78,6 +78,10 @@ def call_method(self, connection, sender, object_path, interface_name, method_na if "dbus_context" in sig.parameters and sig.parameters["dbus_context"].kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.KEYWORD_ONLY): kwargs["dbus_context"] = MethodCallContext(invocation) + if connection.get_capabilities() & Gio.DBusCapabilityFlags.UNIX_FD_PASSING: + if "dbus_unix_fd_list" in sig.parameters and sig.parameters["dbus_unix_fd_list"].kind == Parameter.KEYWORD_ONLY: + kwargs["dbus_unix_fd_list"] = invocation.get_message().get_unix_fd_list() + result = method(*parameters, **kwargs) if len(outargs) == 0: