summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passwd/getgrent.c6
-rw-r--r--src/passwd/getpwent.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/passwd/getgrent.c b/src/passwd/getgrent.c
index e9d25eba..4cbe1ebf 100644
--- a/src/passwd/getgrent.c
+++ b/src/passwd/getgrent.c
@@ -23,17 +23,23 @@ struct group *getgrent()
struct group *getgrgid(gid_t gid)
{
struct group *gr;
+ int errno_saved;
setgrent();
while ((gr=getgrent()) && gr->gr_gid != gid);
+ errno_saved = errno;
endgrent();
+ errno = errno_saved;
return gr;
}
struct group *getgrnam(const char *name)
{
struct group *gr;
+ int errno_saved;
setgrent();
while ((gr=getgrent()) && strcmp(gr->gr_name, name));
+ errno_saved = errno;
endgrent();
+ errno = errno_saved;
return gr;
}
diff --git a/src/passwd/getpwent.c b/src/passwd/getpwent.c
index dabd411a..e8501461 100644
--- a/src/passwd/getpwent.c
+++ b/src/passwd/getpwent.c
@@ -23,17 +23,23 @@ struct passwd *getpwent()
struct passwd *getpwuid(uid_t uid)
{
struct passwd *pw;
+ int errno_saved;
setpwent();
while ((pw=getpwent()) && pw->pw_uid != uid);
+ errno_saved = errno;
endpwent();
+ errno = errno_saved;
return pw;
}
struct passwd *getpwnam(const char *name)
{
struct passwd *pw;
+ int errno_saved;
setpwent();
while ((pw=getpwent()) && strcmp(pw->pw_name, name));
+ errno_saved = errno;
endpwent();
+ errno = errno_saved;
return pw;
}