From: Yu Watanabe Date: Wed, 4 Jun 2025 09:14:52 +0000 (+0900) Subject: userdb: make ENOEXEC wins over ESRCH X-Git-Tag: v258-rc1~396^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=937a355d6b16dae54468d0f2e5b6cc1b6392425d;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/userdb.c b/src/shared/userdb.c index a5c72cfa5da..2238073e01f 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);