summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-transport.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-04-22 03:41:05 +0200
committerLennart Poettering <lennart@poettering.net>2009-05-20 02:09:03 +0200
commita0cc21f8bb6752ffe0ee5f4f5b575dc50d6d46ae (patch)
tree950cbd47691d09ecef51dab996e93163d938a2f1 /dbus/dbus-transport.c
parentba7daa606cf20ff3b5e992907f380a425feaef01 (diff)
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.
Diffstat (limited to 'dbus/dbus-transport.c')
-rw-r--r--dbus/dbus-transport.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index 35b7027d..97ee0e9b 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -29,6 +29,8 @@
#include "dbus-auth.h"
#include "dbus-address.h"
#include "dbus-credentials.h"
+#include "dbus-message-private.h"
+#include "dbus-marshal-header.h"
#ifdef DBUS_BUILD_TESTS
#include "dbus-server-debug-pipe.h"
#endif
@@ -180,7 +182,13 @@ _dbus_transport_init_base (DBusTransport *transport,
/* credentials read from socket if any */
transport->credentials = creds;
-
+
+#ifdef HAVE_UNIX_FD_PASSING
+ transport->can_pass_unix_fd = FALSE;
+ transport->unix_fds = NULL;
+ transport->n_unix_fds = 0;
+#endif
+
_dbus_counter_set_notify (transport->live_messages_size,
transport->max_live_messages_size,
live_messages_size_notify,
@@ -188,7 +196,7 @@ _dbus_transport_init_base (DBusTransport *transport,
if (transport->address)
_dbus_verbose ("Initialized transport on address %s\n", transport->address);
-
+
return TRUE;
}
@@ -803,6 +811,18 @@ _dbus_transport_get_is_anonymous (DBusTransport *transport)
}
/**
+ * Returns TRUE if the transport supports sending unix fds.
+ *
+ * @param transport the transport
+ * @returns #TRUE if TRUE it is possible to send unix fds across the transport.
+ */
+dbus_bool_t
+_dbus_transport_can_pass_unix_fd(DBusTransport *transport)
+{
+ return DBUS_TRANSPORT_CAN_SEND_UNIX_FD(transport);
+}
+
+/**
* Gets the address of a transport. It will be
* #NULL for a server-side transport.
*