Bug 594034 - Use g_mkstemp_full() when creating the replacement file
authorBenjamin Otte <otte@gnome.org>
Thu, 3 Sep 2009 13:39:57 +0000 (15:39 +0200)
committerBenjamin Otte <otte@gnome.org>
Fri, 4 Sep 2009 20:45:57 +0000 (22:45 +0200)
Previous code used g_mkstemp(). But when using
G_FILE_CREATE_REPLACE_DESTINATION, no attempt was made to ensure proper
mode and flags of the created temporary file. The visible issue was that
the file was always created with mode 0600 as opposed to using 0666.
(The invisible issue was that O_RDWR was used instead of O_WRONLY.)

docs/reference/glib/tmpl/glib-unused.sgml
docs/reference/glib/tmpl/macros_misc.sgml
docs/reference/glib/tmpl/misc_utils.sgml
docs/reference/glib/tmpl/version.sgml
gio/glocalfileoutputstream.c

index ca73e16e9179afb083454e533427b03e6b8d00d1..139c5004a03a6a5fc6e48823021f468abfa84750 100644 (file)
@@ -900,6 +900,73 @@ Turns the argument into a string literal by using the '#' stringizing operator.
 </para>
 
 
+<!-- ##### VARIABLE glib_binary_age ##### -->
+<para>
+This is the binary age passed to <application>libtool</application>. If 
+<application>libtool</application> means nothing to you, don't worry 
+about it. ;-)
+</para>
+
+
+<!-- ##### FUNCTION glib_check_version ##### -->
+<para>
+
+</para>
+
+@required_major: 
+@required_minor: 
+@required_micro: 
+@Returns: 
+
+<!-- ##### VARIABLE glib_interface_age ##### -->
+<para>
+This is the interface age passed to <application>libtool</application>. If 
+<application>libtool</application> means nothing to you, don't worry 
+about it. ;-)
+</para>
+
+
+<!-- ##### VARIABLE glib_major_version ##### -->
+<para>
+The major version number of the GLib library. 
+(e.g. in GLib version 1.2.5 this is 1.)
+</para>
+
+<para>
+This variable is in the library, so represents the
+GLib library you have linked against. Contrast with the
+#GLIB_MAJOR_VERSION macro, which represents the major version of the
+GLib headers you have included.
+</para>
+
+
+<!-- ##### VARIABLE glib_micro_version ##### -->
+<para>
+The micro version number of the GLib library.
+(e.g. in GLib version 1.2.5 this is 5.)
+</para>
+
+<para>
+This variable is in the library, so represents the GLib library you
+have linked against. Contrast with the #GLIB_MICRO_VERSION macro, which
+represents the micro version of the GLib headers you have included.
+</para>
+
+
+<!-- ##### VARIABLE glib_minor_version ##### -->
+<para>
+The minor version number of the GLib library.
+(e.g. in GLib version 1.2.5 this is 2.)
+</para>
+
+<para>
+This variable is in the library, so represents the
+GLib library you have linked against. Contrast with the
+#GLIB_MINOR_VERSION macro, which represents the minor version of the
+GLib headers you have included.
+</para>
+
+
 <!-- ##### MACRO lseek ##### -->
 <para>
 
index 39445574ca8dfa02abe0db91af419e602b66620b..a8b0bcabccb4c0efc17097147eed356769c6c28f 100644 (file)
@@ -403,7 +403,7 @@ Since: 2.14
 
 
 
-<!-- ##### FUNCTION G_LIKELY ##### -->
+<!-- ##### MACRO G_LIKELY ##### -->
 <para>
 Hints the compiler that the expression is likely to evaluate to a true
 value. The compiler may use this information for optimizations.
@@ -413,10 +413,9 @@ if (G_LIKELY (random () != 1))
   g_print ("not one");
 </programlisting></informalexample>
 
+@expr: the expression
 @Returns: the value of @expr
 @Since: 2.2
-<!-- # Unused Parameters # -->
-@expr: the expression
 
 
 <!-- ##### MACRO G_UNLIKELY ##### -->
index 8038d8c977b701d57d4094728998eb67780b6b9e..9cfb65f5aff17ba7067d3131122d0614299a85cf 100644 (file)
@@ -165,6 +165,13 @@ These are portable utility functions.
 @Returns: 
 
 
+<!-- ##### FUNCTION g_reload_user_special_dirs_cache ##### -->
+<para>
+
+</para>
+
+
+
 <!-- ##### FUNCTION g_get_host_name ##### -->
 <para>
 
index f46c1e1a59fc471cc4c90f7583b4dd9476491119..b1cf0bb6fca93d2953f3e294b00f4efcebc9de61 100644 (file)
@@ -19,74 +19,6 @@ typically use the features described here.
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### VARIABLE glib_major_version ##### -->
-<para>
-The major version number of the GLib library. 
-(e.g. in GLib version 1.2.5 this is 1.)
-</para>
-
-<para>
-This variable is in the library, so represents the
-GLib library you have linked against. Contrast with the
-#GLIB_MAJOR_VERSION macro, which represents the major version of the
-GLib headers you have included.
-</para>
-
-
-<!-- ##### VARIABLE glib_minor_version ##### -->
-<para>
-The minor version number of the GLib library.
-(e.g. in GLib version 1.2.5 this is 2.)
-</para>
-
-<para>
-This variable is in the library, so represents the
-GLib library you have linked against. Contrast with the
-#GLIB_MINOR_VERSION macro, which represents the minor version of the
-GLib headers you have included.
-</para>
-
-
-<!-- ##### VARIABLE glib_micro_version ##### -->
-<para>
-The micro version number of the GLib library.
-(e.g. in GLib version 1.2.5 this is 5.)
-</para>
-
-<para>
-This variable is in the library, so represents the GLib library you
-have linked against. Contrast with the #GLIB_MICRO_VERSION macro, which
-represents the micro version of the GLib headers you have included.
-</para>
-
-
-<!-- ##### VARIABLE glib_binary_age ##### -->
-<para>
-This is the binary age passed to <application>libtool</application>. If 
-<application>libtool</application> means nothing to you, don't worry 
-about it. ;-)
-</para>
-
-
-<!-- ##### VARIABLE glib_interface_age ##### -->
-<para>
-This is the interface age passed to <application>libtool</application>. If 
-<application>libtool</application> means nothing to you, don't worry 
-about it. ;-)
-</para>
-
-
-<!-- ##### FUNCTION glib_check_version ##### -->
-<para>
-
-</para>
-
-@required_major: 
-@required_minor: 
-@required_micro: 
-@Returns: 
-
-
 <!-- ##### MACRO GLIB_MAJOR_VERSION ##### -->
 <para>
 The major version number of the GLib library.
index 79872117e3f4f7d1cd114c209eb4133421ed0c8e..7ab8a08da086a6f4fdc7e9deb9b8fbd702d9bb39 100644 (file)
@@ -867,7 +867,7 @@ handle_overwrite_open (const char    *filename,
       tmp_filename = g_build_filename (dirname, ".goutputstream-XXXXXX", NULL);
       g_free (dirname);
 
-      tmpfd = g_mkstemp (tmp_filename);
+      tmpfd = g_mkstemp_full (tmp_filename, (readable ? O_RDWR : O_WRONLY) | O_BINARY, mode);
       if (tmpfd == -1)
        {
          g_free (tmp_filename);