From: Victor Julien Date: Sat, 15 Jul 2017 08:00:57 +0000 (+0200) Subject: mingw: don't try to build unix socket X-Git-Tag: suricata-4.0.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c02739e535e6b6cf5311f78b7c9d8c88f1760a5a;p=thirdparty%2Fsuricata.git mingw: don't try to build unix socket --- diff --git a/configure.ac b/configure.ac index ee7408ca3c..88409f7b43 100644 --- a/configure.ac +++ b/configure.ac @@ -129,7 +129,7 @@ AC_CHECK_HEADERS([linux/ethtool.h linux/sockios.h]) AC_CHECK_HEADER(glob.h,,[AC_ERROR(glob.h not found ...)]) AC_CHECK_HEADERS([dirent.h fnmatch.h]) - AC_CHECK_HEADERS([sys/resource.h]) + AC_CHECK_HEADERS([sys/resource.h sys/types.h sys/un.h]) AC_CHECK_HEADERS([sys/socket.h net/if.h sys/mman.h linux/if_arp.h], [], [], [[#ifdef HAVE_SYS_SOCKET_H diff --git a/src/unix-manager.c b/src/unix-manager.c index 02e7a7bebd..a232c76ccd 100644 --- a/src/unix-manager.c +++ b/src/unix-manager.c @@ -35,11 +35,11 @@ #include "util-signal.h" #include "util-buffer.h" +#if (defined BUILD_UNIX_SOCKET) && (defined HAVE_SYS_UN_H) && (defined HAVE_SYS_STAT_H) && (defined HAVE_SYS_TYPES_H) #include #include #include -#ifdef BUILD_UNIX_SOCKET #include #include "output-json.h" @@ -1056,7 +1056,7 @@ void UnixManagerThreadSpawnNonRunmode(void) void TmModuleUnixManagerRegister (void) { -#ifdef BUILD_UNIX_SOCKET +#if defined(BUILD_UNIX_SOCKET) && defined(HAVE_SYS_UN_H) && defined(HAVE_SYS_STAT_H) && defined(HAVE_SYS_TYPES_H) tmm_modules[TMM_UNIXMANAGER].name = "UnixManager"; tmm_modules[TMM_UNIXMANAGER].ThreadInit = UnixManagerThreadInit; tmm_modules[TMM_UNIXMANAGER].ThreadDeinit = UnixManagerThreadDeinit; diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index 53022fa019..9424ac3575 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -23,9 +23,6 @@ * * File-like output for logging: regular files and sockets. */ -#include -#include -#include #include "suricata-common.h" /* errno.h, string.h, etc. */ #include "tm-modules.h" /* LogFileCtx */ @@ -35,10 +32,18 @@ #include "util-logopenfile.h" #include "util-logopenfile-tile.h" +#if defined(HAVE_SYS_UN_H) && defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SYS_TYPES_H) +#define BUILD_WITH_UNIXSOCKET +#include +#include +#include +#endif + #ifdef HAVE_LIBHIREDIS #include "util-log-redis.h" #endif /* HAVE_LIBHIREDIS */ +#ifdef BUILD_WITH_UNIXSOCKET /** \brief connect to the indicated local stream socket, logging any errors * \param path filesystem path to connect to * \param log_err, non-zero if connect failure should be logged. @@ -128,11 +133,11 @@ static int SCLogFileWriteSocket(const char *buffer, int buffer_len, int tries = 0; int ret = 0; bool reopen = false; - +#ifdef BUILD_WITH_UNIXSOCKET if (ctx->fp == NULL && ctx->is_sock) { SCLogUnixSocketReconnect(ctx); } - +#endif tryagain: ret = -1; reopen = 0; @@ -172,6 +177,7 @@ tryagain: return ret; } +#endif /* BUILD_WITH_UNIXSOCKET */ /** * \brief Write buffer to log file. @@ -183,9 +189,12 @@ static int SCLogFileWrite(const char *buffer, int buffer_len, LogFileCtx *log_ct SCMutexLock(&log_ctx->fp_mutex); int ret = 0; +#ifdef BUILD_WITH_UNIXSOCKET if (log_ctx->is_sock) { ret = SCLogFileWriteSocket(buffer, buffer_len, log_ctx); - } else { + } else +#endif + { /* Check for rotation. */ if (log_ctx->rotation_flag) { @@ -462,15 +471,23 @@ SCConfLogOpenGeneric(ConfNode *conf, // Now, what have we been asked to open? if (strcasecmp(filetype, "unix_stream") == 0) { +#ifdef BUILD_WITH_UNIXSOCKET /* Don't bail. May be able to connect later. */ log_ctx->is_sock = 1; log_ctx->sock_type = SOCK_STREAM; log_ctx->fp = SCLogOpenUnixSocketFp(log_path, SOCK_STREAM, 1); +#else + return -1; +#endif } else if (strcasecmp(filetype, "unix_dgram") == 0) { +#ifdef BUILD_WITH_UNIXSOCKET /* Don't bail. May be able to connect later. */ log_ctx->is_sock = 1; log_ctx->sock_type = SOCK_DGRAM; log_ctx->fp = SCLogOpenUnixSocketFp(log_path, SOCK_DGRAM, 1); +#else + return -1; +#endif } else if (strcasecmp(filetype, DEFAULT_LOG_FILETYPE) == 0 || strcasecmp(filetype, "file") == 0) { log_ctx->fp = SCLogOpenFileFp(log_path, append, log_ctx->filemode); @@ -507,12 +524,13 @@ SCConfLogOpenGeneric(ConfNode *conf, return -1; } +#ifdef BUILD_WITH_UNIXSOCKET /* If a socket and running live, do non-blocking writes. */ if (log_ctx->is_sock && run_mode_offline == 0) { SCLogInfo("Setting logging socket of non-blocking in live mode."); log_ctx->send_flags |= MSG_DONTWAIT; } - +#endif SCLogInfo("%s output device (%s) initialized: %s", conf->name, filetype, filename);