summaryrefslogtreecommitdiffstats
path: root/bus/bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'bus/bus.c')
-rw-r--r--bus/bus.c65
1 files changed, 52 insertions, 13 deletions
diff --git a/bus/bus.c b/bus/bus.c
index 1b461fe3..4087334e 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -28,6 +28,7 @@
#include "utils.h"
#include "policy.h"
#include "config-parser.h"
+#include "signals.h"
#include <dbus/dbus-list.h>
#include <dbus/dbus-hash.h>
#include <dbus/dbus-internals.h>
@@ -44,6 +45,7 @@ struct BusContext
BusActivation *activation;
BusRegistry *registry;
BusPolicy *policy;
+ BusMatchmaker *matchmaker;
DBusUserDatabase *user_database;
BusLimits limits;
};
@@ -505,6 +507,13 @@ bus_context_new (const DBusString *config_file,
goto failed;
}
+ context->matchmaker = bus_matchmaker_new ();
+ if (context->matchmaker == NULL)
+ {
+ BUS_SET_OOM (error);
+ goto failed;
+ }
+
context->policy = bus_config_parser_steal_policy (parser);
_dbus_assert (context->policy != NULL);
@@ -715,6 +724,12 @@ bus_context_unref (BusContext *context)
_dbus_loop_unref (context->loop);
context->loop = NULL;
}
+
+ if (context->matchmaker)
+ {
+ bus_matchmaker_unref (context->matchmaker);
+ context->matchmaker = NULL;
+ }
dbus_free (context->type);
dbus_free (context->address);
@@ -771,6 +786,12 @@ bus_context_get_activation (BusContext *context)
return context->activation;
}
+BusMatchmaker*
+bus_context_get_matchmaker (BusContext *context)
+{
+ return context->matchmaker;
+}
+
DBusLoop*
bus_context_get_loop (BusContext *context)
{
@@ -845,18 +866,33 @@ bus_context_get_max_services_per_connection (BusContext *context)
return context->limits.max_services_per_connection;
}
+int
+bus_context_get_max_match_rules_per_connection (BusContext *context)
+{
+ return context->limits.max_match_rules_per_connection;
+}
+
dbus_bool_t
bus_context_check_security_policy (BusContext *context,
DBusConnection *sender,
- DBusConnection *recipient,
+ DBusConnection *addressed_recipient,
+ DBusConnection *proposed_recipient,
DBusMessage *message,
DBusError *error)
{
BusClientPolicy *sender_policy;
BusClientPolicy *recipient_policy;
- /* NULL sender/receiver means the bus driver */
+ /* NULL sender, proposed_recipient means the bus driver. NULL
+ * addressed_recipient means the message didn't specify an explicit
+ * target. If proposed_recipient is NULL, then addressed_recipient
+ * is also NULL but is implicitly the bus driver.
+ */
+ _dbus_assert (proposed_recipient == NULL ||
+ (dbus_message_get_destination (message) == NULL ||
+ addressed_recipient != NULL));
+
if (sender != NULL)
{
if (bus_connection_is_active (sender))
@@ -869,7 +905,7 @@ bus_context_check_security_policy (BusContext *context,
/* Policy for inactive connections is that they can only send
* the hello message to the bus driver
*/
- if (recipient == NULL &&
+ if (proposed_recipient == NULL &&
dbus_message_is_method_call (message,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
"Hello"))
@@ -897,15 +933,15 @@ bus_context_check_security_policy (BusContext *context,
_dbus_assert ((sender != NULL && sender_policy != NULL) ||
(sender == NULL && sender_policy == NULL));
- if (recipient != NULL)
+ if (proposed_recipient != NULL)
{
/* only the bus driver can send to an inactive recipient (as it
* owns no services, so other apps can't address it). Inactive
* recipients can receive any message.
*/
- if (bus_connection_is_active (recipient))
+ if (bus_connection_is_active (proposed_recipient))
{
- recipient_policy = bus_connection_get_policy (recipient);
+ recipient_policy = bus_connection_get_policy (proposed_recipient);
_dbus_assert (recipient_policy != NULL);
}
else if (sender == NULL)
@@ -922,13 +958,13 @@ bus_context_check_security_policy (BusContext *context,
else
recipient_policy = NULL;
- _dbus_assert ((recipient != NULL && recipient_policy != NULL) ||
- (recipient != NULL && sender == NULL && recipient_policy == NULL) ||
- (recipient == NULL && recipient_policy == NULL));
+ _dbus_assert ((proposed_recipient != NULL && recipient_policy != NULL) ||
+ (proposed_recipient != NULL && sender == NULL && recipient_policy == NULL) ||
+ (proposed_recipient == NULL && recipient_policy == NULL));
if (sender_policy &&
!bus_client_policy_check_can_send (sender_policy,
- context->registry, recipient,
+ context->registry, proposed_recipient,
message))
{
const char *dest = dbus_message_get_destination (message);
@@ -951,6 +987,7 @@ bus_context_check_security_policy (BusContext *context,
if (recipient_policy &&
!bus_client_policy_check_can_receive (recipient_policy,
context->registry, sender,
+ addressed_recipient, proposed_recipient,
message))
{
const char *dest = dbus_message_get_destination (message);
@@ -971,14 +1008,16 @@ bus_context_check_security_policy (BusContext *context,
}
/* See if limits on size have been exceeded */
- if (recipient &&
- dbus_connection_get_outgoing_size (recipient) >
+ if (proposed_recipient &&
+ dbus_connection_get_outgoing_size (proposed_recipient) >
context->limits.max_outgoing_bytes)
{
const char *dest = dbus_message_get_destination (message);
dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
"The destination service \"%s\" has a full message queue",
- dest ? dest : DBUS_SERVICE_ORG_FREEDESKTOP_DBUS);
+ dest ? dest : (proposed_recipient ?
+ bus_connection_get_name (proposed_recipient) :
+ DBUS_SERVICE_ORG_FREEDESKTOP_DBUS));
_dbus_verbose ("security policy disallowing message due to full message queue\n");
return FALSE;
}