1570af302Sopenharmony_ci// commit 0afef1aa24b784c86ae6121ca39e999824086c7c
2570af302Sopenharmony_ci// preexisting errno should not be interpreted by passwd/group functions
3570af302Sopenharmony_ci
4570af302Sopenharmony_ci#include <pwd.h>
5570af302Sopenharmony_ci#include <errno.h>
6570af302Sopenharmony_ci#include "test.h"
7570af302Sopenharmony_ci
8570af302Sopenharmony_ciint main(void)
9570af302Sopenharmony_ci{
10570af302Sopenharmony_ci	int baderr = EOWNERDEAD; // arbitrary absurd error
11570af302Sopenharmony_ci	struct passwd *pw, pwbuf;
12570af302Sopenharmony_ci	char buf[1024];
13570af302Sopenharmony_ci	errno = baderr;
14570af302Sopenharmony_ci	if (getpwnam_r("nonsensical_user", &pwbuf, buf, sizeof buf, &pw) == baderr)
15570af302Sopenharmony_ci		t_error("getpwnam_r used preexisting errno for nonexisting user\n");
16570af302Sopenharmony_ci	return t_status;
17570af302Sopenharmony_ci}
18