From 0595609018095dabd5d1a56cf03ddcc008a9e928 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Apr 2008 17:47:28 -0400 Subject: [PATCH] set umask before calling mkstemp This is a POSIX portability thing. Restore the original umask after. --- sponge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sponge.c b/sponge.c index d232b5d..dcd4aba 100644 --- a/sponge.c +++ b/sponge.c @@ -219,14 +219,16 @@ static void copy_tmpfile(FILE *tmpfile, FILE *outfd) { } FILE *open_tmpfile(void) { - /* umask(077); FIXME: Should we be setting umask, or using default? */ struct cs_status cs; int tmpfd; FILE *tmpfile; + mode_t mask; trapsignals(); cs = cs_enter(); + mask=umask(077); tmpfd = mkstemp(tmpname); + umask(mask); atexit(onexit_cleanup); // solaris on_exit(onexit_cleanup, 0); cs_leave(cs); if (tmpfd < 0) { -- 2.39.5