1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 #include "alloc-util.h"
6 #include "bus-internal.h"
8 #include "bus-message.h"
12 #include "hexdecoct.h"
13 #include "string-util.h"
18 * A: type=signal,sender=foo,interface=bar
19 * B: type=signal,sender=quux,interface=fips
20 * C: type=signal,sender=quux,interface=waldo
21 * D: type=signal,member=test
26 * results in this tree:
29 * + BUS_MATCH_MESSAGE_TYPE
30 * | ` BUS_MATCH_VALUE: value == signal
31 * | + DBUS_MATCH_SENDER
32 * | | + BUS_MATCH_VALUE: value == foo
33 * | | | ` DBUS_MATCH_INTERFACE
34 * | | | ` BUS_MATCH_VALUE: value == bar
35 * | | | ` BUS_MATCH_LEAF: A
36 * | | ` BUS_MATCH_VALUE: value == quux
37 * | | ` DBUS_MATCH_INTERFACE
38 * | | | BUS_MATCH_VALUE: value == fips
39 * | | | ` BUS_MATCH_LEAF: B
40 * | | ` BUS_MATCH_VALUE: value == waldo
41 * | | ` BUS_MATCH_LEAF: C
42 * | + DBUS_MATCH_MEMBER
43 * | | ` BUS_MATCH_VALUE: value == test
44 * | | ` BUS_MATCH_LEAF: D
45 * | + BUS_MATCH_LEAF: F
46 * | ` BUS_MATCH_LEAF: G
48 * ` BUS_MATCH_VALUE: value == miau
52 static bool BUS_MATCH_IS_COMPARE(enum bus_match_node_type t
) {
53 return t
>= BUS_MATCH_SENDER
&& t
<= BUS_MATCH_ARG_HAS_LAST
;
56 static bool BUS_MATCH_CAN_HASH(enum bus_match_node_type t
) {
57 return (t
>= BUS_MATCH_MESSAGE_TYPE
&& t
<= BUS_MATCH_PATH
) ||
58 (t
>= BUS_MATCH_ARG
&& t
<= BUS_MATCH_ARG_LAST
) ||
59 (t
>= BUS_MATCH_ARG_HAS
&& t
<= BUS_MATCH_ARG_HAS_LAST
);
62 static void bus_match_node_free(struct bus_match_node
*node
) {
66 assert(node
->type
!= BUS_MATCH_ROOT
);
67 assert(node
->type
< _BUS_MATCH_NODE_TYPE_MAX
);
69 if (node
->parent
->child
) {
70 /* We are apparently linked into the parent's child
71 * list. Let's remove us from there. */
73 assert(node
->prev
->next
== node
);
74 node
->prev
->next
= node
->next
;
76 assert(node
->parent
->child
== node
);
77 node
->parent
->child
= node
->next
;
81 node
->next
->prev
= node
->prev
;
84 if (node
->type
== BUS_MATCH_VALUE
) {
85 /* We might be in the parent's hash table, so clean
88 if (node
->parent
->type
== BUS_MATCH_MESSAGE_TYPE
)
89 hashmap_remove(node
->parent
->compare
.children
, UINT_TO_PTR(node
->value
.u8
));
90 else if (BUS_MATCH_CAN_HASH(node
->parent
->type
) && node
->value
.str
)
91 hashmap_remove(node
->parent
->compare
.children
, node
->value
.str
);
93 free(node
->value
.str
);
96 if (BUS_MATCH_IS_COMPARE(node
->type
)) {
97 assert(hashmap_isempty(node
->compare
.children
));
98 hashmap_free(node
->compare
.children
);
104 static bool bus_match_node_maybe_free(struct bus_match_node
*node
) {
107 if (node
->type
== BUS_MATCH_ROOT
)
113 if (BUS_MATCH_IS_COMPARE(node
->type
) && !hashmap_isempty(node
->compare
.children
))
116 bus_match_node_free(node
);
120 static bool value_node_test(
121 struct bus_match_node
*node
,
122 enum bus_match_node_type parent_type
,
124 const char *value_str
,
129 assert(node
->type
== BUS_MATCH_VALUE
);
131 /* Tests parameters against this value node, doing prefix
132 * magic and stuff. */
134 switch (parent_type
) {
136 case BUS_MATCH_MESSAGE_TYPE
:
137 return node
->value
.u8
== value_u8
;
139 case BUS_MATCH_SENDER
:
140 if (streq_ptr(node
->value
.str
, value_str
))
143 if (m
->creds
.mask
& SD_BUS_CREDS_WELL_KNOWN_NAMES
) {
146 /* on kdbus we have the well known names list
147 * in the credentials, let's make use of that
148 * for an accurate match */
150 STRV_FOREACH(i
, m
->creds
.well_known_names
)
151 if (streq_ptr(node
->value
.str
, *i
))
156 /* If we don't have kdbus, we don't know the
157 * well-known names of the senders. In that,
158 * let's just hope that dbus-daemon doesn't
159 * send us stuff we didn't want. */
161 if (node
->value
.str
[0] != ':' && value_str
&& value_str
[0] == ':')
167 case BUS_MATCH_DESTINATION
:
168 case BUS_MATCH_INTERFACE
:
169 case BUS_MATCH_MEMBER
:
171 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
174 return streq_ptr(node
->value
.str
, value_str
);
178 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
: {
181 STRV_FOREACH(i
, value_strv
)
182 if (streq_ptr(node
->value
.str
, *i
))
188 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
190 return namespace_simple_pattern(node
->value
.str
, value_str
);
194 case BUS_MATCH_PATH_NAMESPACE
:
195 return path_simple_pattern(node
->value
.str
, value_str
);
197 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
199 return path_complex_pattern(node
->value
.str
, value_str
);
204 assert_not_reached("Invalid node type");
208 static bool value_node_same(
209 struct bus_match_node
*node
,
210 enum bus_match_node_type parent_type
,
212 const char *value_str
) {
214 /* Tests parameters against this value node, not doing prefix
215 * magic and stuff, i.e. this one actually compares the match
219 assert(node
->type
== BUS_MATCH_VALUE
);
221 switch (parent_type
) {
223 case BUS_MATCH_MESSAGE_TYPE
:
224 return node
->value
.u8
== value_u8
;
226 case BUS_MATCH_SENDER
:
227 case BUS_MATCH_DESTINATION
:
228 case BUS_MATCH_INTERFACE
:
229 case BUS_MATCH_MEMBER
:
231 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
232 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
:
233 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
234 case BUS_MATCH_PATH_NAMESPACE
:
235 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
236 return streq(node
->value
.str
, value_str
);
239 assert_not_reached("Invalid node type");
245 struct bus_match_node
*node
,
248 _cleanup_strv_free_
char **test_strv
= NULL
;
249 const char *test_str
= NULL
;
258 if (bus
&& bus
->match_callbacks_modified
)
261 /* Not these special semantics: when traversing the tree we
262 * usually let bus_match_run() when called for a node
263 * recursively invoke bus_match_run(). There's are two
264 * exceptions here though, which are BUS_NODE_ROOT (which
265 * cannot have a sibling), and BUS_NODE_VALUE (whose siblings
266 * are invoked anyway by its parent. */
268 switch (node
->type
) {
272 /* Run all children. Since we cannot have any siblings
273 * we won't call any. The children of the root node
274 * are compares or leaves, they will automatically
275 * call their siblings. */
276 return bus_match_run(bus
, node
->child
, m
);
278 case BUS_MATCH_VALUE
:
280 /* Run all children. We don't execute any siblings, we
281 * assume our caller does that. The children of value
282 * nodes are compares or leaves, they will
283 * automatically call their siblings */
286 return bus_match_run(bus
, node
->child
, m
);
291 if (node
->leaf
.callback
->last_iteration
== bus
->iteration_counter
)
294 node
->leaf
.callback
->last_iteration
= bus
->iteration_counter
;
297 r
= sd_bus_message_rewind(m
, true);
301 /* Run the callback. And then invoke siblings. */
302 if (node
->leaf
.callback
->callback
) {
303 _cleanup_(sd_bus_error_free
) sd_bus_error error_buffer
= SD_BUS_ERROR_NULL
;
306 slot
= container_of(node
->leaf
.callback
, sd_bus_slot
, match_callback
);
308 bus
->current_slot
= sd_bus_slot_ref(slot
);
309 bus
->current_handler
= node
->leaf
.callback
->callback
;
310 bus
->current_userdata
= slot
->userdata
;
312 r
= node
->leaf
.callback
->callback(m
, slot
->userdata
, &error_buffer
);
314 bus
->current_userdata
= NULL
;
315 bus
->current_handler
= NULL
;
316 bus
->current_slot
= sd_bus_slot_unref(slot
);
319 r
= bus_maybe_reply_error(m
, r
, &error_buffer
);
323 if (bus
&& bus
->match_callbacks_modified
)
327 return bus_match_run(bus
, node
->next
, m
);
329 case BUS_MATCH_MESSAGE_TYPE
:
330 test_u8
= m
->header
->type
;
333 case BUS_MATCH_SENDER
:
334 test_str
= m
->sender
;
335 /* FIXME: resolve test_str from a well-known to a unique name first */
338 case BUS_MATCH_DESTINATION
:
339 test_str
= m
->destination
;
342 case BUS_MATCH_INTERFACE
:
343 test_str
= m
->interface
;
346 case BUS_MATCH_MEMBER
:
347 test_str
= m
->member
;
351 case BUS_MATCH_PATH_NAMESPACE
:
355 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
356 (void) bus_message_get_arg(m
, node
->type
- BUS_MATCH_ARG
, &test_str
);
359 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
360 (void) bus_message_get_arg(m
, node
->type
- BUS_MATCH_ARG_PATH
, &test_str
);
363 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
364 (void) bus_message_get_arg(m
, node
->type
- BUS_MATCH_ARG_NAMESPACE
, &test_str
);
367 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
:
368 (void) bus_message_get_arg_strv(m
, node
->type
- BUS_MATCH_ARG_HAS
, &test_strv
);
372 assert_not_reached("Unknown match type.");
375 if (BUS_MATCH_CAN_HASH(node
->type
)) {
376 struct bus_match_node
*found
;
378 /* Lookup via hash table, nice! So let's jump directly. */
381 found
= hashmap_get(node
->compare
.children
, test_str
);
382 else if (test_strv
) {
385 STRV_FOREACH(i
, test_strv
) {
386 found
= hashmap_get(node
->compare
.children
, *i
);
388 r
= bus_match_run(bus
, found
, m
);
395 } else if (node
->type
== BUS_MATCH_MESSAGE_TYPE
)
396 found
= hashmap_get(node
->compare
.children
, UINT_TO_PTR(test_u8
));
401 r
= bus_match_run(bus
, found
, m
);
406 struct bus_match_node
*c
;
408 /* No hash table, so let's iterate manually... */
410 for (c
= node
->child
; c
; c
= c
->next
) {
411 if (!value_node_test(c
, node
->type
, test_u8
, test_str
, test_strv
, m
))
414 r
= bus_match_run(bus
, c
, m
);
418 if (bus
&& bus
->match_callbacks_modified
)
423 if (bus
&& bus
->match_callbacks_modified
)
426 /* And now, let's invoke our siblings */
427 return bus_match_run(bus
, node
->next
, m
);
430 static int bus_match_add_compare_value(
431 struct bus_match_node
*where
,
432 enum bus_match_node_type t
,
434 const char *value_str
,
435 struct bus_match_node
**ret
) {
437 struct bus_match_node
*c
= NULL
, *n
= NULL
;
441 assert(IN_SET(where
->type
, BUS_MATCH_ROOT
, BUS_MATCH_VALUE
));
442 assert(BUS_MATCH_IS_COMPARE(t
));
445 for (c
= where
->child
; c
&& c
->type
!= t
; c
= c
->next
)
449 /* Comparison node already exists? Then let's see if
450 * the value node exists too. */
452 if (t
== BUS_MATCH_MESSAGE_TYPE
)
453 n
= hashmap_get(c
->compare
.children
, UINT_TO_PTR(value_u8
));
454 else if (BUS_MATCH_CAN_HASH(t
))
455 n
= hashmap_get(c
->compare
.children
, value_str
);
457 for (n
= c
->child
; n
&& !value_node_same(n
, t
, value_u8
, value_str
); n
= n
->next
)
466 /* Comparison node, doesn't exist yet? Then let's
469 c
= new0(struct bus_match_node
, 1);
477 c
->next
= where
->child
;
482 if (t
== BUS_MATCH_MESSAGE_TYPE
) {
483 c
->compare
.children
= hashmap_new(NULL
);
484 if (!c
->compare
.children
) {
488 } else if (BUS_MATCH_CAN_HASH(t
)) {
489 c
->compare
.children
= hashmap_new(&string_hash_ops
);
490 if (!c
->compare
.children
) {
497 n
= new0(struct bus_match_node
, 1);
503 n
->type
= BUS_MATCH_VALUE
;
504 n
->value
.u8
= value_u8
;
506 n
->value
.str
= strdup(value_str
);
514 if (c
->compare
.children
) {
516 if (t
== BUS_MATCH_MESSAGE_TYPE
)
517 r
= hashmap_put(c
->compare
.children
, UINT_TO_PTR(value_u8
), n
);
519 r
= hashmap_put(c
->compare
.children
, n
->value
.str
, n
);
535 bus_match_node_maybe_free(c
);
545 static int bus_match_add_leaf(
546 struct bus_match_node
*where
,
547 struct match_callback
*callback
) {
549 struct bus_match_node
*n
;
552 assert(IN_SET(where
->type
, BUS_MATCH_ROOT
, BUS_MATCH_VALUE
));
555 n
= new0(struct bus_match_node
, 1);
559 n
->type
= BUS_MATCH_LEAF
;
561 n
->next
= where
->child
;
565 n
->leaf
.callback
= callback
;
566 callback
->match_node
= n
;
573 enum bus_match_node_type
bus_match_node_type_from_string(const char *k
, size_t n
) {
576 if (n
== 4 && startswith(k
, "type"))
577 return BUS_MATCH_MESSAGE_TYPE
;
578 if (n
== 6 && startswith(k
, "sender"))
579 return BUS_MATCH_SENDER
;
580 if (n
== 11 && startswith(k
, "destination"))
581 return BUS_MATCH_DESTINATION
;
582 if (n
== 9 && startswith(k
, "interface"))
583 return BUS_MATCH_INTERFACE
;
584 if (n
== 6 && startswith(k
, "member"))
585 return BUS_MATCH_MEMBER
;
586 if (n
== 4 && startswith(k
, "path"))
587 return BUS_MATCH_PATH
;
588 if (n
== 14 && startswith(k
, "path_namespace"))
589 return BUS_MATCH_PATH_NAMESPACE
;
591 if (n
== 4 && startswith(k
, "arg")) {
598 return BUS_MATCH_ARG
+ j
;
601 if (n
== 5 && startswith(k
, "arg")) {
603 enum bus_match_node_type t
;
610 t
= BUS_MATCH_ARG
+ a
* 10 + b
;
611 if (t
> BUS_MATCH_ARG_LAST
)
617 if (n
== 8 && startswith(k
, "arg") && startswith(k
+ 4, "path")) {
624 return BUS_MATCH_ARG_PATH
+ j
;
627 if (n
== 9 && startswith(k
, "arg") && startswith(k
+ 5, "path")) {
628 enum bus_match_node_type t
;
636 t
= BUS_MATCH_ARG_PATH
+ a
* 10 + b
;
637 if (t
> BUS_MATCH_ARG_PATH_LAST
)
643 if (n
== 13 && startswith(k
, "arg") && startswith(k
+ 4, "namespace")) {
650 return BUS_MATCH_ARG_NAMESPACE
+ j
;
653 if (n
== 14 && startswith(k
, "arg") && startswith(k
+ 5, "namespace")) {
654 enum bus_match_node_type t
;
662 t
= BUS_MATCH_ARG_NAMESPACE
+ a
* 10 + b
;
663 if (t
> BUS_MATCH_ARG_NAMESPACE_LAST
)
669 if (n
== 7 && startswith(k
, "arg") && startswith(k
+ 4, "has")) {
676 return BUS_MATCH_ARG_HAS
+ j
;
679 if (n
== 8 && startswith(k
, "arg") && startswith(k
+ 5, "has")) {
680 enum bus_match_node_type t
;
688 t
= BUS_MATCH_ARG_HAS
+ a
* 10 + b
;
689 if (t
> BUS_MATCH_ARG_HAS_LAST
)
698 static int match_component_compare(const struct bus_match_component
*a
, const struct bus_match_component
*b
) {
699 return CMP(a
->type
, b
->type
);
702 void bus_match_parse_free(struct bus_match_component
*components
, unsigned n_components
) {
705 for (i
= 0; i
< n_components
; i
++)
706 free(components
[i
].value_str
);
713 struct bus_match_component
**_components
,
714 unsigned *_n_components
) {
716 const char *p
= match
;
717 struct bus_match_component
*components
= NULL
;
718 size_t components_allocated
= 0;
719 unsigned n_components
= 0, i
;
720 _cleanup_free_
char *value
= NULL
;
725 assert(_n_components
);
729 enum bus_match_node_type t
;
731 size_t value_allocated
= 0;
732 bool escaped
= false, quoted
;
735 /* Avahi's match rules appear to include whitespace, skip over it */
742 t
= bus_match_node_type_from_string(p
, eq
- p
);
746 quoted
= eq
[1] == '\'';
748 for (q
= eq
+ 1 + quoted
;; q
++) {
784 if (!GREEDY_REALLOC(value
, value_allocated
, j
+ 2)) {
801 if (t
== BUS_MATCH_MESSAGE_TYPE
) {
802 r
= bus_message_type_from_string(value
, &u
);
806 value
= mfree(value
);
810 if (!GREEDY_REALLOC(components
, components_allocated
, n_components
+ 1)) {
815 components
[n_components
].type
= t
;
816 components
[n_components
].value_str
= TAKE_PTR(value
);
817 components
[n_components
].value_u8
= u
;
823 if (q
[quoted
] != ',') {
831 /* Order the whole thing, so that we always generate the same tree */
832 typesafe_qsort(components
, n_components
, match_component_compare
);
834 /* Check for duplicates */
835 for (i
= 0; i
+1 < n_components
; i
++)
836 if (components
[i
].type
== components
[i
+1].type
) {
841 *_components
= components
;
842 *_n_components
= n_components
;
847 bus_match_parse_free(components
, n_components
);
851 char *bus_match_to_string(struct bus_match_component
*components
, unsigned n_components
) {
852 _cleanup_fclose_
FILE *f
= NULL
;
858 if (n_components
<= 0)
863 f
= open_memstream(&buffer
, &size
);
867 (void) __fsetlocking(f
, FSETLOCKING_BYCALLER
);
869 for (i
= 0; i
< n_components
; i
++) {
875 fputs(bus_match_node_type_to_string(components
[i
].type
, buf
, sizeof(buf
)), f
);
879 if (components
[i
].type
== BUS_MATCH_MESSAGE_TYPE
)
880 fputs(bus_message_type_to_string(components
[i
].value_u8
), f
);
882 fputs(components
[i
].value_str
, f
);
887 r
= fflush_and_check(f
);
895 struct bus_match_node
*root
,
896 struct bus_match_component
*components
,
897 unsigned n_components
,
898 struct match_callback
*callback
) {
901 struct bus_match_node
*n
;
908 for (i
= 0; i
< n_components
; i
++) {
909 r
= bus_match_add_compare_value(
910 n
, components
[i
].type
,
911 components
[i
].value_u8
, components
[i
].value_str
, &n
);
916 return bus_match_add_leaf(n
, callback
);
919 int bus_match_remove(
920 struct bus_match_node
*root
,
921 struct match_callback
*callback
) {
923 struct bus_match_node
*node
, *pp
;
928 node
= callback
->match_node
;
932 assert(node
->type
== BUS_MATCH_LEAF
);
934 callback
->match_node
= NULL
;
938 bus_match_node_free(node
);
940 /* Prune the tree above */
945 if (!bus_match_node_maybe_free(node
))
952 void bus_match_free(struct bus_match_node
*node
) {
953 struct bus_match_node
*c
;
958 if (BUS_MATCH_CAN_HASH(node
->type
)) {
961 HASHMAP_FOREACH(c
, node
->compare
.children
, i
)
964 assert(hashmap_isempty(node
->compare
.children
));
967 while ((c
= node
->child
))
970 if (node
->type
!= BUS_MATCH_ROOT
)
971 bus_match_node_free(node
);
974 const char* bus_match_node_type_to_string(enum bus_match_node_type t
, char buf
[], size_t l
) {
980 case BUS_MATCH_VALUE
:
986 case BUS_MATCH_MESSAGE_TYPE
:
989 case BUS_MATCH_SENDER
:
992 case BUS_MATCH_DESTINATION
:
993 return "destination";
995 case BUS_MATCH_INTERFACE
:
998 case BUS_MATCH_MEMBER
:
1001 case BUS_MATCH_PATH
:
1004 case BUS_MATCH_PATH_NAMESPACE
:
1005 return "path_namespace";
1007 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
1008 snprintf(buf
, l
, "arg%i", t
- BUS_MATCH_ARG
);
1011 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
1012 snprintf(buf
, l
, "arg%ipath", t
- BUS_MATCH_ARG_PATH
);
1015 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
1016 snprintf(buf
, l
, "arg%inamespace", t
- BUS_MATCH_ARG_NAMESPACE
);
1019 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
:
1020 snprintf(buf
, l
, "arg%ihas", t
- BUS_MATCH_ARG_HAS
);
1028 void bus_match_dump(struct bus_match_node
*node
, unsigned level
) {
1029 struct bus_match_node
*c
;
1030 _cleanup_free_
char *pfx
= NULL
;
1036 pfx
= strrep(" ", level
);
1037 printf("%s[%s]", strempty(pfx
), bus_match_node_type_to_string(node
->type
, buf
, sizeof(buf
)));
1039 if (node
->type
== BUS_MATCH_VALUE
) {
1040 if (node
->parent
->type
== BUS_MATCH_MESSAGE_TYPE
)
1041 printf(" <%u>\n", node
->value
.u8
);
1043 printf(" <%s>\n", node
->value
.str
);
1044 } else if (node
->type
== BUS_MATCH_ROOT
)
1046 else if (node
->type
== BUS_MATCH_LEAF
)
1047 printf(" %p/%p\n", node
->leaf
.callback
->callback
, container_of(node
->leaf
.callback
, sd_bus_slot
, match_callback
)->userdata
);
1051 if (BUS_MATCH_CAN_HASH(node
->type
)) {
1054 HASHMAP_FOREACH(c
, node
->compare
.children
, i
)
1055 bus_match_dump(c
, level
+ 1);
1058 for (c
= node
->child
; c
; c
= c
->next
)
1059 bus_match_dump(c
, level
+ 1);
1062 enum bus_match_scope
bus_match_get_scope(const struct bus_match_component
*components
, unsigned n_components
) {
1063 bool found_driver
= false;
1066 if (n_components
<= 0)
1067 return BUS_MATCH_GENERIC
;
1071 /* Checks whether the specified match can only match the
1072 * pseudo-service for local messages, which we detect by
1073 * sender, interface or path. If a match is not restricted to
1074 * local messages, then we check if it only matches on the
1077 for (i
= 0; i
< n_components
; i
++) {
1078 const struct bus_match_component
*c
= components
+ i
;
1080 if (c
->type
== BUS_MATCH_SENDER
) {
1081 if (streq_ptr(c
->value_str
, "org.freedesktop.DBus.Local"))
1082 return BUS_MATCH_LOCAL
;
1084 if (streq_ptr(c
->value_str
, "org.freedesktop.DBus"))
1085 found_driver
= true;
1088 if (c
->type
== BUS_MATCH_INTERFACE
&& streq_ptr(c
->value_str
, "org.freedesktop.DBus.Local"))
1089 return BUS_MATCH_LOCAL
;
1091 if (c
->type
== BUS_MATCH_PATH
&& streq_ptr(c
->value_str
, "/org/freedesktop/DBus/Local"))
1092 return BUS_MATCH_LOCAL
;
1095 return found_driver
? BUS_MATCH_DRIVER
: BUS_MATCH_GENERIC
;