From 788693d92fefe5a6cde1d876b7536c80552c48e4 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 10 Mar 1998 20:27:07 +0000 Subject: fchown() after unlink(), taking umask into account; std conformance according to casper@HOLLAND.SUN.COM --- lib/libc/stdio/tmpfile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c index 265ed26b2d8..7496c504738 100644 --- a/lib/libc/stdio/tmpfile.c +++ b/lib/libc/stdio/tmpfile.c @@ -35,7 +35,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: tmpfile.c,v 1.4 1997/04/03 05:31:38 millert Exp $"; +static char rcsid[] = "$OpenBSD: tmpfile.c,v 1.5 1998/03/10 20:27:06 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -62,8 +62,14 @@ tmpfile() (void)sigprocmask(SIG_BLOCK, &set, &oset); fd = mkstemp(buf); - if (fd != -1) + if (fd != -1) { + mode_t u; + (void)unlink(buf); + u = umask(0); + (void)umask(u); + (void)fchmod(fd, 0666 & ~u); + } (void)sigprocmask(SIG_SETMASK, &oset, NULL); -- cgit v1.2.3