sd-login,test-login: return -ENODATA from sd_pid_get_unit too

After all, we might be running on a non-systemd system.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-05-18 22:32:19 -04:00
parent ce737f46cd
commit 171f8f591f
2 changed files with 5 additions and 2 deletions

View File

@ -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) {

View File

@ -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);