summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-08-08 16:03:11 +0200
committerSven Eden <sven.eden@prydeworx.com>2018-10-29 10:18:38 +0100
commit151de03f030c95712301d3a4ac598255622d490b (patch)
treee8c8b046e62d8354cc7b369ce59ceb89d6280a96
parent675752d11fd2fd1708d42a90b618a9556688a20a (diff)
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)
-rw-r--r--src/login/logind-user.c10
1 files changed, 9 insertions, 1 deletions
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) {