SHA256
1
0
forked from pool/dconf
dconf/0001-gvdb-Restore-permissions-on-changed-files.patch
Dominique Leuenberger 58d4574fd0 Accepting request 483857 from home:zhangxiaofei:branches:GNOME:Factory
- Update 0001-gvdb-Restore-permissions-on-changed-files.patch:
  'dconf update' should set permissions to 0644 on restored missing
  db files, despite of the umask setting (bsc#1025721, bsc#971074,
  bgo#758066).

OBS-URL: https://build.opensuse.org/request/show/483857
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/dconf?expand=0&rev=93
2017-04-24 08:38:17 +00:00

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;
}