Commit 1acedfdd authored by Simon McVittie's avatar Simon McVittie

Capture a fake reply if a broadcast cannot be delivered

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787Reviewed-by: Philip Withnall's avatarPhilip Withnall <philip.withnall@collabora.co.uk>
parent 9fce7380
...@@ -2180,7 +2180,7 @@ out: ...@@ -2180,7 +2180,7 @@ out:
return ret; return ret;
} }
static dbus_bool_t dbus_bool_t
bus_transaction_capture_error_reply (BusTransaction *transaction, bus_transaction_capture_error_reply (BusTransaction *transaction,
const DBusError *error, const DBusError *error,
DBusMessage *in_reply_to) DBusMessage *in_reply_to)
......
...@@ -134,6 +134,9 @@ dbus_bool_t bus_transaction_send (BusTransaction * ...@@ -134,6 +134,9 @@ dbus_bool_t bus_transaction_send (BusTransaction *
dbus_bool_t bus_transaction_capture (BusTransaction *transaction, dbus_bool_t bus_transaction_capture (BusTransaction *transaction,
DBusConnection *connection, DBusConnection *connection,
DBusMessage *message); DBusMessage *message);
dbus_bool_t bus_transaction_capture_error_reply (BusTransaction *transaction,
const DBusError *error,
DBusMessage *in_reply_to);
dbus_bool_t bus_transaction_send_from_driver (BusTransaction *transaction, dbus_bool_t bus_transaction_send_from_driver (BusTransaction *transaction,
DBusConnection *connection, DBusConnection *connection,
DBusMessage *message); DBusMessage *message);
......
...@@ -63,17 +63,47 @@ send_one_message (DBusConnection *connection, ...@@ -63,17 +63,47 @@ send_one_message (DBusConnection *connection,
BusTransaction *transaction, BusTransaction *transaction,
DBusError *error) DBusError *error)
{ {
DBusError stack_error = DBUS_ERROR_INIT;
if (!bus_context_check_security_policy (context, transaction, if (!bus_context_check_security_policy (context, transaction,
sender, sender,
addressed_recipient, addressed_recipient,
connection, connection,
message, message,
NULL)) &stack_error))
return TRUE; /* silently don't send it */ {
if (!bus_transaction_capture_error_reply (transaction, &stack_error,
message))
{
bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
"broadcast rejected, but not enough "
"memory to tell monitors");
}
dbus_error_free (&stack_error);
return TRUE; /* don't send it but don't return an error either */
}
if (dbus_message_contains_unix_fds(message) && if (dbus_message_contains_unix_fds(message) &&
!dbus_connection_can_send_type(connection, DBUS_TYPE_UNIX_FD)) !dbus_connection_can_send_type(connection, DBUS_TYPE_UNIX_FD))
return TRUE; /* silently don't send it */ {
dbus_set_error (&stack_error, DBUS_ERROR_NOT_SUPPORTED,
"broadcast cannot be delivered to %s (%s) because "
"it does not support receiving Unix fds",
bus_connection_get_name (connection),
bus_connection_get_loginfo (connection));
if (!bus_transaction_capture_error_reply (transaction, &stack_error,
message))
{
bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
"broadcast with Unix fd not delivered, but not "
"enough memory to tell monitors");
}
dbus_error_free (&stack_error);
return TRUE; /* don't send it but don't return an error either */
}
if (!bus_transaction_send (transaction, if (!bus_transaction_send (transaction,
connection, connection,
......
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