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 "sort-util.h"
14 #include "string-util.h"
19 * A: type=signal,sender=foo,interface=bar
20 * B: type=signal,sender=quux,interface=fips
21 * C: type=signal,sender=quux,interface=waldo
22 * D: type=signal,member=test
27 * results in this tree:
30 * + BUS_MATCH_MESSAGE_TYPE
31 * | ` BUS_MATCH_VALUE: value == signal
32 * | + DBUS_MATCH_SENDER
33 * | | + BUS_MATCH_VALUE: value == foo
34 * | | | ` DBUS_MATCH_INTERFACE
35 * | | | ` BUS_MATCH_VALUE: value == bar
36 * | | | ` BUS_MATCH_LEAF: A
37 * | | ` BUS_MATCH_VALUE: value == quux
38 * | | ` DBUS_MATCH_INTERFACE
39 * | | | BUS_MATCH_VALUE: value == fips
40 * | | | ` BUS_MATCH_LEAF: B
41 * | | ` BUS_MATCH_VALUE: value == waldo
42 * | | ` BUS_MATCH_LEAF: C
43 * | + DBUS_MATCH_MEMBER
44 * | | ` BUS_MATCH_VALUE: value == test
45 * | | ` BUS_MATCH_LEAF: D
46 * | + BUS_MATCH_LEAF: F
47 * | ` BUS_MATCH_LEAF: G
49 * ` BUS_MATCH_VALUE: value == miau
53 static bool BUS_MATCH_IS_COMPARE(enum bus_match_node_type t
) {
54 return t
>= BUS_MATCH_SENDER
&& t
<= BUS_MATCH_ARG_HAS_LAST
;
57 static bool BUS_MATCH_CAN_HASH(enum bus_match_node_type t
) {
58 return (t
>= BUS_MATCH_MESSAGE_TYPE
&& t
<= BUS_MATCH_PATH
) ||
59 (t
>= BUS_MATCH_ARG
&& t
<= BUS_MATCH_ARG_LAST
) ||
60 (t
>= BUS_MATCH_ARG_HAS
&& t
<= BUS_MATCH_ARG_HAS_LAST
);
63 static void bus_match_node_free(struct bus_match_node
*node
) {
67 assert(node
->type
!= BUS_MATCH_ROOT
);
68 assert(node
->type
< _BUS_MATCH_NODE_TYPE_MAX
);
70 if (node
->parent
->child
) {
71 /* We are apparently linked into the parent's child
72 * list. Let's remove us from there. */
74 assert(node
->prev
->next
== node
);
75 node
->prev
->next
= node
->next
;
77 assert(node
->parent
->child
== node
);
78 node
->parent
->child
= node
->next
;
82 node
->next
->prev
= node
->prev
;
85 if (node
->type
== BUS_MATCH_VALUE
) {
86 /* We might be in the parent's hash table, so clean
89 if (node
->parent
->type
== BUS_MATCH_MESSAGE_TYPE
)
90 hashmap_remove(node
->parent
->compare
.children
, UINT_TO_PTR(node
->value
.u8
));
91 else if (BUS_MATCH_CAN_HASH(node
->parent
->type
) && node
->value
.str
)
92 hashmap_remove(node
->parent
->compare
.children
, node
->value
.str
);
94 free(node
->value
.str
);
97 if (BUS_MATCH_IS_COMPARE(node
->type
)) {
98 assert(hashmap_isempty(node
->compare
.children
));
99 hashmap_free(node
->compare
.children
);
105 static bool bus_match_node_maybe_free(struct bus_match_node
*node
) {
108 if (node
->type
== BUS_MATCH_ROOT
)
114 if (BUS_MATCH_IS_COMPARE(node
->type
) && !hashmap_isempty(node
->compare
.children
))
117 bus_match_node_free(node
);
121 static bool value_node_test(
122 struct bus_match_node
*node
,
123 enum bus_match_node_type parent_type
,
125 const char *value_str
,
130 assert(node
->type
== BUS_MATCH_VALUE
);
132 /* Tests parameters against this value node, doing prefix
133 * magic and stuff. */
135 switch (parent_type
) {
137 case BUS_MATCH_MESSAGE_TYPE
:
138 return node
->value
.u8
== value_u8
;
140 case BUS_MATCH_SENDER
:
141 if (streq_ptr(node
->value
.str
, value_str
))
144 if (m
->creds
.mask
& SD_BUS_CREDS_WELL_KNOWN_NAMES
) {
147 /* on kdbus we have the well known names list
148 * in the credentials, let's make use of that
149 * for an accurate match */
151 STRV_FOREACH(i
, m
->creds
.well_known_names
)
152 if (streq_ptr(node
->value
.str
, *i
))
157 /* If we don't have kdbus, we don't know the
158 * well-known names of the senders. In that,
159 * let's just hope that dbus-daemon doesn't
160 * send us stuff we didn't want. */
162 if (node
->value
.str
[0] != ':' && value_str
&& value_str
[0] == ':')
168 case BUS_MATCH_DESTINATION
:
169 case BUS_MATCH_INTERFACE
:
170 case BUS_MATCH_MEMBER
:
172 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
175 return streq_ptr(node
->value
.str
, value_str
);
179 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
: {
182 STRV_FOREACH(i
, value_strv
)
183 if (streq_ptr(node
->value
.str
, *i
))
189 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
191 return namespace_simple_pattern(node
->value
.str
, value_str
);
195 case BUS_MATCH_PATH_NAMESPACE
:
196 return path_simple_pattern(node
->value
.str
, value_str
);
198 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
200 return path_complex_pattern(node
->value
.str
, value_str
);
205 assert_not_reached("Invalid node type");
209 static bool value_node_same(
210 struct bus_match_node
*node
,
211 enum bus_match_node_type parent_type
,
213 const char *value_str
) {
215 /* Tests parameters against this value node, not doing prefix
216 * magic and stuff, i.e. this one actually compares the match
220 assert(node
->type
== BUS_MATCH_VALUE
);
222 switch (parent_type
) {
224 case BUS_MATCH_MESSAGE_TYPE
:
225 return node
->value
.u8
== value_u8
;
227 case BUS_MATCH_SENDER
:
228 case BUS_MATCH_DESTINATION
:
229 case BUS_MATCH_INTERFACE
:
230 case BUS_MATCH_MEMBER
:
232 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
233 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
:
234 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
235 case BUS_MATCH_PATH_NAMESPACE
:
236 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
237 return streq(node
->value
.str
, value_str
);
240 assert_not_reached("Invalid node type");
246 struct bus_match_node
*node
,
249 _cleanup_strv_free_
char **test_strv
= NULL
;
250 const char *test_str
= NULL
;
259 if (bus
&& bus
->match_callbacks_modified
)
262 /* Not these special semantics: when traversing the tree we
263 * usually let bus_match_run() when called for a node
264 * recursively invoke bus_match_run(). There's are two
265 * exceptions here though, which are BUS_NODE_ROOT (which
266 * cannot have a sibling), and BUS_NODE_VALUE (whose siblings
267 * are invoked anyway by its parent. */
269 switch (node
->type
) {
273 /* Run all children. Since we cannot have any siblings
274 * we won't call any. The children of the root node
275 * are compares or leaves, they will automatically
276 * call their siblings. */
277 return bus_match_run(bus
, node
->child
, m
);
279 case BUS_MATCH_VALUE
:
281 /* Run all children. We don't execute any siblings, we
282 * assume our caller does that. The children of value
283 * nodes are compares or leaves, they will
284 * automatically call their siblings */
287 return bus_match_run(bus
, node
->child
, m
);
292 if (node
->leaf
.callback
->last_iteration
== bus
->iteration_counter
)
295 node
->leaf
.callback
->last_iteration
= bus
->iteration_counter
;
298 r
= sd_bus_message_rewind(m
, true);
302 /* Run the callback. And then invoke siblings. */
303 if (node
->leaf
.callback
->callback
) {
304 _cleanup_(sd_bus_error_free
) sd_bus_error error_buffer
= SD_BUS_ERROR_NULL
;
307 slot
= container_of(node
->leaf
.callback
, sd_bus_slot
, match_callback
);
309 bus
->current_slot
= sd_bus_slot_ref(slot
);
310 bus
->current_handler
= node
->leaf
.callback
->callback
;
311 bus
->current_userdata
= slot
->userdata
;
313 r
= node
->leaf
.callback
->callback(m
, slot
->userdata
, &error_buffer
);
315 bus
->current_userdata
= NULL
;
316 bus
->current_handler
= NULL
;
317 bus
->current_slot
= sd_bus_slot_unref(slot
);
320 r
= bus_maybe_reply_error(m
, r
, &error_buffer
);
324 if (bus
&& bus
->match_callbacks_modified
)
328 return bus_match_run(bus
, node
->next
, m
);
330 case BUS_MATCH_MESSAGE_TYPE
:
331 test_u8
= m
->header
->type
;
334 case BUS_MATCH_SENDER
:
335 test_str
= m
->sender
;
336 /* FIXME: resolve test_str from a well-known to a unique name first */
339 case BUS_MATCH_DESTINATION
:
340 test_str
= m
->destination
;
343 case BUS_MATCH_INTERFACE
:
344 test_str
= m
->interface
;
347 case BUS_MATCH_MEMBER
:
348 test_str
= m
->member
;
352 case BUS_MATCH_PATH_NAMESPACE
:
356 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
357 (void) bus_message_get_arg(m
, node
->type
- BUS_MATCH_ARG
, &test_str
);
360 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
361 (void) bus_message_get_arg(m
, node
->type
- BUS_MATCH_ARG_PATH
, &test_str
);
364 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
365 (void) bus_message_get_arg(m
, node
->type
- BUS_MATCH_ARG_NAMESPACE
, &test_str
);
368 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
:
369 (void) bus_message_get_arg_strv(m
, node
->type
- BUS_MATCH_ARG_HAS
, &test_strv
);
373 assert_not_reached("Unknown match type.");
376 if (BUS_MATCH_CAN_HASH(node
->type
)) {
377 struct bus_match_node
*found
;
379 /* Lookup via hash table, nice! So let's jump directly. */
382 found
= hashmap_get(node
->compare
.children
, test_str
);
383 else if (test_strv
) {
386 STRV_FOREACH(i
, test_strv
) {
387 found
= hashmap_get(node
->compare
.children
, *i
);
389 r
= bus_match_run(bus
, found
, m
);
396 } else if (node
->type
== BUS_MATCH_MESSAGE_TYPE
)
397 found
= hashmap_get(node
->compare
.children
, UINT_TO_PTR(test_u8
));
402 r
= bus_match_run(bus
, found
, m
);
407 struct bus_match_node
*c
;
409 /* No hash table, so let's iterate manually... */
411 for (c
= node
->child
; c
; c
= c
->next
) {
412 if (!value_node_test(c
, node
->type
, test_u8
, test_str
, test_strv
, m
))
415 r
= bus_match_run(bus
, c
, m
);
419 if (bus
&& bus
->match_callbacks_modified
)
424 if (bus
&& bus
->match_callbacks_modified
)
427 /* And now, let's invoke our siblings */
428 return bus_match_run(bus
, node
->next
, m
);
431 static int bus_match_add_compare_value(
432 struct bus_match_node
*where
,
433 enum bus_match_node_type t
,
435 const char *value_str
,
436 struct bus_match_node
**ret
) {
438 struct bus_match_node
*c
= NULL
, *n
= NULL
;
442 assert(IN_SET(where
->type
, BUS_MATCH_ROOT
, BUS_MATCH_VALUE
));
443 assert(BUS_MATCH_IS_COMPARE(t
));
446 for (c
= where
->child
; c
&& c
->type
!= t
; c
= c
->next
)
450 /* Comparison node already exists? Then let's see if
451 * the value node exists too. */
453 if (t
== BUS_MATCH_MESSAGE_TYPE
)
454 n
= hashmap_get(c
->compare
.children
, UINT_TO_PTR(value_u8
));
455 else if (BUS_MATCH_CAN_HASH(t
))
456 n
= hashmap_get(c
->compare
.children
, value_str
);
458 for (n
= c
->child
; n
&& !value_node_same(n
, t
, value_u8
, value_str
); n
= n
->next
)
467 /* Comparison node, doesn't exist yet? Then let's
470 c
= new0(struct bus_match_node
, 1);
478 c
->next
= where
->child
;
483 if (t
== BUS_MATCH_MESSAGE_TYPE
) {
484 c
->compare
.children
= hashmap_new(NULL
);
485 if (!c
->compare
.children
) {
489 } else if (BUS_MATCH_CAN_HASH(t
)) {
490 c
->compare
.children
= hashmap_new(&string_hash_ops
);
491 if (!c
->compare
.children
) {
498 n
= new0(struct bus_match_node
, 1);
504 n
->type
= BUS_MATCH_VALUE
;
505 n
->value
.u8
= value_u8
;
507 n
->value
.str
= strdup(value_str
);
515 if (c
->compare
.children
) {
517 if (t
== BUS_MATCH_MESSAGE_TYPE
)
518 r
= hashmap_put(c
->compare
.children
, UINT_TO_PTR(value_u8
), n
);
520 r
= hashmap_put(c
->compare
.children
, n
->value
.str
, n
);
536 bus_match_node_maybe_free(c
);
546 static int bus_match_add_leaf(
547 struct bus_match_node
*where
,
548 struct match_callback
*callback
) {
550 struct bus_match_node
*n
;
553 assert(IN_SET(where
->type
, BUS_MATCH_ROOT
, BUS_MATCH_VALUE
));
556 n
= new0(struct bus_match_node
, 1);
560 n
->type
= BUS_MATCH_LEAF
;
562 n
->next
= where
->child
;
566 n
->leaf
.callback
= callback
;
567 callback
->match_node
= n
;
574 enum bus_match_node_type
bus_match_node_type_from_string(const char *k
, size_t n
) {
577 if (n
== 4 && startswith(k
, "type"))
578 return BUS_MATCH_MESSAGE_TYPE
;
579 if (n
== 6 && startswith(k
, "sender"))
580 return BUS_MATCH_SENDER
;
581 if (n
== 11 && startswith(k
, "destination"))
582 return BUS_MATCH_DESTINATION
;
583 if (n
== 9 && startswith(k
, "interface"))
584 return BUS_MATCH_INTERFACE
;
585 if (n
== 6 && startswith(k
, "member"))
586 return BUS_MATCH_MEMBER
;
587 if (n
== 4 && startswith(k
, "path"))
588 return BUS_MATCH_PATH
;
589 if (n
== 14 && startswith(k
, "path_namespace"))
590 return BUS_MATCH_PATH_NAMESPACE
;
592 if (n
== 4 && startswith(k
, "arg")) {
599 return BUS_MATCH_ARG
+ j
;
602 if (n
== 5 && startswith(k
, "arg")) {
604 enum bus_match_node_type t
;
611 t
= BUS_MATCH_ARG
+ a
* 10 + b
;
612 if (t
> BUS_MATCH_ARG_LAST
)
618 if (n
== 8 && startswith(k
, "arg") && startswith(k
+ 4, "path")) {
625 return BUS_MATCH_ARG_PATH
+ j
;
628 if (n
== 9 && startswith(k
, "arg") && startswith(k
+ 5, "path")) {
629 enum bus_match_node_type t
;
637 t
= BUS_MATCH_ARG_PATH
+ a
* 10 + b
;
638 if (t
> BUS_MATCH_ARG_PATH_LAST
)
644 if (n
== 13 && startswith(k
, "arg") && startswith(k
+ 4, "namespace")) {
651 return BUS_MATCH_ARG_NAMESPACE
+ j
;
654 if (n
== 14 && startswith(k
, "arg") && startswith(k
+ 5, "namespace")) {
655 enum bus_match_node_type t
;
663 t
= BUS_MATCH_ARG_NAMESPACE
+ a
* 10 + b
;
664 if (t
> BUS_MATCH_ARG_NAMESPACE_LAST
)
670 if (n
== 7 && startswith(k
, "arg") && startswith(k
+ 4, "has")) {
677 return BUS_MATCH_ARG_HAS
+ j
;
680 if (n
== 8 && startswith(k
, "arg") && startswith(k
+ 5, "has")) {
681 enum bus_match_node_type t
;
689 t
= BUS_MATCH_ARG_HAS
+ a
* 10 + b
;
690 if (t
> BUS_MATCH_ARG_HAS_LAST
)
699 static int match_component_compare(const struct bus_match_component
*a
, const struct bus_match_component
*b
) {
700 return CMP(a
->type
, b
->type
);
703 void bus_match_parse_free(struct bus_match_component
*components
, unsigned n_components
) {
706 for (i
= 0; i
< n_components
; i
++)
707 free(components
[i
].value_str
);
714 struct bus_match_component
**_components
,
715 unsigned *_n_components
) {
717 const char *p
= match
;
718 struct bus_match_component
*components
= NULL
;
719 size_t components_allocated
= 0;
720 unsigned n_components
= 0, i
;
721 _cleanup_free_
char *value
= NULL
;
726 assert(_n_components
);
730 enum bus_match_node_type t
;
732 size_t value_allocated
= 0;
733 bool escaped
= false, quoted
;
736 /* Avahi's match rules appear to include whitespace, skip over it */
743 t
= bus_match_node_type_from_string(p
, eq
- p
);
747 quoted
= eq
[1] == '\'';
749 for (q
= eq
+ 1 + quoted
;; q
++) {
785 if (!GREEDY_REALLOC(value
, value_allocated
, j
+ 2)) {
802 if (t
== BUS_MATCH_MESSAGE_TYPE
) {
803 r
= bus_message_type_from_string(value
, &u
);
807 value
= mfree(value
);
811 if (!GREEDY_REALLOC(components
, components_allocated
, n_components
+ 1)) {
816 components
[n_components
].type
= t
;
817 components
[n_components
].value_str
= TAKE_PTR(value
);
818 components
[n_components
].value_u8
= u
;
824 if (q
[quoted
] != ',') {
832 /* Order the whole thing, so that we always generate the same tree */
833 typesafe_qsort(components
, n_components
, match_component_compare
);
835 /* Check for duplicates */
836 for (i
= 0; i
+1 < n_components
; i
++)
837 if (components
[i
].type
== components
[i
+1].type
) {
842 *_components
= components
;
843 *_n_components
= n_components
;
848 bus_match_parse_free(components
, n_components
);
852 char *bus_match_to_string(struct bus_match_component
*components
, unsigned n_components
) {
853 _cleanup_fclose_
FILE *f
= NULL
;
859 if (n_components
<= 0)
864 f
= open_memstream(&buffer
, &size
);
868 (void) __fsetlocking(f
, FSETLOCKING_BYCALLER
);
870 for (i
= 0; i
< n_components
; i
++) {
876 fputs(bus_match_node_type_to_string(components
[i
].type
, buf
, sizeof(buf
)), f
);
880 if (components
[i
].type
== BUS_MATCH_MESSAGE_TYPE
)
881 fputs(bus_message_type_to_string(components
[i
].value_u8
), f
);
883 fputs(components
[i
].value_str
, f
);
888 r
= fflush_and_check(f
);
896 struct bus_match_node
*root
,
897 struct bus_match_component
*components
,
898 unsigned n_components
,
899 struct match_callback
*callback
) {
902 struct bus_match_node
*n
;
909 for (i
= 0; i
< n_components
; i
++) {
910 r
= bus_match_add_compare_value(
911 n
, components
[i
].type
,
912 components
[i
].value_u8
, components
[i
].value_str
, &n
);
917 return bus_match_add_leaf(n
, callback
);
920 int bus_match_remove(
921 struct bus_match_node
*root
,
922 struct match_callback
*callback
) {
924 struct bus_match_node
*node
, *pp
;
929 node
= callback
->match_node
;
933 assert(node
->type
== BUS_MATCH_LEAF
);
935 callback
->match_node
= NULL
;
939 bus_match_node_free(node
);
941 /* Prune the tree above */
946 if (!bus_match_node_maybe_free(node
))
953 void bus_match_free(struct bus_match_node
*node
) {
954 struct bus_match_node
*c
;
959 if (BUS_MATCH_CAN_HASH(node
->type
)) {
962 HASHMAP_FOREACH(c
, node
->compare
.children
, i
)
965 assert(hashmap_isempty(node
->compare
.children
));
968 while ((c
= node
->child
))
971 if (node
->type
!= BUS_MATCH_ROOT
)
972 bus_match_node_free(node
);
975 const char* bus_match_node_type_to_string(enum bus_match_node_type t
, char buf
[], size_t l
) {
981 case BUS_MATCH_VALUE
:
987 case BUS_MATCH_MESSAGE_TYPE
:
990 case BUS_MATCH_SENDER
:
993 case BUS_MATCH_DESTINATION
:
994 return "destination";
996 case BUS_MATCH_INTERFACE
:
999 case BUS_MATCH_MEMBER
:
1002 case BUS_MATCH_PATH
:
1005 case BUS_MATCH_PATH_NAMESPACE
:
1006 return "path_namespace";
1008 case BUS_MATCH_ARG
... BUS_MATCH_ARG_LAST
:
1009 snprintf(buf
, l
, "arg%i", t
- BUS_MATCH_ARG
);
1012 case BUS_MATCH_ARG_PATH
... BUS_MATCH_ARG_PATH_LAST
:
1013 snprintf(buf
, l
, "arg%ipath", t
- BUS_MATCH_ARG_PATH
);
1016 case BUS_MATCH_ARG_NAMESPACE
... BUS_MATCH_ARG_NAMESPACE_LAST
:
1017 snprintf(buf
, l
, "arg%inamespace", t
- BUS_MATCH_ARG_NAMESPACE
);
1020 case BUS_MATCH_ARG_HAS
... BUS_MATCH_ARG_HAS_LAST
:
1021 snprintf(buf
, l
, "arg%ihas", t
- BUS_MATCH_ARG_HAS
);
1029 void bus_match_dump(struct bus_match_node
*node
, unsigned level
) {
1030 struct bus_match_node
*c
;
1031 _cleanup_free_
char *pfx
= NULL
;
1037 pfx
= strrep(" ", level
);
1038 printf("%s[%s]", strempty(pfx
), bus_match_node_type_to_string(node
->type
, buf
, sizeof(buf
)));
1040 if (node
->type
== BUS_MATCH_VALUE
) {
1041 if (node
->parent
->type
== BUS_MATCH_MESSAGE_TYPE
)
1042 printf(" <%u>\n", node
->value
.u8
);
1044 printf(" <%s>\n", node
->value
.str
);
1045 } else if (node
->type
== BUS_MATCH_ROOT
)
1047 else if (node
->type
== BUS_MATCH_LEAF
)
1048 printf(" %p/%p\n", node
->leaf
.callback
->callback
, container_of(node
->leaf
.callback
, sd_bus_slot
, match_callback
)->userdata
);
1052 if (BUS_MATCH_CAN_HASH(node
->type
)) {
1055 HASHMAP_FOREACH(c
, node
->compare
.children
, i
)
1056 bus_match_dump(c
, level
+ 1);
1059 for (c
= node
->child
; c
; c
= c
->next
)
1060 bus_match_dump(c
, level
+ 1);
1063 enum bus_match_scope
bus_match_get_scope(const struct bus_match_component
*components
, unsigned n_components
) {
1064 bool found_driver
= false;
1067 if (n_components
<= 0)
1068 return BUS_MATCH_GENERIC
;
1072 /* Checks whether the specified match can only match the
1073 * pseudo-service for local messages, which we detect by
1074 * sender, interface or path. If a match is not restricted to
1075 * local messages, then we check if it only matches on the
1078 for (i
= 0; i
< n_components
; i
++) {
1079 const struct bus_match_component
*c
= components
+ i
;
1081 if (c
->type
== BUS_MATCH_SENDER
) {
1082 if (streq_ptr(c
->value_str
, "org.freedesktop.DBus.Local"))
1083 return BUS_MATCH_LOCAL
;
1085 if (streq_ptr(c
->value_str
, "org.freedesktop.DBus"))
1086 found_driver
= true;
1089 if (c
->type
== BUS_MATCH_INTERFACE
&& streq_ptr(c
->value_str
, "org.freedesktop.DBus.Local"))
1090 return BUS_MATCH_LOCAL
;
1092 if (c
->type
== BUS_MATCH_PATH
&& streq_ptr(c
->value_str
, "/org/freedesktop/DBus/Local"))
1093 return BUS_MATCH_LOCAL
;
1096 return found_driver
? BUS_MATCH_DRIVER
: BUS_MATCH_GENERIC
;