diff --git a/glib/gfileutils.c b/glib/gfileutils.c index a62db6696..94083a22b 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -1362,9 +1362,13 @@ g_file_set_contents_full (const gchar *filename, GError *rename_error = NULL; gboolean retval; int fd; - gboolean do_fsync; + gboolean do_fsync, maintain_perms; GStatBuf old_stat; + maintain_perms = !g_stat (filename, &old_stat); + if (maintain_perms) + mode = 0600; + tmp_filename = g_strdup_printf ("%s.XXXXXX", filename); errno = 0; @@ -1382,7 +1386,7 @@ g_file_set_contents_full (const gchar *filename, } /* Maintain the permissions of the file if it exists */ - if (!g_stat (filename, &old_stat)) + if (maintain_perms) { #ifndef G_OS_WIN32 if (fchmod (fd, old_stat.st_mode))