summaryrefslogtreecommitdiff
path: root/libc/pwd_grp/getpwuid.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-06-27 10:43:43 +0000
committerEric Andersen <andersen@codepoet.org>2003-06-27 10:43:43 +0000
commit017c8132edae466e2892faec7ef6b834dfecbd34 (patch)
tree692c913a40337653fbcf9425e1551f2314ffc55b /libc/pwd_grp/getpwuid.c
parent2e55dec21f3310e6868689fc1f4c4074ea3a35bb (diff)
Yet more cleanup for the reentrant pwd/grp functions so they
should now actually be doing the right thing
Diffstat (limited to 'libc/pwd_grp/getpwuid.c')
-rw-r--r--libc/pwd_grp/getpwuid.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libc/pwd_grp/getpwuid.c b/libc/pwd_grp/getpwuid.c
index c54df0977..4a85aa289 100644
--- a/libc/pwd_grp/getpwuid.c
+++ b/libc/pwd_grp/getpwuid.c
@@ -37,16 +37,18 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
#endif
int getpwuid_r (uid_t uid, struct passwd *password,
- char *buff, size_t buflen, struct passwd **crap)
+ char *buff, size_t buflen, struct passwd **result)
{
int passwd_fd;
if ((passwd_fd = open(_PATH_PASSWD, O_RDONLY)) < 0)
return errno;
+ *result = NULL;
while (__getpwent_r(password, buff, buflen, passwd_fd) == 0)
if (password->pw_uid == uid) {
close(passwd_fd);
+ *result = password;
return 0;
}
@@ -60,9 +62,10 @@ struct passwd *getpwuid(uid_t uid)
/* file descriptor for the password file currently open */
static char line_buff[PWD_BUFFER_SIZE];
static struct passwd pwd;
+ struct passwd *result;
LOCK;
- if ((ret=getpwuid_r(uid, &pwd, line_buff, sizeof(line_buff), NULL)) == 0) {
+ if ((ret=getpwuid_r(uid, &pwd, line_buff, sizeof(line_buff), &result)) == 0) {
UNLOCK;
return &pwd;
}