From 151de03f030c95712301d3a4ac598255622d490b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 8 Aug 2018 16:03:11 +0200 Subject: 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) (cherry picked from commit 6996df9b864981980f5b713dc5c7d506a7a4b9bf) --- src/login/logind-user.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/login/logind-user.c') diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 8cc407c20..7ab3e7513 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -362,6 +362,7 @@ static void user_start_service(User *u) { * start the per-user slice or the elogind-runtime-dir@.service instance, as those are pulled in both by * start the per-user slice or the elogind-runtime-dir@.service instance, as those are pulled in both by * start the per-user slice or the elogind-runtime-dir@.service instance, as those are pulled in both by + * start the per-user slice or the elogind-runtime-dir@.service instance, as those are pulled in both by * user@.service and the session scopes as dependencies. */ hashmap_put(u->manager->user_units, u->service, u); @@ -403,6 +404,7 @@ int user_start(User *u) { * elogind --user. We need to do user_save_internal() because we have not "officially" started yet. */ * elogind --user. We need to do user_save_internal() because we have not "officially" started yet. */ * elogind --user. We need to do user_save_internal() because we have not "officially" started yet. */ + * elogind --user. We need to do user_save_internal() because we have not "officially" started yet. */ user_save_internal(u); /* Spawn user systemd */ @@ -610,8 +612,14 @@ int user_check_linger_file(User *u) { return -ENOMEM; p = strjoina("/var/lib/elogind/linger/", cc); + if (access(p, F_OK) < 0) { + if (errno != ENOENT) + return -errno; + + return false; + } - return access(p, F_OK) >= 0; + return true; } bool user_may_gc(User *u, bool drop_not_started) { -- cgit v1.2.3