]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mingw: don't try to build unix socket
authorVictor Julien <victor@inliniac.net>
Sat, 15 Jul 2017 08:00:57 +0000 (10:00 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 19 Jul 2017 07:38:33 +0000 (09:38 +0200)
configure.ac
src/unix-manager.c
src/util-logopenfile.c

index ee7408ca3c93a2009655c30d203a7e87a92d3a2f..88409f7b43ac039d90c3e27e74da471a099a50d7 100644 (file)
     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
index 02e7a7bebd051428f0330f449aa683b7304a35d3..a232c76ccd0c13db02581016f21cf32fdecc4606 100644 (file)
 #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 <sys/un.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#ifdef BUILD_UNIX_SOCKET
 #include <jansson.h>
 
 #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;
index 53022fa0192637538397d495e19445abd31a2305..9424ac35756ce5dac117ac036479708c3c71d7c6 100644 (file)
@@ -23,9 +23,6 @@
  *
  * File-like output for logging:  regular files and sockets.
  */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
 
 #include "suricata-common.h" /* errno.h, string.h, etc. */
 #include "tm-modules.h"      /* LogFileCtx */
 #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 <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#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);