From 937a355d6b16dae54468d0f2e5b6cc1b6392425d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 4 Jun 2025 18:14:52 +0900 Subject: [PATCH] userdb: make ENOEXEC wins over ESRCH 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shared/userdb.c b/src/shared/userdb.c index a5c72cfa5d..2238073e01 100644 --- a/src/shared/userdb.c +++ b/src/shared/userdb.c @@ -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);