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) { diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c index 67c9e20c..a3b7364c 100644 --- a/src/fe-common/core/fe-common-core.c +++ b/src/fe-common/core/fe-common-core.c @@ -32,7 +32,9 @@ #include "special-vars.h" #include "fe-core-commands.h" #include "fe-queries.h" +#ifdef HAVE_CAPSICUM #include "fe-capsicum.h" +#endif #include "hilight-text.h" #include "command-history.h" #include "completion.h" diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 3d8910c9..0fed8642 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -30,7 +30,9 @@ #include "special-vars.h" #include "settings.h" #include "lib-config/iconfig.h" +#ifdef HAVE_CAPSICUM #include "capsicum.h" +#endif #include "fe-windows.h" #include "window-items.h" @@ -452,7 +454,11 @@ static void autolog_open(SERVER_REC *server, const char *server_tag, log_item_add(log, LOG_ITEM_TARGET, target, server_tag); 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); log->temp = TRUE;