summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-login
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-05-18 22:32:19 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-05-18 22:32:19 -0400
commit171f8f591ff27ebb5ff475b7a9d1f13a846c9331 (patch)
tree0921e2e6540cdf2ff3b574d0304af51215649f92 /src/libsystemd/sd-login
parentce737f46cd8aa8bfa0b586d0a821c815835000ab (diff)
downloadsystemd-171f8f591ff27ebb5ff475b7a9d1f13a846c9331.tar.gz
sd-login,test-login: return -ENODATA from sd_pid_get_unit too
After all, we might be running on a non-systemd system.
Diffstat (limited to 'src/libsystemd/sd-login')
-rw-r--r--src/libsystemd/sd-login/sd-login.c4
-rw-r--r--src/libsystemd/sd-login/test-login.c3
2 files changed, 5 insertions, 2 deletions
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
index cd844b3105..82a94bfd5c 100644
--- a/src/libsystemd/sd-login/sd-login.c
+++ b/src/libsystemd/sd-login/sd-login.c
@@ -66,11 +66,13 @@ _public_ int sd_pid_get_session(pid_t pid, char **session) {
}
_public_ int sd_pid_get_unit(pid_t pid, char **unit) {
+ int r;
assert_return(pid >= 0, -EINVAL);
assert_return(unit, -EINVAL);
- return cg_pid_get_unit(pid, unit);
+ r = cg_pid_get_unit(pid, unit);
+ return r == -ENXIO ? -ENODATA : r;
}
_public_ int sd_pid_get_user_unit(pid_t pid, char **unit) {
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
index fb7d4e2ece..6889d2f0b4 100644
--- a/src/libsystemd/sd-login/test-login.c
+++ b/src/libsystemd/sd-login/test-login.c
@@ -59,7 +59,8 @@ static void test_login(void) {
uid_t u, u2;
char *t, **seats, **sessions;
- assert_se(sd_pid_get_unit(0, &unit) >= 0);
+ r = sd_pid_get_unit(0, &unit);
+ assert_se(r >= 0 || r == -ENODATA);
log_info("sd_pid_get_unit(0, …) → \"%s\"", unit);
r = sd_pid_get_user_unit(0, &user_unit);