logind: improve error propagation of user_check_linger_file()

Let's make this a bit prettier, and propagate unexpected access() errors
correctly.

(The callers of this function will suppress them, but it's nicer of they
do that, rather than us doing that twice in both the callers and the
callees)
This commit is contained in:
Lennart Poettering 2018-08-08 16:03:11 +02:00
parent d5ac9d0602
commit 6996df9b86
1 changed files with 7 additions and 1 deletions

View File

@ -530,8 +530,14 @@ int user_check_linger_file(User *u) {
return -ENOMEM;
p = strjoina("/var/lib/systemd/linger/", cc);
if (access(p, F_OK) < 0) {
if (errno != ENOENT)
return -errno;
return access(p, F_OK) >= 0;
return false;
}
return true;
}
bool user_may_gc(User *u, bool drop_not_started) {