From: WanBingjiang Date: Wed, 29 Apr 2026 07:01:23 +0000 (+0800) Subject: test_sigreceive: use ul_getuserpw_str() for user name/UID parsing X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3d39999213a5c133d3fa43aae132e34933763493;p=thirdparty%2Futil-linux.git test_sigreceive: use ul_getuserpw_str() for user name/UID parsing --- diff --git a/tests/helpers/test_sigreceive.c b/tests/helpers/test_sigreceive.c index 8f83e0594..59a2f5111 100644 --- a/tests/helpers/test_sigreceive.c +++ b/tests/helpers/test_sigreceive.c @@ -16,7 +16,7 @@ #include #include -#include "strutils.h" +#include "pwdutils.h" #define TEST_SIGRECEIVE_FAILURE 0 @@ -63,14 +63,11 @@ int main(int argc, char **argv) } if (user) { - struct passwd *pw; uid_t uid; - pw = getpwnam(user); - if (pw) - uid = pw->pw_uid; - else - uid = strtou32_or_err(user, "failed to parse uid"); + ul_getuserpw_str(user, &uid); + if (uid == (uid_t)-1) + errx(TEST_SIGRECEIVE_FAILURE, "failed to parse uid: %s", user); if (setuid(uid) < 0) err(TEST_SIGRECEIVE_FAILURE, "setuid failed"); }