about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-10-18 21:26:38 +0100
committerJames Booth <boothj5@gmail.com>2014-10-18 21:26:38 +0100
commitc6ae459cd500e6e7bd8c845a407e1573e98a31cf (patch)
tree8ff365d868205fc5487be970347ec3ac39bc84c8 /src/config
parent462cf67f1d342143a78f7ca3c6f3c3ef46def3bd (diff)
downloadprofani-tty-c6ae459cd500e6e7bd8c845a407e1573e98a31cf.tar.gz
Set file permissions for preferences file
Diffstat (limited to 'src/config')
-rw-r--r--src/config/preferences.c7
1 files changed, 7 insertions, 0 deletions
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 <string.h>
 
 #include <glib.h>
+#include <glib/gstdio.h>
+
 #ifdef HAVE_NCURSESW_NCURSES_H
 #include <ncursesw/ncurses.h>
 #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);
 }