diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-03-23 05:18:34 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-03-23 05:18:34 +0000 |
commit | 4e21c272d514bc954a5e22ee8b968e372ad92887 (patch) | |
tree | d54728c57a95df609da5d44864aa7e9fc994533e /lib | |
parent | 0f6a0fd938026e4dee885e50f59b4a935061a465 (diff) |
test re-entrant getpwnam_r
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc_r/TEST/test_pw.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libc_r/TEST/test_pw.c b/lib/libc_r/TEST/test_pw.c index 1bf41d7723c..cc23e6f4f4f 100644 --- a/lib/libc_r/TEST/test_pw.c +++ b/lib/libc_r/TEST/test_pw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_pw.c,v 1.4 2000/01/06 06:58:34 d Exp $ */ +/* $OpenBSD: test_pw.c,v 1.5 2000/03/23 05:18:33 d Exp $ */ #include <stdio.h> #include <sys/types.h> #include <unistd.h> @@ -9,6 +9,9 @@ int main() { struct passwd *pw; + struct passwd pwbuf; + char buf[8192]; + char name[16]; CHECKn(pw = getpwuid(getuid())); printf("getpwuid(%d) => %p\n", getuid(), pw); @@ -16,5 +19,10 @@ main() "class: %s\ngecos: %s\n dir: %s\nshell: %s\n", pw->pw_name, pw->pw_uid, pw->pw_gid, pw->pw_class, pw->pw_gecos, pw->pw_dir, pw->pw_shell); + + strlcpy(name, pw->pw_name, sizeof name); + CHECKe(getpwnam_r(name, &pwbuf, buf, sizeof buf, &pw)); + ASSERT(pwbuf.pw_uid == getuid()); + SUCCEED; } |