diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-03-08 16:45:24 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-03-08 16:45:24 +0000 |
commit | 791312e7259153e1235f14a9a9e5cc6055ce8dfc (patch) | |
tree | 81f07808e6af9d42e92a4bba911b3b425f589516 /libc/pwd_grp/pwent.c | |
parent | bfb8f8f6ea438e632e808868c44af2bff196cc18 (diff) |
Reworked the password stuff to be reentrant. Group stuff is
still needing to be reworked.
-Erik
Diffstat (limited to 'libc/pwd_grp/pwent.c')
-rw-r--r-- | libc/pwd_grp/pwent.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libc/pwd_grp/pwent.c b/libc/pwd_grp/pwent.c index 475c8e560..6f81f1ea6 100644 --- a/libc/pwd_grp/pwent.c +++ b/libc/pwd_grp/pwent.c @@ -30,8 +30,12 @@ * link them all in together. */ +#define PWD_BUFFER_SIZE 256 + /* file descriptor for the password file currently open */ static int pw_fd = -1; +static char line_buff[PWD_BUFFER_SIZE]; +static struct passwd pwd; void setpwent(void) { @@ -48,9 +52,20 @@ void endpwent(void) pw_fd = -1; } +int getpwent_r (struct passwd *password, char *buff, + size_t buflen, struct passwd **crap) +{ + if (pw_fd != -1 && __getpwent_r(password, buff, buflen, pw_fd) != -1) { + return 0; + } + return -1; +} + struct passwd *getpwent(void) { - if (pw_fd != -1) - return (__getpwent(pw_fd)); - return NULL; + if (getpwent_r(&pwd, line_buff, PWD_BUFFER_SIZE, NULL) != -1) { + return &pwd; + } + return NULL; } + |