]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: improve error propagation of user_check_linger_file()
authorLennart Poettering <lennart@poettering.net>
Wed, 8 Aug 2018 14:03:11 +0000 (16:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 13 Oct 2018 10:59:29 +0000 (12:59 +0200)
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)

src/login/logind-user.c

index e92f2a5243f04debdf93737ba61988b73a744c27..230c8f392d5485ded4186127b9a734c6dfa1b915 100644 (file)
@@ -530,8 +530,14 @@ int user_check_linger_file(User *u) {
                 return -ENOMEM;
 
         p = strjoina("/var/lib/systemd/linger/", cc);
+        if (access(p, F_OK) < 0) {
+                if (errno != ENOENT)
+                        return -errno;
 
-        return access(p, F_OK) >= 0;
+                return false;
+        }
+
+        return true;
 }
 
 bool user_may_gc(User *u, bool drop_not_started) {