]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
userdb: make ENOEXEC wins over ESRCH
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 4 Jun 2025 09:14:52 +0000 (18:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 4 Jun 2025 12:50:12 +0000 (21:50 +0900)
Both ENOEXEC and ESRCH is a kind of error that indicate successful
lookup. ENOEXEC means the server found an entry but it does not
pass filter. ESRCH means the server could not find an entry.
Hence, ENOEXEC should have more information, and should be propagated to
the caller.

src/shared/userdb.c

index a5c72cfa5dafb1d74b975d1988f4d57d1dfe56da..2238073e01f0c8fdad574bce147ffbf533afd33d 100644 (file)
@@ -427,9 +427,12 @@ static int userdb_on_query_reply(
         }
 
 finish:
-        /* If we got one ESRCH or ENOEXEC, let that win. This way when we do a wild dump we won't be tripped
-         * up by bad errors – as long as at least one connection ended somewhat cleanly */
-        if (IN_SET(r, -ESRCH, -ENOEXEC) || iterator->error == 0)
+        /* If we got one ENOEXEC, let that win. Similarly, ESRCH wins except for ENOEXEC. This way when we do
+         * a wild dump we won't be tripped up by bad errors – as long as at least one connection ended
+         * somewhat cleanly. */
+        if (r == -ENOEXEC ||
+            (r == -ESRCH && iterator->error != ENOEXEC) ||
+            iterator->error == 0)
                 iterator->error = -r;
 
         assert_se(set_remove(iterator->links, link) == link);