forked from pool/dconf
Dominique Leuenberger
54095054b9
- Bring back 0001-gvdb-Restore-permissions-on-changed-files.patch since the useful fix was never merged to upstream (bsc#971074 bgo#758066 bsc#1203344). OBS-URL: https://build.opensuse.org/request/show/1003109 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/dconf?expand=0&rev=117
36 lines
875 B
Diff
36 lines
875 B
Diff
diff --git a/gvdb/gvdb-builder.c b/gvdb/gvdb-builder.c
|
|
index 90ea50b..cf5f1f4 100644
|
|
--- a/gvdb/gvdb-builder.c
|
|
+++ b/gvdb/gvdb-builder.c
|
|
@@ -21,6 +21,7 @@
|
|
#include "gvdb-format.h"
|
|
|
|
#include <glib.h>
|
|
+#include <glib/gstdio.h>
|
|
#include <fcntl.h>
|
|
#if !defined(G_OS_WIN32) || !defined(_MSC_VER)
|
|
#include <unistd.h>
|
|
@@ -509,13 +510,22 @@ gvdb_table_write_contents (GHashTable *table,
|
|
gboolean status;
|
|
FileBuilder *fb;
|
|
GString *str;
|
|
+ GStatBuf buf;
|
|
+ gint stat_ret;
|
|
|
|
fb = file_builder_new (byteswap);
|
|
file_builder_add_hash (fb, table, &root);
|
|
str = file_builder_serialise (fb, root);
|
|
|
|
+ stat_ret = g_stat (filename, &buf);
|
|
+
|
|
status = g_file_set_contents (filename, str->str, str->len, error);
|
|
g_string_free (str, TRUE);
|
|
|
|
+ if (stat_ret == 0)
|
|
+ g_chmod (filename, buf.st_mode);
|
|
+ else
|
|
+ g_chmod (filename, 0644);
|
|
+
|
|
return status;
|
|
}
|