Update to most recent Gnulib
[pspp-builds.git] / src / data / make-file.c
index f8719dc67223d6cd1f44be998f49632ac5bdf0ce..f5cda498a89358662965a01c2b5e44a39c5a707b 100644 (file)
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <errno.h>
 #include <stdio.h>
+#include <sys/stat.h>
 
 #include <data/file-name.h>
 #include <data/make-file.h>
@@ -176,7 +177,7 @@ replace_file_start (const char *file_name, const char *mode,
     {
       /* Generate unique temporary file name. */
       rf->tmp_name = xasprintf ("%s.tmpXXXXXX", file_name);
-      if (gen_tempname (rf->tmp_name, GT_NOCREATE) < 0)
+      if (gen_tempname (rf->tmp_name, 0600, GT_NOCREATE) < 0)
         {
           msg (ME, _("Creating temporary file to replace %s: %s."),
                rf->file_name, strerror (errno));
@@ -184,7 +185,7 @@ replace_file_start (const char *file_name, const char *mode,
         }
 
       /* Create file by that name. */
-      fd = open (rf->tmp_name, O_WRONLY | O_CREAT | O_EXCL, permissions);
+      fd = open (rf->tmp_name, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, permissions);
       if (fd >= 0)
         break;
       if (errno != EEXIST)