summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-10-14 12:15:58 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-10-14 18:28:30 +0200
commitab4a88eb920e2f64a79a60c1ea9aecb7907a9635 (patch)
treea6e19b63960b0ec77ee06159e22a57dda28d45e7 /src/libsystemd
parent165fee860a384b2e1ea4317551bc4463b3d53b61 (diff)
downloadsystemd-ab4a88eb920e2f64a79a60c1ea9aecb7907a9635.tar.gz
sd-bus: add custom return code when $XDG_RUNTIME_DIR is not set
We would return ENOENT, which is extremely confusing. Strace is not helpful because no *file* is actually missing. So let's add some logs at debug level and also use a custom return code. Let all user-facing utilities print a custom error message in that case.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c3
-rw-r--r--src/libsystemd/sd-bus/test-bus-cleanup.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-track.c2
3 files changed, 4 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index c602088cf8..daae8aaa6a 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -1340,7 +1340,8 @@ int bus_set_address_user(sd_bus *b) {
e = secure_getenv("XDG_RUNTIME_DIR");
if (!e)
- return -ENOENT;
+ return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM),
+ "sd-bus: $XDG_RUNTIME_DIR not set, cannot connect to user bus.");
ee = bus_address_escape(e);
if (!ee)
diff --git a/src/libsystemd/sd-bus/test-bus-cleanup.c b/src/libsystemd/sd-bus/test-bus-cleanup.c
index 99d335e3fc..86a2407507 100644
--- a/src/libsystemd/sd-bus/test-bus-cleanup.c
+++ b/src/libsystemd/sd-bus/test-bus-cleanup.c
@@ -23,7 +23,7 @@ static int test_bus_open(void) {
int r;
r = sd_bus_open_user(&bus);
- if (IN_SET(r, -ECONNREFUSED, -ENOENT)) {
+ if (IN_SET(r, -ECONNREFUSED, -ENOENT, -ENOMEDIUM)) {
r = sd_bus_open_system(&bus);
if (IN_SET(r, -ECONNREFUSED, -ENOENT))
return r;
diff --git a/src/libsystemd/sd-bus/test-bus-track.c b/src/libsystemd/sd-bus/test-bus-track.c
index 68a0010368..5adcf948dd 100644
--- a/src/libsystemd/sd-bus/test-bus-track.c
+++ b/src/libsystemd/sd-bus/test-bus-track.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
assert_se(r >= 0);
r = sd_bus_open_user(&a);
- if (IN_SET(r, -ECONNREFUSED, -ENOENT)) {
+ if (IN_SET(r, -ECONNREFUSED, -ENOENT, -ENOMEDIUM)) {
r = sd_bus_open_system(&a);
if (IN_SET(r, -ECONNREFUSED, -ENOENT))
return log_tests_skipped("Failed to connect to bus");