diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-06-17 11:42:39 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-06-17 11:42:39 +0200 |
commit | cc65fe5e14770d0116e0f475c5dc2ef57113bc98 (patch) | |
tree | 90a3ea575e749110fb7273d99b13896fedc823c6 /src/libsystemd/sd-bus/sd-bus.c | |
parent | 3eb3228e583e7e07dc3f2d17ea02dcb06f30fcc0 (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/sd-bus.c')
-rw-r--r-- | src/libsystemd/sd-bus/sd-bus.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 2805b29839..0881b4779a 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -2952,22 +2952,35 @@ _public_ int sd_bus_add_match( s->match_callback.cookie = ++bus->match_cookie; if (bus->bus_client) { + enum bus_match_scope scope; - if (!bus->is_kernel) { - /* When this is not a kernel transport, we - * store the original match string, so that we - * can use it to remove the match again */ + scope = bus_match_get_scope(components, n_components); - s->match_callback.match_string = strdup(match); - if (!s->match_callback.match_string) { - r = -ENOMEM; - goto finish; + /* Do not install server-side matches for matches + * against the local service, interface or bus + * path. Also, when on kdbus don't install driver + * matches server side. */ + if (scope == BUS_MATCH_GENERIC || + (!bus->is_kernel && scope == BUS_MATCH_DRIVER)) { + + if (!bus->is_kernel) { + /* When this is not a kernel transport, we + * store the original match string, so that we + * can use it to remove the match again */ + + s->match_callback.match_string = strdup(match); + if (!s->match_callback.match_string) { + r = -ENOMEM; + goto finish; + } } - } - r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components, s->match_callback.cookie); - if (r < 0) - goto finish; + r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components, s->match_callback.cookie); + if (r < 0) + goto finish; + + s->match_added = true; + } } bus->match_callbacks_modified = true; |