|
@@ -62,18 +62,27 @@ void endpwent(void)
|
|
LOCK;
|
|
LOCK;
|
|
if (pw_fd > -1)
|
|
if (pw_fd > -1)
|
|
close(pw_fd);
|
|
close(pw_fd);
|
|
- pw_fd = -1;
|
|
+ pw_fd = -9;
|
|
UNLOCK;
|
|
UNLOCK;
|
|
}
|
|
}
|
|
|
|
|
|
int getpwent_r (struct passwd *password, char *buff,
|
|
int getpwent_r (struct passwd *password, char *buff,
|
|
- size_t buflen, struct passwd **result)
|
|
+ size_t buflen, struct passwd **result)
|
|
{
|
|
{
|
|
int ret=EINVAL;
|
|
int ret=EINVAL;
|
|
- LOCK;
|
|
|
|
*result = NULL;
|
|
*result = NULL;
|
|
|
|
|
|
- if ((ret=__getpwent_r(password, buff, buflen, pw_fd)) == 0) {
|
|
+ LOCK;
|
|
|
|
+
|
|
|
|
+ if (pw_fd == -9) {
|
|
|
|
+ setpwent();
|
|
|
|
+ }
|
|
|
|
+ if (pw_fd == -1) {
|
|
|
|
+ UNLOCK;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ ret=__getpwent_r(password, buff, buflen, pw_fd);
|
|
|
|
+ if (ret == 0) {
|
|
UNLOCK;
|
|
UNLOCK;
|
|
*result = password;
|
|
*result = password;
|
|
return 0;
|
|
return 0;
|
|
@@ -90,21 +99,10 @@ struct passwd *getpwent(void)
|
|
static struct passwd pwd;
|
|
static struct passwd pwd;
|
|
static char line_buff[PWD_BUFFER_SIZE];
|
|
static char line_buff[PWD_BUFFER_SIZE];
|
|
|
|
|
|
- LOCK;
|
|
+ ret = getpwent_r(&pwd, line_buff, sizeof(line_buff), &result);
|
|
-
|
|
|
|
- if (pw_fd == -9) {
|
|
|
|
- setpwent();
|
|
|
|
- }
|
|
|
|
- if (pw_fd == -1) {
|
|
|
|
- UNLOCK;
|
|
|
|
- return NULL;
|
|
|
|
- }
|
|
|
|
- ret=getpwent_r(&pwd, line_buff, sizeof(line_buff), &result);
|
|
|
|
if (ret == 0) {
|
|
if (ret == 0) {
|
|
- UNLOCK;
|
|
|
|
return &pwd;
|
|
return &pwd;
|
|
}
|
|
}
|
|
- UNLOCK;
|
|
|
|
__set_errno(ret);
|
|
__set_errno(ret);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|