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