698723
From 117ed6bd7aa71fc79599e1d37bdb4a94b3505a38 Mon Sep 17 00:00:00 2001
698723
From: Lennart Poettering <lennart@poettering.net>
698723
Date: Wed, 8 Aug 2018 16:03:11 +0200
698723
Subject: [PATCH] logind: improve error propagation of user_check_linger_file()
698723
698723
Let's make this a bit prettier, and propagate unexpected access() errors
698723
correctly.
698723
698723
(The callers of this function will suppress them, but it's nicer of they
698723
do that, rather than us doing that twice in both the callers and the
698723
callees)
698723
698723
(cherry picked from commit 6996df9b864981980f5b713dc5c7d506a7a4b9bf)
698723
698723
Related: #1642460
698723
---
698723
 src/login/logind-user.c | 8 +++++++-
698723
 1 file changed, 7 insertions(+), 1 deletion(-)
698723
698723
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
698723
index 70f5eb9d59..3fd28fc66c 100644
698723
--- a/src/login/logind-user.c
698723
+++ b/src/login/logind-user.c
698723
@@ -532,8 +532,14 @@ int user_check_linger_file(User *u) {
698723
                 return -ENOMEM;
698723
 
698723
         p = strjoina("/var/lib/systemd/linger/", cc);
698723
+        if (access(p, F_OK) < 0) {
698723
+                if (errno != ENOENT)
698723
+                        return -errno;
698723
 
698723
-        return access(p, F_OK) >= 0;
698723
+                return false;
698723
+        }
698723
+
698723
+        return true;
698723
 }
698723
 
698723
 bool user_may_gc(User *u, bool drop_not_started) {