summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 14:59:52 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 15:08:42 -0400
commit8f077bf94e129fa1b6f0159e3140c4326f1066cf (patch)
tree86e09f4e9720253c641a00cd6619b6ec0493524b /src
parent4aa4d2ae9717d0f8656528a3197bbc0c256380b1 (diff)
Print kdbus path when opening fails
This makes it easier to debug what is going on.
Diffstat (limited to 'src')
-rw-r--r--src/core/busname.c9
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c15
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.h2
3 files changed, 20 insertions, 6 deletions
diff --git a/src/core/busname.c b/src/core/busname.c
index b3f7e0d5d5..39ea6a0d93 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -290,14 +290,19 @@ static int busname_watch_fd(BusName *n) {
}
static int busname_open_fd(BusName *n) {
+ _cleanup_free_ char *path = NULL;
+ const char *mode;
+
assert(n);
if (n->starter_fd >= 0)
return 0;
- n->starter_fd = bus_kernel_open_bus_fd(UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user");
+ mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user";
+ n->starter_fd = bus_kernel_open_bus_fd(mode, &path);
if (n->starter_fd < 0) {
- log_warning_unit(UNIT(n)->id, "Failed to create starter fd: %s", strerror(-n->starter_fd));
+ log_warning_unit(UNIT(n)->id, "Failed to open %s: %s",
+ path ?: "kdbus", strerror(-n->starter_fd));
return n->starter_fd;
}
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index f49fb5b394..8b961c38eb 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1402,11 +1402,20 @@ static int bus_kernel_translate_policy(const BusNamePolicy *policy, struct kdbus
return 0;
}
-int bus_kernel_open_bus_fd(const char *bus) {
+int bus_kernel_open_bus_fd(const char *bus, char **path) {
char *p;
int fd;
+ size_t len;
- p = alloca(strlen("/dev/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + strlen(bus) + strlen("/bus") + 1);
+ len = strlen("/dev/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + strlen(bus) + strlen("/bus") + 1;
+
+ if (path) {
+ p = malloc(len);
+ if (!p)
+ return -ENOMEM;
+ *path = p;
+ } else
+ p = alloca(len);
sprintf(p, "/dev/kdbus/" UID_FMT "-%s/bus", getuid(), bus);
fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC);
@@ -1549,7 +1558,7 @@ int bus_kernel_create_monitor(const char *bus) {
assert(bus);
- fd = bus_kernel_open_bus_fd(bus);
+ fd = bus_kernel_open_bus_fd(bus, NULL);
if (fd < 0)
return fd;
diff --git a/src/libsystemd/sd-bus/bus-kernel.h b/src/libsystemd/sd-bus/bus-kernel.h
index 2fe2495a6c..87f98c58bf 100644
--- a/src/libsystemd/sd-bus/bus-kernel.h
+++ b/src/libsystemd/sd-bus/bus-kernel.h
@@ -65,7 +65,7 @@ int bus_kernel_take_fd(sd_bus *b);
int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call);
int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority);
-int bus_kernel_open_bus_fd(const char *bus);
+int bus_kernel_open_bus_fd(const char *bus, char **path);
int bus_kernel_make_starter(int fd, const char *name, bool activating, bool accept_fd, BusNamePolicy *policy, BusNamePolicyAccess world_policy);
int bus_kernel_create_bus(const char *name, bool world, char **s);