summaryrefslogtreecommitdiff
path: root/src/core/rawlog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/rawlog.c')
-rw-r--r--src/core/rawlog.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/core/rawlog.c b/src/core/rawlog.c
index 5927e730..fdd51241 100644
--- a/src/core/rawlog.c
+++ b/src/core/rawlog.c
@@ -20,19 +20,21 @@
#include "module.h"
#include "rawlog.h"
+#include "log.h"
#include "modules.h"
#include "signals.h"
#include "commands.h"
#include "misc.h"
#include "write-buffer.h"
#include "settings.h"
+#ifdef HAVE_CAPSICUM
+#include "capsicum.h"
+#endif
#include "servers.h"
static int rawlog_lines;
static int signal_rawlog;
-static int log_file_create_mode;
-static int log_dir_create_mode;
RAWLOG_REC *rawlog_create(void)
{
@@ -127,12 +129,24 @@ void rawlog_open(RAWLOG_REC *rawlog, const char *fname)
return;
path = convert_home(fname);
+#ifdef HAVE_CAPSICUM
+ rawlog->handle = capsicum_open_wrapper(path,
+ O_WRONLY | O_APPEND | O_CREAT,
+ log_file_create_mode);
+#else
rawlog->handle = open(path, O_WRONLY | O_APPEND | O_CREAT,
log_file_create_mode);
+#endif
+
g_free(path);
+ if (rawlog->handle == -1) {
+ g_warning("rawlog open() failed: %s", strerror(errno));
+ return;
+ }
+
rawlog_dump(rawlog, rawlog->handle);
- rawlog->logging = rawlog->handle != -1;
+ rawlog->logging = TRUE;
}
void rawlog_close(RAWLOG_REC *rawlog)
@@ -140,7 +154,7 @@ void rawlog_close(RAWLOG_REC *rawlog)
if (rawlog->logging) {
write_buffer_flush();
close(rawlog->handle);
- rawlog->logging = 0;
+ rawlog->logging = FALSE;
}
}
@@ -150,11 +164,20 @@ void rawlog_save(RAWLOG_REC *rawlog, const char *fname)
int f;
dir = g_path_get_dirname(fname);
+#ifdef HAVE_CAPSICUM
+ capsicum_mkdir_with_parents_wrapper(dir, log_dir_create_mode);
+#else
g_mkdir_with_parents(dir, log_dir_create_mode);
+#endif
g_free(dir);
path = convert_home(fname);
+#ifdef HAVE_CAPSICUM
+ f = capsicum_open_wrapper(path, O_WRONLY | O_APPEND | O_CREAT,
+ log_file_create_mode);
+#else
f = open(path, O_WRONLY | O_APPEND | O_CREAT, log_file_create_mode);
+#endif
g_free(path);
if (f < 0) {
@@ -174,12 +197,6 @@ void rawlog_set_size(int lines)
static void read_settings(void)
{
rawlog_set_size(settings_get_int("rawlog_lines"));
- log_file_create_mode = octal2dec(settings_get_int("log_create_mode"));
- log_dir_create_mode = log_file_create_mode;
- if (log_file_create_mode & 0400) log_dir_create_mode |= 0100;
- if (log_file_create_mode & 0040) log_dir_create_mode |= 0010;
- if (log_file_create_mode & 0004) log_dir_create_mode |= 0001;
-
}
static void cmd_rawlog(const char *data, SERVER_REC *server, void *item)