Commit 89f70b19 authored by Lennart Poettering's avatar Lennart Poettering

bus: don't forward messages with unix fds on connections that don't support it

This simply verifies that we forward unix fds only on connection that
support it. We willr eturn an error if a client attempts to send a
message with unix fds to another client that cannot do it.
parent 724adb2f
......@@ -56,6 +56,10 @@ send_one_message (DBusConnection *connection,
return TRUE; /* silently don't send it */
if (dbus_message_contains_unix_fds(message) &&
!dbus_connection_can_send_type(connection, DBUS_TYPE_UNIX_FD))
return TRUE; /* silently don't send it */
if (!bus_transaction_send (transaction,
......@@ -300,6 +304,16 @@ bus_dispatch (DBusConnection *connection,
message, &error))
goto out;
if (dbus_message_contains_unix_fds(message) &&
!dbus_connection_can_send_type(addressed_recipient, DBUS_TYPE_UNIX_FD))
"Tried to send message with Unix file descriptors"
"to a client that doesn't support that.");
goto out;
/* Dispatch the message */
if (!bus_transaction_send (transaction, addressed_recipient, message))
......@@ -34,7 +34,7 @@ typedef struct DBusMessageLoader DBusMessageLoader;
void _dbus_message_get_network_data (DBusMessage *message,
const DBusString **header,
const DBusString **body);
void _dbus_message_get_unix_fds (DBusMessage *messgage,
void _dbus_message_get_unix_fds (DBusMessage *message,
const int **fds,
unsigned *n_fds);
......@@ -3560,6 +3560,20 @@ dbus_set_error_from_message (DBusError *error,
return TRUE;
* Checks whether a message contains unix fds
* @param message the message
* @returns #TRUE if the message contains unix fds
dbus_message_contains_unix_fds(DBusMessage *message)
return message->n_unix_fds > 0;
/** @} */
......@@ -159,6 +159,7 @@ dbus_bool_t dbus_message_get_args_valist (DBusMessage *message,
int first_arg_type,
va_list var_args);
dbus_bool_t dbus_message_contains_unix_fds (DBusMessage *message);
dbus_bool_t dbus_message_iter_init (DBusMessage *message,
DBusMessageIter *iter);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment