diff options
| author | sborrill <sborrill@NetBSD.org> | 2008-11-28 19:39:00 +0000 |
|---|---|---|
| committer | sborrill <sborrill@NetBSD.org> | 2008-11-28 19:39:00 +0000 |
| commit | 8e03e5a4c8efd39ddfdb0840216c95fb201c4396 (patch) | |
| tree | 558a2ecff1d541d80c993f3f7628bb60022215c3 /distrib/utils/libhack | |
| parent | 67fb7f0d5cdb41898fe67037cbd79ef2a2efa401 (diff) | |
Add cut-down getpwent_r() to join existing getpwent() and friends. This
fixes PR 40003
Diffstat (limited to 'distrib/utils/libhack')
| -rw-r--r-- | distrib/utils/libhack/getpwent.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/distrib/utils/libhack/getpwent.c b/distrib/utils/libhack/getpwent.c index 5366bd667a7..6dfdae30d19 100644 --- a/distrib/utils/libhack/getpwent.c +++ b/distrib/utils/libhack/getpwent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getpwent.c,v 1.9 2005/03/31 12:56:49 he Exp $ */ +/* $NetBSD: getpwent.c,v 1.10 2008/11/28 19:39:00 sborrill Exp $ */ /* * Copyright (c) 1987, 1988, 1989, 1993, 1994, 1995 @@ -40,6 +40,7 @@ #ifdef __weak_alias #define endpwent _endpwent #define getpwent _getpwent +#define getpwent_r _getpwent_r #define getpwuid _getpwuid #define getpwnam _getpwnam #define setpwent _setpwent @@ -49,6 +50,7 @@ __weak_alias(endpwent,_endpwent) __weak_alias(getpwent,_getpwent) +__weak_alias(getpwent_r,_getpwent_r) __weak_alias(getpwuid,_getpwuid) __weak_alias(getpwnam,_getpwnam) __weak_alias(setpwent,_setpwent) @@ -90,6 +92,22 @@ getpwent(void) return (&_pw_passwd); } +int +getpwent_r(struct passwd *pwres, char *buf, size_t bufsiz, + struct passwd **pwd) +{ + int rval; + + if (!_pw_fp && !pwstart()) + return 1; + rval = !pwscan(0, 0, NULL, pwres, buf, bufsiz); + if (rval) + *pwd = NULL; + else + *pwd = pwres; + return rval; +} + struct passwd * getpwnam(const char *name) { |
