diff options
author | Ray Strode <rstrode@redhat.com> | 2007-03-02 19:28:54 +0000 |
---|---|---|
committer | Ray Strode <halfline@src.gnome.org> | 2007-03-02 19:28:54 +0000 |
commit | 55c1e2ba74c986699a710385a460e9a7293898d3 (patch) | |
tree | 633c23f706e753ee467e333a78c3ddfa6dab7b5a /backends/markup-tree.c | |
parent | 8c1eb0c0c18b85609c96c08860e3fb61f759f51a (diff) | |
download | gconf-55c1e2ba74c986699a710385a460e9a7293898d3.tar.gz |
Patch from Narayana Pattipati <narayana.pattipati@wipro.com>
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).
svn path=/trunk/; revision=2369
Diffstat (limited to 'backends/markup-tree.c')
-rw-r--r-- | backends/markup-tree.c | 22 |
1 files changed, 22 insertions, 0 deletions
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); |