summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-23 16:23:15 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-23 16:23:15 +0200
commit33c62dcbd78dd42603a0d8989a150e816e0414d9 (patch)
tree07ffe18852a35381a7087a51abe3955a11f923ea /src/libsystemd
parent8d9803b83c1f72e1bf158af4615b1c53a4749118 (diff)
sd-bus: when bus operations are to be executed on direct connections always fail
Also, don't consider this an loggable event, so that code that tries to read creds from a direct connection, doesn't generate logs.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-control.c27
-rw-r--r--src/libsystemd/sd-bus/bus-track.c3
2 files changed, 27 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 1084ddc9ca..ca31807f70 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -42,6 +42,9 @@ _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
assert_return(unique, -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!bus->bus_client)
+ return -EINVAL;
+
r = bus_ensure_running(bus);
if (r < 0)
return r;
@@ -130,12 +133,14 @@ static int bus_request_name_dbus1(sd_bus *bus, const char *name, uint64_t flags)
_public_ int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags) {
assert_return(bus, -EINVAL);
assert_return(name, -EINVAL);
- assert_return(bus->bus_client, -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_QUEUE)), -EINVAL);
assert_return(service_name_is_valid(name), -EINVAL);
assert_return(name[0] != ':', -EINVAL);
+ if (!bus->bus_client)
+ return -EINVAL;
+
/* Don't allow requesting the special driver and local names */
if (STR_IN_SET(name, "org.freedesktop.DBus", "org.freedesktop.DBus.Local"))
return -EINVAL;
@@ -213,11 +218,13 @@ static int bus_release_name_dbus1(sd_bus *bus, const char *name) {
_public_ int sd_bus_release_name(sd_bus *bus, const char *name) {
assert_return(bus, -EINVAL);
assert_return(name, -EINVAL);
- assert_return(bus->bus_client, -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(service_name_is_valid(name), -EINVAL);
assert_return(name[0] != ':', -EINVAL);
+ if (!bus->bus_client)
+ return -EINVAL;
+
/* Don't allow releasing the special driver and local names */
if (STR_IN_SET(name, "org.freedesktop.DBus", "org.freedesktop.DBus.Local"))
return -EINVAL;
@@ -374,6 +381,9 @@ _public_ int sd_bus_list_names(sd_bus *bus, char ***acquired, char ***activatabl
assert_return(acquired || activatable, -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
+ if (!bus->bus_client)
+ return -EINVAL;
+
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -885,7 +895,9 @@ _public_ int sd_bus_get_name_creds(
assert_return(mask == 0 || creds, -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(service_name_is_valid(name), -EINVAL);
- assert_return(bus->bus_client, -ENODATA);
+
+ if (!bus->bus_client)
+ return -EINVAL;
if (streq(name, "org.freedesktop.DBus.Local"))
return -EINVAL;
@@ -1400,6 +1412,9 @@ int bus_add_match_internal(
assert(bus);
+ if (!bus->bus_client)
+ return -EINVAL;
+
if (bus->is_kernel)
return bus_add_match_internal_kernel(bus, components, n_components, cookie);
else
@@ -1459,6 +1474,9 @@ int bus_remove_match_internal(
assert(bus);
+ if (!bus->bus_client)
+ return -EINVAL;
+
if (bus->is_kernel)
return bus_remove_match_internal_kernel(bus, cookie);
else
@@ -1476,6 +1494,9 @@ _public_ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(service_name_is_valid(name), -EINVAL);
+ if (!bus->bus_client)
+ return -EINVAL;
+
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
index 048178550b..6582baa8e0 100644
--- a/src/libsystemd/sd-bus/bus-track.c
+++ b/src/libsystemd/sd-bus/bus-track.c
@@ -90,6 +90,9 @@ _public_ int sd_bus_track_new(
assert_return(bus, -EINVAL);
assert_return(track, -EINVAL);
+ if (!bus->bus_client)
+ return -EINVAL;
+
t = new0(sd_bus_track, 1);
if (!t)
return -ENOMEM;