]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1353 in SNORT/snort3 from alpine to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 5 Sep 2018 19:02:58 +0000 (15:02 -0400)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 5 Sep 2018 19:02:58 +0000 (15:02 -0400)
Squashed commit of the following:

commit 8bfe2663676b663fb4dad6788e8663e825f56f65
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Sep 4 21:25:45 2018 -0400

    build: Add libnsl and libsocket to Snort for Solaris builds

    Fixes Snort build on OpenIndiana.

commit 42dccb76a6c0d504118e2c71a68aa71070b09b9c
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Sep 4 18:30:54 2018 -0400

    build: Fall back on TI-RPC if no built-in RPC DB is found

    Necessary for getrpcent() on musl-based Linux systems.

commit c70cd8e45e2227c2937d350ad05d82c39f05350c
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Sep 4 19:07:14 2018 -0400

    daqs: Include unistd.h directly for better cross-platform compatibility

commit cb2df1c310054404c80339ff2b4de072ba1ed551
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Sep 4 15:32:45 2018 -0400

    build: Introduce a more robust check for GNU strerror_r

    This should better handle the case where we're using alternative C
    libraries on Linux like musl.

CMakeLists.txt
cmake/FindTIRPC.cmake [new file with mode: 0644]
cmake/sanity_checks.cmake
config.cmake.h.in
daqs/daq_file.c
daqs/daq_hext.c
src/CMakeLists.txt
src/network_inspectors/appid/service_plugins/service_rpc.cc
src/utils/util.cc

index e6a01fb4575568a1086437bddeaeb40c3184dc60..e06881f8227ac808494145dbac54ab7e866fc83f 100644 (file)
@@ -125,6 +125,14 @@ else ()
     LZMA:           OFF")
 endif ()
 
+if (USE_TIRPC)
+    message("\
+    RPC DB:         TIRPC")
+else ()
+    message("\
+    RPC DB:         Built-in")
+endif ()
+
 if (HAVE_SAFEC AND SAFEC_ENABLED)
     message("\
     SafeC:          ON")
diff --git a/cmake/FindTIRPC.cmake b/cmake/FindTIRPC.cmake
new file mode 100644 (file)
index 0000000..467cb40
--- /dev/null
@@ -0,0 +1,44 @@
+# FindTIRPC
+# ---------
+#
+# Find the native TIRPC includes and library.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module will set the following variables in your project:
+#
+# ``TIRPC_INCLUDE_DIRS``
+#   where to find rpc.h, etc.
+# ``TIRPC_LIBRARIES``
+#   the libraries to link against to use TIRPC.
+# ``TIRPC_VERSION``
+#   the version of TIRPC found.
+# ``TIRPC_FOUND``
+#   true if the TIRPC headers and libraries were found.
+#
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_TIRPC libtirpc)
+
+find_path(TIRPC_INCLUDE_DIRS
+    NAMES netconfig.h
+    PATH_SUFFIXES tirpc
+    HINTS ${PC_TIRPC_INCLUDE_DIRS}
+)
+
+find_library(TIRPC_LIBRARIES
+    NAMES tirpc
+    HINTS ${PC_TIRPC_LIBRARY_DIRS}
+)
+
+set(TIRPC_VERSION ${PC_TIRPC_VERSION})
+
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args(TIRPC
+    REQUIRED_VARS TIRPC_LIBRARIES TIRPC_INCLUDE_DIRS
+    VERSION_VAR TIRPC_VERSION
+)
+
+mark_as_advanced(TIRPC_INCLUDE_DIRS TIRPC_LIBRARIES)
index 4907516cb3309f539ae2661c68154c4863485fce..f2b501e6086e8e7de3f635d72de86abe497f6ded 100644 (file)
@@ -1,9 +1,9 @@
+include(CheckCXXSourceCompiles)
 include(CheckIncludeFileCXX)
 include(CheckFunctionExists)
+include(CheckLibraryExists)
 include(CheckSymbolExists)
 include(CheckTypeSize)
-include(CheckLibraryExists)
-include(CheckCXXSourceCompiles)
 
 include (TestBigEndian)
 test_big_endian(WORDS_BIGENDIAN)
@@ -17,6 +17,42 @@ check_function_exists(malloc_trim HAVE_MALLOC_TRIM)
 check_function_exists(memrchr HAVE_MEMRCHR)
 check_function_exists(sigaction HAVE_SIGACTION)
 
