From d712dd396d7d69686f7001fd986bfc59217b72dd Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 29 Sep 2012 18:14:46 -0400 Subject: more close-on-exec fixes, mostly using new "e" flag to fopen --- src/passwd/getspnam_r.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/passwd/getspnam_r.c') 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; } -- cgit v1.2.1