diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-09-07 19:53:34 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-09-07 19:53:34 +0200 |
commit | 385080c09e48ea62a80525197f66f3347d96d2ce (patch) | |
tree | 8ae7f44ae8f7ba9658484d3fd7ca2c8b394de1af | |
parent | 2b7d6d33dc04d9ef370b51afe88d28be8a4f9f84 (diff) |
machined: improve error message when trying to get a bus in bus-less containers
Now that we get useful error messages from sd-bus for container
connections, let's make use of this and report better errors back to
machined clients.
Fixes #685.
-rw-r--r-- | src/machine/machine-dbus.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index fbeace0ed6..cc38116704 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -519,7 +519,7 @@ int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_ return sd_bus_send(NULL, reply, NULL); } -static int container_bus_new(Machine *m, sd_bus **ret) { +static int container_bus_new(Machine *m, sd_bus_error *error, sd_bus **ret) { int r; assert(m); @@ -548,6 +548,8 @@ static int container_bus_new(Machine *m, sd_bus **ret) { bus->is_system = true; r = sd_bus_start(bus); + if (r == -ENOENT) + return sd_bus_error_set_errnof(error, r, "There is no system bus in container %s.", m->name); if (r < 0) return r; @@ -602,7 +604,7 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu if (!p) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PTS name %s is invalid", pty_name); - r = container_bus_new(m, &allocated_bus); + r = container_bus_new(m, error, &allocated_bus); if (r < 0) return r; @@ -704,7 +706,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu utmp_id = path_startswith(pty_name, "/dev/"); assert(utmp_id); - r = container_bus_new(m, &allocated_bus); + r = container_bus_new(m, error, &allocated_bus); if (r < 0) return r; |