+check_cxx_source_compiles(
+    "
+    #include <string.h>
+    #include <errno.h>
+
+    void check(char c) {}
+
+    int main()
+    {
+        char buffer[1024];
+       /* This will not compile if strerror_r does not return a char* */
+       check(strerror_r(EACCES, buffer, sizeof(buffer))[0]);
+       return 0;
+    }
+    "
+    HAVE_GNU_STRERROR_R)
+
+# vvvvvvvvv  GETRPCENT TEST vvvvvvvvv
+cmake_push_check_state(RESET)
+if ( CMAKE_SYSTEM_NAME STREQUAL SunOS )
+    set(CMAKE_REQUIRED_LIBRARIES nsl)
+endif ()
+check_function_exists(getrpcent HAVE_GETRPCENT)
+if (NOT HAVE_GETRPCENT)
+    find_package(TIRPC)
+    set(CMAKE_REQUIRED_LIBRARIES ${TIRPC_LIBRARIES})
+    check_function_exists(getrpcent HAVE_TIRPC_GETRPCENT)
+    if (HAVE_TIRPC_GETRPCENT)
+        set(USE_TIRPC TRUE)
+    else()
+        message(SEND_ERROR "Couldn't find an RPC program number database implementation!")
+    endif()
+endif()
+cmake_pop_check_state()
+# ^^^^^^^^^  GETRPCENT TEST ^^^^^^^^^
+
 #--------------------------------------------------------------------------
 # Checks for typedefs, structures, and compiler characteristics.
 #--------------------------------------------------------------------------
index 7ac063abe413bbc78e3f07b9dacc94962186522e..7066c299a518ecd781a294e0e3d8e9601f3f04cf 100644 (file)
 
 #cmakedefine HAVE_UUID 1
 
+#cmakedefine USE_TIRPC 1
+
 
 /*  Availability of specific library functions */
 
 /* Define to 1 if you have the `sigaction' function. */
 #cmakedefine HAVE_SIGACTION 1
 
+/* Define to 1 if you have the GNU form of the `strerror_r' function. */
+#cmakedefine HAVE_GNU_STRERROR_R 1
+
 
 /*  Available compiler options */
 
index 192236a6ba8a4258277b87757b26b0cb1a695f0b..92f9093cfef5a55ed68fa10e5685511fba5b73b3 100644 (file)
 
 #include "daq_user.h"
 
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-
-#include <sys/types.h>
 #include <sys/time.h>
-#include <sys/unistd.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include <daq_api.h>
 #include <sfbpf_dlt.h>
index 97311483d276e311108ab55a3b94e68aec7169b1..b9524e227799cda0655e6406787e2f57926ffba6 100644 (file)
 
 #include "daq_user.h"
 
-#include <assert.h>
+#include <arpa/inet.h>
 #include <ctype.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/unistd.h>
 #include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include <daq_api.h>
 #include <sfbpf_dlt.h>
index c066be3b699389533ce037ea624e0e60638bac1b..679bfdc22f13d3a2da9bdeb6ddd8f5a876f855f0 100644 (file)
@@ -43,6 +43,11 @@ if ( ICONV_FOUND )
     LIST(APPEND EXTERNAL_INCLUDES ${ICONV_INCLUDE_DIR})
 endif ()
 
+if ( USE_TIRPC )
+    LIST(APPEND EXTERNAL_LIBRARIES ${TIRPC_LIBRARIES})
+    LIST(APPEND EXTERNAL_INCLUDES ${TIRPC_INCLUDE_DIRS})
+endif ()
+
 include_directories(BEFORE ${LUAJIT_INCLUDE_DIR})
 include_directories(AFTER ${EXTERNAL_INCLUDES})
 
@@ -178,6 +183,11 @@ target_link_libraries( snort
     ${EXTERNAL_LIBRARIES}
 )
 
+# Solaris requires libnsl and libsocket for various network-related library functions
+if ( CMAKE_SYSTEM_NAME STREQUAL SunOS )
+    target_link_libraries(snort nsl socket)
+endif ()
+
 #  setting export properties
 set_property(TARGET snort APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
     ${LUAJIT_INCLUDE_DIR}
index 42fd6523235061544f0d4754719e9e865de1c100..a6e5d0b2cd662bfa1d71e82f878faa7fd0425b5c 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <netdb.h>
 
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(USE_TIRPC)
 #include <rpc/rpc.h>
 #elif defined(__sun)
 #include <rpc/rpcent.h>
index a26f0a2d1f4b46baf5237676451eb0000d3be496..34d2b64ca246becd94cfe4bddf53d4722fc2a11b 100644 (file)
@@ -605,8 +605,7 @@ const char* get_error(int errnum)
 {
     static THREAD_LOCAL char buf[128];
 
-#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 200112L && \
-        defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 600) || _GNU_SOURCE
+#if defined(HAVE_GNU_STRERROR_R)
     return strerror_r(errnum, buf, sizeof(buf));
 #else
     (void)strerror_r(errnum, buf, sizeof(buf));