about summary refs log tree commit diff
path: root/src/passwd
diff options
context:
space:
mode:
Diffstat (limited to 'src/passwd')
-rw-r--r--src/passwd/getgr_r.c2
-rw-r--r--src/passwd/getgrent.c2
-rw-r--r--src/passwd/getpw_r.c2
-rw-r--r--src/passwd/getpwent.c2
-rw-r--r--src/passwd/getspnam_r.c4
5 files changed, 6 insertions, 6 deletions
diff --git a/src/passwd/getgr_r.c b/src/passwd/getgr_r.c
index 1dc5f7e0..234c9013 100644
--- a/src/passwd/getgr_r.c
+++ b/src/passwd/getgr_r.c
@@ -16,7 +16,7 @@ static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, siz
 
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
 
-	f = fopen("/etc/group", "rb");
+	f = fopen("/etc/group", "rbe");
 	if (!f) {
 		rv = errno;
 		goto done;
diff --git a/src/passwd/getgrent.c b/src/passwd/getgrent.c
index 4cbe1ebf..429a3e58 100644
--- a/src/passwd/getgrent.c
+++ b/src/passwd/getgrent.c
@@ -15,7 +15,7 @@ struct group *getgrent()
 	static char *line, **mem;
 	static struct group gr;
 	size_t size=0, nmem=0;
-	if (!f) f = fopen("/etc/group", "rb");
+	if (!f) f = fopen("/etc/group", "rbe");
 	if (!f) return 0;
 	return __getgrent_a(f, &gr, &line, &size, &mem, &nmem);
 }
diff --git a/src/passwd/getpw_r.c b/src/passwd/getpw_r.c
index 39744959..28552572 100644
--- a/src/passwd/getpw_r.c
+++ b/src/passwd/getpw_r.c
@@ -13,7 +13,7 @@ static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si
 
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
 
-	f = fopen("/etc/passwd", "rb");
+	f = fopen("/etc/passwd", "rbe");
 	if (!f) {
 		rv = errno;
 		goto done;
diff --git a/src/passwd/getpwent.c b/src/passwd/getpwent.c
index e8501461..c655135e 100644
--- a/src/passwd/getpwent.c
+++ b/src/passwd/getpwent.c
@@ -15,7 +15,7 @@ struct passwd *getpwent()
 	static char *line;
 	static struct passwd pw;
 	size_t size=0;
-	if (!f) f = fopen("/etc/passwd", "rb");
+	if (!f) f = fopen("/etc/passwd", "rbe");
 	if (!f) return 0;
 	return __getpwent_a(f, &pw, &line, &size);
 }
diff --git a/src/passwd/getspnam_r.c b/src/passwd/getspnam_r.c
index 9f3378e9..f4d7b35e 100644
--- a/src/passwd/getspnam_r.c
+++ b/src/passwd/getspnam_r.c
@@ -46,7 +46,7 @@ int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct
 	if (snprintf(path, sizeof path, "/etc/tcb/%s/shadow", name) >= sizeof path)
 		return EINVAL;
 
-	fd = open(path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK);
+	fd = open(path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK|O_CLOEXEC);
 	if (fd >= 0) {
 		struct stat st = { 0 };
 		errno = EINVAL;
@@ -57,7 +57,7 @@ int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct
 			return errno;
 		}
 	} else {
-		f = fopen("/etc/shadow", "rb");
+		f = fopen("/etc/shadow", "rbe");
 		if (!f) return errno;
 	}