diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-03-10 20:27:07 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-03-10 20:27:07 +0000 |
commit | 788693d92fefe5a6cde1d876b7536c80552c48e4 (patch) | |
tree | a32f2c835ddd734f546f3850efc647159713b52f /lib/libc/stdio | |
parent | a534f884503c2bcc4872322f7c860c499527f999 (diff) |
fchown() after unlink(), taking umask into account; std conformance according to casper@HOLLAND.SUN.COM
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/tmpfile.c | 10 |
1 files 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 <sys/types.h> @@ -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); |