regression tests for bugs in first versions of new passwd code
[libc-test.git] / src / regression / getpwnam_r-errno.c
blobbb8685ee431f3279c924e67dc49a1b261fda10dc
1 // commit 0afef1aa24b784c86ae6121ca39e999824086c7c
2 // preexisting errno should not be interpreted by passwd/group functions
4 #include <pwd.h>
5 #include <errno.h>
6 #include "test.h"
8 int main(void)
10 int baderr = EOWNERDEAD; // arbitrary absurd error
11 struct passwd *pw, pwbuf;
12 char buf[1024];
13 errno = baderr;
14 if (getpwnam_r("nonsensical_user", &pwbuf, buf, sizeof buf, &pw) == baderr)
15 t_error("getpwnam_r used preexisting errno for nonexisting user\n");
16 return t_status;