1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-07-21 18:24:14 -04:00

Set file permissions for logs

This commit is contained in:
James Booth 2014-10-18 21:40:11 +01:00
parent c6ae459cd5
commit bb3f1b0909
2 changed files with 10 additions and 0 deletions

View File

@ -40,6 +40,7 @@
#include <unistd.h>
#include "glib.h"
#include "glib/gstdio.h"
#include "log.h"
@ -133,6 +134,7 @@ log_init(log_level_t filter)
tz = g_time_zone_new_local();
gchar *log_file = _get_main_log_file();
logp = fopen(log_file, "a");
g_chmod(log_file, S_IRUSR | S_IWUSR);
mainlogfile = g_string_new(log_file);
free(log_file);
}
@ -274,6 +276,7 @@ chat_log_chat(const gchar * const login, gchar *other,
date_fmt = g_date_time_format(dt, "%H:%M:%S");
FILE *logp = fopen(dated_log->filename, "a");
g_chmod(dated_log->filename, S_IRUSR | S_IWUSR);
if (logp != NULL) {
if (direction == PROF_IN_LOG) {
if (strncmp(msg, "/me ", 4) == 0) {
@ -322,6 +325,7 @@ groupchat_log_chat(const gchar * const login, const gchar * const room,
gchar *date_fmt = g_date_time_format(dt, "%H:%M:%S");
FILE *logp = fopen(dated_log->filename, "a");
g_chmod(dated_log->filename, S_IRUSR | S_IWUSR);
if (logp != NULL) {
if (strncmp(msg, "/me ", 4) == 0) {
fprintf(logp, "%s - *%s %s\n", date_fmt, nick, msg + 4);

View File

@ -42,6 +42,7 @@
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <strophe.h>
#include "common.h"
@ -69,6 +70,10 @@ caps_init(void)
log_info("Loading capabilities cache");
cache_loc = _get_cache_file();
if (g_file_test(cache_loc, G_FILE_TEST_EXISTS)) {
g_chmod(cache_loc, S_IRUSR | S_IWUSR);
}
cache = g_key_file_new();
g_key_file_load_from_file(cache, cache_loc, G_KEY_FILE_KEEP_COMMENTS,
NULL);
@ -614,6 +619,7 @@ _save_cache(void)
gsize g_data_size;
gchar *g_cache_data = g_key_file_to_data(cache, &g_data_size, NULL);
g_file_set_contents(cache_loc, g_cache_data, g_data_size, NULL);
g_chmod(cache_loc, S_IRUSR | S_IWUSR);
g_free(g_cache_data);
}