summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--backends/markup-tree.c22
2 files changed, 31 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c7e46bd6..0f997524 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2007-03-02 Ray Strode <rstrode@redhat.com>
+ Patch from
+ Narayana Pattipati <narayana.pattipati@wipro.com>
+
+ * backends/markup-tree.c (save_tree):
+ transfer the file permissions and ownership after
+ rename (bug 314343).
+
+2007-03-02 Ray Strode <rstrode@redhat.com>
+
* gconf/gconf-value.c (gconf_value_new_from_string):
Check that type isn't a container type, since there
would be no way to know what the type of its elements
diff --git a/backends/markup-tree.c b/backends/markup-tree.c
index 816d4cab..645d0d49 100644
--- a/backends/markup-tree.c
+++ b/backends/markup-tree.c
@@ -4359,6 +4359,7 @@ save_tree_with_locale (MarkupDir *dir,
char *err_str;
gboolean write_failed;
GSList *tmp;
+ struct stat st;
write_failed = FALSE;
err_str = NULL;
@@ -4489,6 +4490,9 @@ save_tree_with_locale (MarkupDir *dir,
target_renamed = (g_rename (filename, tmp_filename) == 0);
#endif
+ if (g_stat (filename, &st) != 0)
+ goto out;
+
if (g_rename (new_filename, filename) < 0)
{
err_str = g_strdup_printf (_("Failed to move temporary file \"%s\" to final location \"%s\": %s"),
@@ -4499,6 +4503,24 @@ save_tree_with_locale (MarkupDir *dir,
#endif
goto out;
}
+#ifndef G_OS_WIN32
+ else
+ {
+ /* Restore permissions. There is not much error checking we can do
+ * here. The final data is saved anyways. Note the order:
+ * mode, uid+gid, gid, uid, mode.
+ */
+ chmod (filename, st.st_mode);
+ if (chown (filename, st.st_uid, st.st_gid) < 0)
+ {
+ /* We cannot set both. Maybe we can set one. */
+ chown (filename, -1, st.st_gid);
+ chown (filename, st.st_uid, -1);
+ }
+ chmod (filename, st.st_mode);
+ }
+#endif
+
#ifdef G_OS_WIN32
if (target_renamed)
g_remove (tmp_filename);