X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fpasswd%2Fgetpwent.c;h=f2bd516e57ba3261ab94c6081f692f77aaea4f47;hb=0847902ab99065a48f9bd3729b6e676288dfd69e;hp=dabd411ab987730b649ed765baead9bfb1c7d880;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/passwd/getpwent.c b/src/passwd/getpwent.c index dabd411a..f2bd516e 100644 --- a/src/passwd/getpwent.c +++ b/src/passwd/getpwent.c @@ -1,6 +1,9 @@ #include "pwf.h" static FILE *f; +static char *line; +static struct passwd pw; +static size_t size; void setpwent() { @@ -12,28 +15,23 @@ weak_alias(setpwent, endpwent); struct passwd *getpwent() { - static char *line; - static struct passwd pw; - size_t size=0; - if (!f) f = fopen("/etc/passwd", "rb"); + struct passwd *res; + if (!f) f = fopen("/etc/passwd", "rbe"); if (!f) return 0; - return __getpwent_a(f, &pw, &line, &size); + __getpwent_a(f, &pw, &line, &size, &res); + return res; } struct passwd *getpwuid(uid_t uid) { - struct passwd *pw; - setpwent(); - while ((pw=getpwent()) && pw->pw_uid != uid); - endpwent(); - return pw; + struct passwd *res; + __getpw_a(0, uid, &pw, &line, &size, &res); + return res; } struct passwd *getpwnam(const char *name) { - struct passwd *pw; - setpwent(); - while ((pw=getpwent()) && strcmp(pw->pw_name, name)); - endpwent(); - return pw; + struct passwd *res; + __getpw_a(name, 0, &pw, &line, &size, &res); + return res; }