From 0c49a84ffb8d74506a13653183bfa1ef8ffd2554 Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Wed, 9 Aug 2017 11:06:36 +0100 Subject: Add back some ifdefs. Signed-off-by: Edward Tomasz Napierala --- src/core/capsicum.h | 10 +--------- src/core/core.c | 2 ++ src/core/log.c | 12 ++++++++++++ src/core/rawlog.c | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/capsicum.h b/src/core/capsicum.h index 3c1234e1..7d89f2aa 100644 --- a/src/core/capsicum.h +++ b/src/core/capsicum.h @@ -5,17 +5,9 @@ gboolean capsicum_enabled(void); int capsicum_net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip); int capsicum_net_gethostbyname(const char *addr, IPADDR *ip4, IPADDR *ip6); int capsicum_open(const char *path, int flags, int mode); -void capsicum_mkdir_with_parents(const char *path, int mode); - -#ifdef HAVE_CAPSICUM int capsicum_open_wrapper(const char *path, int flags, int mode); +void capsicum_mkdir_with_parents(const char *path, int mode); void capsicum_mkdir_with_parents_wrapper(const char *path, int mode); -#else -#define capsicum_open_wrapper(P, F, M) \ - open(P, F, M) -#define capsicum_mkdir_with_parents_wrapper(P, M) \ - g_mkdir_with_parents(P, M) -#endif void capsicum_init(void); void capsicum_deinit(void); diff --git a/src/core/core.c b/src/core/core.c index c95879de..506d6a13 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -29,7 +29,9 @@ #include "signals.h" #include "settings.h" #include "session.h" +#ifdef HAVE_CAPSICUM #include "capsicum.h" +#endif #include "chat-protocols.h" #include "servers.h" diff --git a/src/core/log.c b/src/core/log.c index ea2f1a1d..f7741d3d 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -26,7 +26,9 @@ #include "servers.h" #include "log.h" #include "write-buffer.h" +#ifdef HAVE_CAPSICUM #include "capsicum.h" +#endif #include "lib-config/iconfig.h" #include "settings.h" @@ -115,13 +117,23 @@ int log_start_logging(LOG_REC *log) /* path may contain variables (%time, $vars), make sure the directory is created */ dir = g_path_get_dirname(log->real_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); } +#ifdef HAVE_CAPSICUM log->handle = log->real_fname == NULL ? -1 : capsicum_open_wrapper(log->real_fname, O_WRONLY | O_APPEND | O_CREAT, log_file_create_mode); +#else + log->handle = log->real_fname == NULL ? -1 : + open(log->real_fname, O_WRONLY | O_APPEND | O_CREAT, + log_file_create_mode); +#endif if (log->handle == -1) { signal_emit("log create failed", 1, log); log->failed = TRUE; diff --git a/src/core/rawlog.c b/src/core/rawlog.c index a95b9a92..fdd51241 100644 --- a/src/core/rawlog.c +++ b/src/core/rawlog.c @@ -27,7 +27,9 @@ #include "misc.h" #include "write-buffer.h" #include "settings.h" +#ifdef HAVE_CAPSICUM #include "capsicum.h" +#endif #include "servers.h" @@ -127,9 +129,15 @@ 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) { @@ -156,12 +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) { -- cgit v1.2.3