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.
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")
--- /dev/null
+# 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)
+include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX)
include(CheckFunctionExists)
+include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckTypeSize)
-include(CheckLibraryExists)
-include(CheckCXXSourceCompiles)
include (TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
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.
#--------------------------------------------------------------------------
#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 */
#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>
#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>
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})
${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}
#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>
{
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));