}
static dbus_bool_t
-kernel_match_needed (MatchRule *rule)
-{
- int message_type;
-
- /* Allow only NameOwnerChanged member */
- if (strcmp_existing (_match_rule_get_member (rule), "NameOwnerChanged") != 0)
- return FALSE;
-
- /* Allow only signals */
- message_type = _match_rule_get_message_type (rule);
- if (message_type != DBUS_MESSAGE_TYPE_INVALID && message_type != DBUS_MESSAGE_TYPE_SIGNAL)
- return FALSE;
-
- /* Check if from DBus */
- if (strcmp_existing (_match_rule_get_sender (rule), DBUS_SERVICE_DBUS) != 0)
- return FALSE;
-
- if (strcmp_existing (_match_rule_get_interface (rule), DBUS_INTERFACE_DBUS) != 0)
- return FALSE;
-
- if (strcmp_existing (_match_rule_get_path (rule), DBUS_PATH_DBUS) != 0)
- return FALSE;
-
- return TRUE;
-}
-
-static dbus_bool_t
is_bloom_needed (MatchRule *rule)
{
int rule_int;
int ret;
rule_cookie = match_rule_get_cookie (rule);
+ rule_sender = _match_rule_get_sender (rule);
/*
* First check if it is org.freedesktop.DBus's NameOwnerChanged or any
* because it must be converted to special kdbus rule (kdbus has separate rules
* for kdbus (kernel) generated broadcasts).
*/
- if (kernel_match_needed (rule))
+ if (!strcmp_existing (rule_sender, DBUS_SERVICE_DBUS))
{
- ret = _kdbus_add_match_name_change (transport->kdbus,
- 0,
- rule_cookie,
- KDBUS_MATCH_ID_ANY,
- 0,
- KDBUS_MATCH_ID_ANY,
- 0);
- if (0 != ret)
- {
- _dbus_verbose ("Failed adding match rule for name removal for daemon, error: %d, %s\n",
- ret, _dbus_strerror (ret));
- return FALSE;
- }
+ int message_type = _match_rule_get_message_type (rule);
- ret = _kdbus_add_match_id_change (transport->kdbus,
- 0,
- rule_cookie,
- KDBUS_MATCH_ID_ANY,
- 0);
- if (0 != ret)
+ if ((DBUS_MESSAGE_TYPE_INVALID == message_type || DBUS_MESSAGE_TYPE_SIGNAL == message_type)
+ && !strcmp_existing (_match_rule_get_member (rule), "NameOwnerChanged")
+ && !strcmp_existing (_match_rule_get_interface (rule), DBUS_INTERFACE_DBUS)
+ && !strcmp_existing (_match_rule_get_path (rule), DBUS_PATH_DBUS))
{
- _dbus_verbose ("Failed adding match rule for adding id for daemon, error: %d, %s\n",
- ret, _dbus_strerror (ret));
- return FALSE;
- }
+ ret = _kdbus_add_match_name_change (transport->kdbus,
+ 0,
+ rule_cookie,
+ KDBUS_MATCH_ID_ANY,
+ 0,
+ KDBUS_MATCH_ID_ANY,
+ 0);
+ if (0 != ret)
+ {
+ _dbus_verbose ("Failed adding match rule for name removal for daemon, error: %d, %s\n",
+ ret, _dbus_strerror (ret));
+ return FALSE;
+ }
- _dbus_verbose ("Added match rule for kernel correctly.\n");
+ ret = _kdbus_add_match_id_change (transport->kdbus,
+ 0,
+ rule_cookie,
+ KDBUS_MATCH_ID_ANY,
+ 0);
+ if (0 != ret)
+ {
+ _dbus_verbose ("Failed adding match rule for adding id for daemon, error: %d, %s\n",
+ ret, _dbus_strerror (ret));
+ return FALSE;
+ }
-/*
- * In case all of sender, interface and path are NULL, the rule
- * says simply about NameHasOwner signal from any object, any interface, any sender.
- * So, we need to consider that.
- * Otherwise, our job is finished here.
- */
- if (_match_rule_get_sender (rule) != NULL
- || _match_rule_get_interface (rule) != NULL
- || _match_rule_get_path (rule) != NULL)
+ _dbus_verbose ("Added match rule for kernel correctly.\n");
+ }
+
+ /* Sender=DBUS_SERVICE_DBUS matches (as opposed to wildcard sender) need no standard rule. */
+ if (rule_sender)
return TRUE;
}
need_bloom = is_bloom_needed (rule);
- rule_sender = _match_rule_get_sender (rule);
if (rule_sender != NULL)
{
DBusString str;