summaryrefslogtreecommitdiffstats
path: root/libgfortran
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-10 18:42:34 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-10 18:42:34 +0000
commit34f4b81ffd100cade54f308cf28a2b07cba5d70e (patch)
treed863c9dbd5ed9572a7306a41426ddf45343735cf /libgfortran
parent19a230126c201c6aafe3b89a2484f374a254a0ef (diff)
downloadppe42-gcc-34f4b81ffd100cade54f308cf28a2b07cba5d70e.tar.gz
ppe42-gcc-34f4b81ffd100cade54f308cf28a2b07cba5d70e.zip
2012-10-10 Tobias Burnus <burnus@net-b.de>
PR fortran/54878 * io/unix.c (tempfile_open): Set umask before calling mkstemp. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192325 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog5
-rw-r--r--libgfortran/io/unix.c12
2 files changed, 17 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 74d6294b39d..d52648688f7 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-10 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/54878
+ * io/unix.c (tempfile_open): Set umask before calling mkstemp.
+
2012-10-06 Janne Blomqvist <jb@gcc.gnu.org>
* configure.ac: Check for presence of secure_getenv.
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 805d4bbd205..9d2e9d85087 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1051,6 +1051,9 @@ tempfile_open (const char *tempdir, char **fname)
{
int fd;
const char *slash = "/";
+#if defined(HAVE_UMASK) && defined(HAVE_MKSTEMP)
+ mode_t mode_mask;
+#endif
if (!tempdir)
return -1;
@@ -1072,8 +1075,17 @@ tempfile_open (const char *tempdir, char **fname)
snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX",
tempdir, slash);
+#ifdef HAVE_UMASK
+ /* Temporarily set the umask such that the file has 0600 permissions. */
+ mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
+#endif
+
fd = mkstemp (template);
+#ifdef HAVE_UMASK
+ (void) umask (mode_mask);
+#endif
+
#else /* HAVE_MKSTEMP */
fd = -1;
int count = 0;
OpenPOWER on IntegriCloud