From 6337aa05846d8e158c028c313a8eee6502d76fd8 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 13:02:51 -0800 Subject: [PATCH] testsuite: allow t/src/getpwuid.c to compile against musl Problem: musl libc doesn't have fgetpwent_r(3), so compilation of t/src/getpwuid.c fails. The program is not multithreaded, so switch to fgetpwent(3) and getpwuid(3). --- t/src/getpwuid.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/t/src/getpwuid.c b/t/src/getpwuid.c index 3c09bc9e..f457d77d 100644 --- a/t/src/getpwuid.c +++ b/t/src/getpwuid.c @@ -24,14 +24,12 @@ struct passwd *getpwuid (uid_t uid) { const char *filename; - static char buf[4096]; - static struct passwd pw; struct passwd *pwp = NULL; if ((filename = getenv ("TEST_PASSWD_FILE"))) { FILE *f; if ((f = fopen (filename, "r"))) { - while (fgetpwent_r (f, &pw, buf, sizeof (buf), &pwp) == 0) { + while ((pwp = fgetpwent (f))) { if (pwp->pw_uid == uid) break; } @@ -39,7 +37,7 @@ struct passwd *getpwuid (uid_t uid) } } else - getpwuid_r (uid, &pw, buf, sizeof (buf), &pwp); + pwp = getpwuid (uid); if (pwp == NULL) errno = ENOENT;