From a0cc21f8bb6752ffe0ee5f4f5b575dc50d6d46ae Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2009 03:41:05 +0200 Subject: unix-fd: add message encoding/decoding for unix fds When appending unix fds to the message a new entry in the fd array will be allocated and the index to it will be written to the message payload. When parsing unix fds from the message the index will be read from the payload and then looked up in the fd array. When we read fds we put them in a queue first. Since each message knows how many fds are attached to it we will then pop enough fds from this queue each time we decode a message from the stream. This should make sending and receiving more portable since we don't make any strong requirements on the exact semantics of the SCM_RIGHTS implementation: as long as fds are recieved in order, none or lost and the arrive at the same time as at least one byte from the actual message dat we should be able to handle them correctly. --- dbus/dbus-transport-protected.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'dbus/dbus-transport-protected.h') diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h index 4d56a72f..023549d0 100644 --- a/dbus/dbus-transport-protected.h +++ b/dbus/dbus-transport-protected.h @@ -23,6 +23,8 @@ #ifndef DBUS_TRANSPORT_PROTECTED_H #define DBUS_TRANSPORT_PROTECTED_H +#include + #include #include #include @@ -71,6 +73,10 @@ struct DBusTransportVTable /**< Get socket file descriptor */ }; +/** How many unix file descriptors may be queued up before they are + handed off to messages */ +#define DBUS_MAX_QUEUED_FDS 1024 + /** * Object representing a transport such as a socket. * A transport can shuttle messages from point A to point B, -- cgit From c200e0304d6f53a0fd47f524386b02b27c0c45f6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 24 Apr 2009 04:38:27 +0200 Subject: auth: add fd passing negotiation support This adds two new directives to the auth protocol: NEGOTIATE_UNIX_FD is sent by the client after the authentication was sucessful, i.e. OK was received. AGREE_UNIX_FD is then sent by the server if it can do unix fd passing as well. ERROR is returned when the server cannot or is unwilling to do unix fd passing. This should be compatible with existing D-Bus implementations which will naturally return ERROR on NEGOTIATE_UNIX_FD. --- dbus/dbus-transport-protected.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'dbus/dbus-transport-protected.h') diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h index 023549d0..8c389a6d 100644 --- a/dbus/dbus-transport-protected.h +++ b/dbus/dbus-transport-protected.h @@ -144,6 +144,9 @@ DBusTransportOpenResult _dbus_transport_open_platform_specific (DBusAddressEntry DBusTransport **transport_p, DBusError *error); +#define DBUS_TRANSPORT_CAN_SEND_UNIX_FD(x) \ + _dbus_auth_get_unix_fd_negotiated((x)->auth) + DBUS_END_DECLS #endif /* DBUS_TRANSPORT_PROTECTED_H */ -- cgit From bfad32422f1f78bce4de1e88a4afb5cc295bb877 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 20 May 2009 01:32:46 +0200 Subject: unix-fd: add logic to count unix fds the same way as allocated memory This make all counters count both bytes of memory and unix fds. --- dbus/dbus-transport-protected.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'dbus/dbus-transport-protected.h') diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h index 8c389a6d..50ec6ce0 100644 --- a/dbus/dbus-transport-protected.h +++ b/dbus/dbus-transport-protected.h @@ -73,10 +73,6 @@ struct DBusTransportVTable /**< Get socket file descriptor */ }; -/** How many unix file descriptors may be queued up before they are - handed off to messages */ -#define DBUS_MAX_QUEUED_FDS 1024 - /** * Object representing a transport such as a socket. * A transport can shuttle messages from point A to point B, @@ -98,9 +94,9 @@ struct DBusTransport DBusCredentials *credentials; /**< Credentials of other end read from the socket */ long max_live_messages_size; /**< Max total size of received messages. */ + long max_live_messages_unix_fds; /**< Max total unix fds of received messages. */ - DBusCounter *live_messages_size; /**< Counter for size of all live messages. */ - + DBusCounter *live_messages; /**< Counter for size/unix fds of all live messages. */ char *address; /**< Address of the server we are connecting to (#NULL for the server side of a transport) */ -- cgit