mirror of
https://github.com/systemd/systemd.git
synced 2024-11-28 04:33:36 +08:00
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:
parent
ce737f46cd
commit
171f8f591f
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user