about summary refs log tree commit diff
path: root/src/passwd/getpwent.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/passwd/getpwent.c')
-rw-r--r--src/passwd/getpwent.c6
1 files changed, 6 insertions, 0 deletions
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;
 }