From c6ae459cd500e6e7bd8c845a407e1573e98a31cf Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 18 Oct 2014 21:26:38 +0100 Subject: [PATCH] Set file permissions for preferences file --- src/config/preferences.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/config/preferences.c b/src/config/preferences.c index cad30cfb..63c226f6 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -39,6 +39,8 @@ #include #include +#include + #ifdef HAVE_NCURSESW_NCURSES_H #include #elif HAVE_NCURSES_H @@ -80,6 +82,10 @@ prefs_load(void) log_info("Loading preferences"); prefs_loc = _get_preferences_file(); + if (g_file_test(prefs_loc, G_FILE_TEST_EXISTS)) { + g_chmod(prefs_loc, S_IRUSR | S_IWUSR); + } + prefs = g_key_file_new(); g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL); @@ -401,6 +407,7 @@ _save_prefs(void) gsize g_data_size; gchar *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); g_file_set_contents(prefs_loc, g_prefs_data, g_data_size, NULL); + g_chmod(prefs_loc, S_IRUSR | S_IWUSR); g_free(g_prefs_data); }