diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-06-12 23:27:00 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-06-12 23:27:00 +0000 |
commit | c617db9065afa51100199d9ac4561feee4279291 (patch) | |
tree | e4a90725f73b9fb7ec9970ca495172181acfa873 /libc/pwd_grp/getpwnam.c | |
parent | fd6b9378be20243eaea7da1c2ddb3d68f123d28e (diff) |
Silence warnings, clean things up.
-Erik
Diffstat (limited to 'libc/pwd_grp/getpwnam.c')
-rw-r--r-- | libc/pwd_grp/getpwnam.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/libc/pwd_grp/getpwnam.c b/libc/pwd_grp/getpwnam.c index 36f6f0942..b0674b15d 100644 --- a/libc/pwd_grp/getpwnam.c +++ b/libc/pwd_grp/getpwnam.c @@ -22,43 +22,38 @@ #include <string.h> #include <errno.h> #include <fcntl.h> -#include <pwd.h> #include <paths.h> #include "config.h" -#define PWD_BUFFER_SIZE 256 - -/* file descriptor for the password file currently open */ -static char line_buff[PWD_BUFFER_SIZE]; -static struct passwd pwd; - - int getpwnam_r (const char *name, struct passwd *password, char *buff, size_t buflen, struct passwd **crap) { - int passwd_fd; + int passwd_fd; - if (name == NULL) { - __set_errno(EINVAL); - return -1; - } + if (name == NULL) { + __set_errno(EINVAL); + return -1; + } - if ((passwd_fd = open(_PATH_PASSWD, O_RDONLY)) < 0) - return -1; + if ((passwd_fd = open(_PATH_PASSWD, O_RDONLY)) < 0) + return -1; - while (__getpwent_r(password, buff, buflen, passwd_fd) != -1) - if (!strcmp(password->pw_name, name)) { - close(passwd_fd); - return 0; - } + while (__getpwent_r(password, buff, buflen, passwd_fd) != -1) + if (!strcmp(password->pw_name, name)) { + close(passwd_fd); + return 0; + } - close(passwd_fd); - return -1; + close(passwd_fd); + return -1; } struct passwd *getpwnam(const char *name) { - if (getpwnam_r(name, &pwd, line_buff, PWD_BUFFER_SIZE, NULL) != -1) { + static char line_buff[PWD_BUFFER_SIZE]; + static struct passwd pwd; + + if (getpwnam_r(name, &pwd, line_buff, sizeof(line_buff), NULL) != -1) { return &pwd; } return NULL; |