summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/test-bus-match.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-06-17 11:42:39 +0200
committerLennart Poettering <lennart@poettering.net>2015-06-17 11:42:39 +0200
commitcc65fe5e14770d0116e0f475c5dc2ef57113bc98 (patch)
tree90a3ea575e749110fb7273d99b13896fedc823c6 /src/libsystemd/sd-bus/test-bus-match.c
parent3eb3228e583e7e07dc3f2d17ea02dcb06f30fcc0 (diff)
sd-bus: suppress installing local bus matches server side
Matches that can only match against messages from the org.freedesktop.DBus.Local service (or the local interfaces or path) should never be installed server side, suppress them hence. Similar, on kdbus matches that can only match driver messages shouldn't be passed to the kernel.
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-match.c')
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index 40c67046d..a1687b1c7 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -77,6 +77,15 @@ static int match_add(sd_bus_slot *slots, struct bus_match_node *root, const char
return r;
}
+static void test_match_scope(const char *match, enum bus_match_scope scope) {
+ struct bus_match_component *components = NULL;
+ unsigned n_components = 0;
+
+ assert_se(bus_match_parse(match, &components, &n_components) >= 0);
+ assert_se(bus_match_get_scope(components, n_components) == scope);
+ bus_match_parse_free(components, n_components);
+}
+
int main(int argc, char *argv[]) {
struct bus_match_node root = {
.type = BUS_MATCH_ROOT,
@@ -142,5 +151,12 @@ int main(int argc, char *argv[]) {
bus_match_free(&root);
+ test_match_scope("interface='foobar'", BUS_MATCH_GENERIC);
+ test_match_scope("", BUS_MATCH_GENERIC);
+ test_match_scope("interface='org.freedesktop.DBus.Local'", BUS_MATCH_LOCAL);
+ test_match_scope("sender='org.freedesktop.DBus.Local'", BUS_MATCH_LOCAL);
+ test_match_scope("member='gurke',path='/org/freedesktop/DBus/Local'", BUS_MATCH_LOCAL);
+ test_match_scope("arg2='piep',sender='org.freedesktop.DBus',member='waldo'", BUS_MATCH_DRIVER);
+
return 0;
}