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