summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-control.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-05-17 02:50:00 +0200
committerLennart Poettering <lennart@poettering.net>2013-05-17 04:26:27 +0200
commitd5a2b9a6f455468a0f29483303657ab4fd7013d8 (patch)
tree99ffb05077e6318545de6cb182f2bbbf278ceda9 /src/libsystemd-bus/bus-control.c
parent63edf05ed9c1d4cb5cf9364e734b2a96f84622d0 (diff)
bus: return ECHILD as soon as people try to reuse a bus connection across a fork()
Diffstat (limited to 'src/libsystemd-bus/bus-control.c')
-rw-r--r--src/libsystemd-bus/bus-control.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c
index a4dc9bf511..177bd882ad 100644
--- a/src/libsystemd-bus/bus-control.c
+++ b/src/libsystemd-bus/bus-control.c
@@ -40,6 +40,8 @@ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
return -EINVAL;
if (!unique)
return -EINVAL;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
r = bus_ensure_running(bus);
if (r < 0)
@@ -60,6 +62,10 @@ int sd_bus_request_name(sd_bus *bus, const char *name, int flags) {
return -EINVAL;
if (!bus->bus_client)
return -EINVAL;
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
if (bus->is_kernel) {
struct kdbus_cmd_name *n;
@@ -114,6 +120,10 @@ int sd_bus_release_name(sd_bus *bus, const char *name) {
return -EINVAL;
if (!bus->bus_client)
return -EINVAL;
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
if (bus->is_kernel) {
struct kdbus_cmd_name *n;
@@ -163,6 +173,10 @@ int sd_bus_list_names(sd_bus *bus, char ***l) {
return -EINVAL;
if (!l)
return -EINVAL;
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
r = sd_bus_call_method(
bus,
@@ -213,6 +227,10 @@ int sd_bus_get_owner(sd_bus *bus, const char *name, char **owner) {
return -EINVAL;
if (!name)
return -EINVAL;
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
r = sd_bus_call_method(
bus,
@@ -255,6 +273,10 @@ int sd_bus_get_owner_uid(sd_bus *bus, const char *name, uid_t *uid) {
return -EINVAL;
if (!uid)
return -EINVAL;
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
r = sd_bus_call_method(
bus,
@@ -288,6 +310,10 @@ int sd_bus_get_owner_pid(sd_bus *bus, const char *name, pid_t *pid) {
return -EINVAL;
if (!pid)
return -EINVAL;
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
r = sd_bus_call_method(
bus,
@@ -354,6 +380,10 @@ int sd_bus_get_owner_machine_id(sd_bus *bus, const char *name, sd_id128_t *machi
return -EINVAL;
if (!name)
return -EINVAL;
+ if (!BUS_IS_OPEN(bus->state))
+ return -ENOTCONN;
+ if (bus_pid_changed(bus))
+ return -ECHILD;
if (streq_ptr(name, bus->unique_name))
return sd_id128_get_machine(machine);