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:23:42 +0100
committerJames Booth <boothj5@gmail.com>2014-10-18 21:23:42 +0100
commit462cf67f1d342143a78f7ca3c6f3c3ef46def3bd (patch)
tree62ecbdf40c78300356005aff48a78e0ea3ed64c3 /src/config
parentb87c158c6a477d53045c24d2620224d4f2b4593d (diff)
downloadprofani-tty-462cf67f1d342143a78f7ca3c6f3c3ef46def3bd.tar.gz
Set file permissions for accounts file
Diffstat (limited to 'src/config')
-rw-r--r--src/config/accounts.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 7cd6ebc7..0bea55b4 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -36,6 +36,7 @@
 #include <string.h>
 
 #include <glib.h>
+#include <glib/gstdio.h>
 
 #include "accounts.h"
 
@@ -80,6 +81,10 @@ _accounts_load(void)
     enabled_ac = autocomplete_new();
     accounts_loc = _get_accounts_file();
 
+    if (g_file_test(accounts_loc, G_FILE_TEST_EXISTS)) {
+        g_chmod(accounts_loc, S_IRUSR | S_IWUSR);
+    }
+
     accounts = g_key_file_new();
     g_key_file_load_from_file(accounts, accounts_loc, G_KEY_FILE_KEEP_COMMENTS,
         NULL);
@@ -804,6 +809,7 @@ _save_accounts(void)
     gsize g_data_size;
     gchar *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL);
     g_file_set_contents(accounts_loc, g_accounts_data, g_data_size, NULL);
+    g_chmod(accounts_loc, S_IRUSR | S_IWUSR);
     g_free(g_accounts_data);
 }