mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +00:00
Add CMake build tooling
This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
This commit is contained in:
parent
1a8b164b4f
commit
9e20cdf6ea
293 changed files with 9728 additions and 3297 deletions
865
CMakeLists.txt
Normal file
865
CMakeLists.txt
Normal file
|
@ -0,0 +1,865 @@
|
||||||
|
# Copyright (C) 2019-2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
set(CMAKE_C_STANDARD 90)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# Change this on a release:
|
||||||
|
# During active development: set(VERSION_SUFFIX "-devel-${TODAY}")
|
||||||
|
# For beta: set(VERSION_SUFFIX "-beta")
|
||||||
|
# For release candidate: set(VERSION_SUFFIX "-rc")
|
||||||
|
# For release: set(VERSION_SUFFIX "")
|
||||||
|
string(TIMESTAMP TODAY "%Y%m%d")
|
||||||
|
set(VERSION_SUFFIX "-devel-${TODAY}")
|
||||||
|
|
||||||
|
project( ClamAV
|
||||||
|
VERSION "0.103.0"
|
||||||
|
DESCRIPTION "ClamAV open source email, web, and end-point anti-virus toolkit." )
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
include(Version)
|
||||||
|
|
||||||
|
set(PACKAGE_NAME "${PROJECT_NAME}")
|
||||||
|
set(PACKAGE_VERSION "${PROJECT_VERSION}")
|
||||||
|
set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}${VERSION_SUFFIX}")
|
||||||
|
set(PACKAGE_BUGREPORT "https://bugzilla.clamav.net/")
|
||||||
|
set(PACKAGE_URL "https://www.clamav.net/")
|
||||||
|
HexVersion(PACKAGE_VERSION_NUM ${PROJECT_VERSION_MAJOR} ${PROJECT_VERSION_MINOR} ${PROJECT_VERSION_PATCH})
|
||||||
|
|
||||||
|
# libtool library versioning rules: http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
||||||
|
set(LIBCLAMAV_CURRENT 9)
|
||||||
|
set(LIBCLAMAV_REVISION 5)
|
||||||
|
set(LIBCLAMAV_AGE 0)
|
||||||
|
|
||||||
|
math(EXPR LIBCLAMAV_SOVERSION "${LIBCLAMAV_CURRENT} - ${LIBCLAMAV_AGE}")
|
||||||
|
set(LIBCLAMAV_VERSION "${LIBCLAMAV_SOVERSION}.${LIBCLAMAV_AGE}.${LIBCLAMAV_REVISION}")
|
||||||
|
HexVersion(LIBCLAMAV_VERSION_NUM ${LIBCLAMAV_CURRENT} ${LIBCLAMAV_REVISION} ${LIBCLAMAV_AGE})
|
||||||
|
|
||||||
|
set(LIBFRESHCLAM_CURRENT 2)
|
||||||
|
set(LIBFRESHCLAM_REVISION 1)
|
||||||
|
set(LIBFRESHCLAM_AGE 0)
|
||||||
|
|
||||||
|
math(EXPR LIBFRESHCLAM_SOVERSION "${LIBFRESHCLAM_CURRENT} - ${LIBFRESHCLAM_AGE}")
|
||||||
|
set(LIBFRESHCLAM_VERSION "${LIBFRESHCLAM_SOVERSION}.${LIBFRESHCLAM_AGE}.${LIBFRESHCLAM_REVISION}")
|
||||||
|
HexVersion(LIBFRESHCLAM_VERSION_NUM ${LIBFRESHCLAM_CURRENT} ${LIBFRESHCLAM_REVISION} ${LIBFRESHCLAM_AGE})
|
||||||
|
|
||||||
|
# Git optionally used to add commit info into build to differentiate in bug reports.
|
||||||
|
find_package(Git)
|
||||||
|
if(Git_FOUND)
|
||||||
|
# Store git description into variable
|
||||||
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always
|
||||||
|
OUTPUT_VARIABLE REPO_VERSION)
|
||||||
|
if("${REPO_VERSION}" MATCHES "")
|
||||||
|
unset(REPO_VERSION)
|
||||||
|
else()
|
||||||
|
string(STRIP ${REPO_VERSION} REPO_VERSION)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Enable use of pkg-config to find depenencies.
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Find Build Tools
|
||||||
|
#
|
||||||
|
|
||||||
|
# Bison, Flex required to build Yara module for libclamav.
|
||||||
|
find_package(BISON REQUIRED)
|
||||||
|
find_package(FLEX REQUIRED)
|
||||||
|
if(MAINTAINER_MODE)
|
||||||
|
find_package(GPERF REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Load Build Options
|
||||||
|
#
|
||||||
|
|
||||||
|
# CMake Option default values:
|
||||||
|
set(ENABLE_APP_DEFAULT ON)
|
||||||
|
set(ENABLE_MILTER_DEFAULT OFF)
|
||||||
|
set(ENABLE_CLAMONACC_DEFAULT ON)
|
||||||
|
set(ENABLE_EXAMPLES_DEFAULT OFF)
|
||||||
|
if(WIN32)
|
||||||
|
set(ENABLE_DOCS_DEFAULT OFF)
|
||||||
|
else()
|
||||||
|
set(ENABLE_DOCS_DEFAULT ON)
|
||||||
|
endif()
|
||||||
|
set(ENABLE_DOXYGEN_DEFAULT OFF)
|
||||||
|
set(ENABLE_UNRAR_DEFAULT ON)
|
||||||
|
set(ENABLE_SYSTEMD_DEFAULT ON)
|
||||||
|
|
||||||
|
# See CMakeOptions.cmake for additional options.
|
||||||
|
include(CMakeOptions.cmake)
|
||||||
|
|
||||||
|
if(ENABLE_LIBCLAMAV_ONLY AND (ENABLE_APP OR ENABLE_EXAMPLES))
|
||||||
|
# Remember when disabled options are disabled for later diagnostics.
|
||||||
|
set(ENABLE_LIB_ONLY_DISABLED_OTHERS 1)
|
||||||
|
else()
|
||||||
|
set(ENABLE_LIB_ONLY_DISABLED_OTHERS 0)
|
||||||
|
endif()
|
||||||
|
if(ENABLE_LIBCLAMAV_ONLY)
|
||||||
|
set(ENABLE_APP OFF)
|
||||||
|
set(ENABLE_EXAMPLES OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set RPATH for custom install prefixes
|
||||||
|
#
|
||||||
|
if(APPLE)
|
||||||
|
set(CMAKE_MACOSX_RPATH 1)
|
||||||
|
endif()
|
||||||
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Define LINUX because CMake only defines UNIX
|
||||||
|
#
|
||||||
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||||
|
set(LINUX 1)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
# For O_LARGEFILE, O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW, etc flags on older systems
|
||||||
|
# (pre POSIX.1-2008: glibc 2.11 and earlier). #4042
|
||||||
|
set(_GNU_SOURCE 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set FreeBSD include path to include /usr/local/include
|
||||||
|
#
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||||
|
include_directories(/usr/local/include)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Use the `lib` prefix on Windows, to match previous ClamAV build
|
||||||
|
#
|
||||||
|
if(WIN32)
|
||||||
|
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||||
|
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Find Library Dependencies
|
||||||
|
#
|
||||||
|
if (WIN32)
|
||||||
|
find_package(PThreadW32)
|
||||||
|
set(HAVE_PTHREAD_H 1)
|
||||||
|
set(_REENTRANT 1)
|
||||||
|
set(CL_THREAD_SAFE 1)
|
||||||
|
else()
|
||||||
|
set(CMAKE_THREAD_PREFER_PTHREAD 1)
|
||||||
|
find_package(Threads)
|
||||||
|
if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
|
||||||
|
set(HAVE_PTHREAD_H 1)
|
||||||
|
set(_REENTRANT 1)
|
||||||
|
set(CL_THREAD_SAFE 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# libclamav efficacy dependencies
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
|
if(OPENSSL_FOUND)
|
||||||
|
set(HAVE_LIBSSL 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
if(ZLIB_FOUND)
|
||||||
|
set(HAVE_ZLIB_H 1)
|
||||||
|
set(HAVE_LIBZ 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(BZip2 REQUIRED)
|
||||||
|
if(BZIP2_FOUND)
|
||||||
|
set(HAVE_BZLIB_H 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(LibXml2 REQUIRED)
|
||||||
|
if(LibXml2_FOUND)
|
||||||
|
set(HAVE_LIBXML2 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(PCRE2 REQUIRED)
|
||||||
|
if(PCRE2_FOUND)
|
||||||
|
set(HAVE_PCRE 1)
|
||||||
|
set(USING_PCRE2 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# libclamav feature dependencies
|
||||||
|
if(NOT WIN32)
|
||||||
|
find_package(Iconv REQUIRED)
|
||||||
|
# Set variable required by libclamav to use iconv
|
||||||
|
set(HAVE_ICONV 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_JSON_SHARED)
|
||||||
|
set(JSONC_USE_STATIC OFF)
|
||||||
|
else()
|
||||||
|
set(JSONC_USE_STATIC ON)
|
||||||
|
endif()
|
||||||
|
find_package(JSONC REQUIRED)
|
||||||
|
# Set variable required by libclamav to use libjson-c
|
||||||
|
set(HAVE_JSON 1)
|
||||||
|
|
||||||
|
if(BYTECODE_RUNTIME STREQUAL "llvm")
|
||||||
|
find_package(LLVM REQUIRED)
|
||||||
|
if(LLVM_FOUND)
|
||||||
|
# Set variable required by libclamav to use llvm instead of interpreter
|
||||||
|
set(LLVM_VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# libfreshclam & app dependencies
|
||||||
|
if(NOT ENABLE_LIBCLAMAV_ONLY)
|
||||||
|
find_package(CURL REQUIRED)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
find_library(APPLE_CORE_FOUNDATION CoreFoundation)
|
||||||
|
if (NOT APPLE_CORE_FOUNDATION)
|
||||||
|
message(FATAL_ERROR "Apple CoreFoundation framework not found")
|
||||||
|
endif()
|
||||||
|
find_library(APPLE_SECURITY Security)
|
||||||
|
if (NOT APPLE_SECURITY)
|
||||||
|
message(FATAL_ERROR "Apple Security framework not found")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_APP)
|
||||||
|
find_package(CURSES REQUIRED)
|
||||||
|
|
||||||
|
if(NOT WIN32 AND ENABLE_MILTER)
|
||||||
|
find_package(Milter REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LINUX AND ENABLE_SYSTEMD)
|
||||||
|
find_package(SYSTEMD)
|
||||||
|
if(SYSTEMD_FOUND)
|
||||||
|
set(HAVE_SYSTEMD 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# Do not disable assertions based on CMAKE_BUILD_TYPE.
|
||||||
|
foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
|
||||||
|
foreach(_lang C CXX)
|
||||||
|
string(TOUPPER "CMAKE_${_lang}_FLAGS_${_build_type}" _var)
|
||||||
|
string(REGEX REPLACE "(^|)[/-]D *NDEBUG($|)" " " ${_var} "${${_var}}")
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Disable optimizations if OPTIMIZE=OFF
|
||||||
|
if(NOT OPTIMIZE)
|
||||||
|
# Get rid of any previous optimization flag settings...
|
||||||
|
string(REGEX REPLACE "(\-O[011123456789])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
string(REGEX REPLACE "(\-O[011123456789])" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
|
|
||||||
|
# ...And substitute our own.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Support the latest c++ standard available.
|
||||||
|
include(ExtractValidFlags)
|
||||||
|
foreach(_cxx1x_flag -std=c++14 -std=c++11)
|
||||||
|
extract_valid_cxx_flags(_cxx1x_flag_supported ${_cxx1x_flag})
|
||||||
|
if(_cxx1x_flag_supported)
|
||||||
|
set(CXX1XCXXFLAGS ${_cxx1x_flag})
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the build type" FORCE)
|
||||||
|
|
||||||
|
# Include "None" as option to disable any additional (optimization) flags,
|
||||||
|
# relying on just CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (which are empty by
|
||||||
|
# default). These strings are presented in cmake-gui.
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||||
|
"None" "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
# For test scripts and documentation
|
||||||
|
find_package(Python3)
|
||||||
|
|
||||||
|
# Always use '-fPIC'/'-fPIE' option.
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
# Checks for header files.
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
|
||||||
|
check_include_file("fcntl.h" HAVE_FCNTL_H)
|
||||||
|
check_include_file("grp.h" HAVE_GRP_H)
|
||||||
|
check_include_file("limits.h" HAVE_LIMITS_H)
|
||||||
|
check_include_file("malloc.h" HAVE_MALLOC_H)
|
||||||
|
check_include_file("netdb.h" HAVE_NETDB_H)
|
||||||
|
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
|
||||||
|
check_include_file("poll.h" HAVE_POLL_H)
|
||||||
|
check_include_file("pwd.h" HAVE_PWD_H)
|
||||||
|
check_include_file("stdbool.h" HAVE_STDBOOL_H)
|
||||||
|
check_include_file("stdlib.h" HAVE_STDLIB_H)
|
||||||
|
check_include_file("string.h" HAVE_STRING_H)
|
||||||
|
check_include_file("strings.h" HAVE_STRINGS_H)
|
||||||
|
check_include_file("sys/cdefs.h" HAVE_SYS_CDEFS_H)
|
||||||
|
check_include_file("sys/dl.h" HAVE_SYS_DL_H)
|
||||||
|
check_include_file("sys/fileio.h" HAVE_SYS_FILIO_H)
|
||||||
|
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
|
||||||
|
check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
|
||||||
|
check_include_file("sys/queue.h" HAVE_SYS_QUEUE_H)
|
||||||
|
check_include_file("sys/select.h" HAVE_SYS_SELECT_H)
|
||||||
|
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
|
||||||
|
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
|
||||||
|
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
|
||||||
|
check_include_file("sys/times.h" HAVE_SYS_TIMES_H)
|
||||||
|
check_include_file("sys/uio.h" HAVE_SYS_UIO_H)
|
||||||
|
check_include_file("syslog.h" USE_SYSLOG)
|
||||||
|
check_include_file("termios.h" HAVE_TERMIOS_H)
|
||||||
|
check_include_file("time.h" HAVE_TIME_H)
|
||||||
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
||||||
|
check_include_file("sys/fanotify.h" HAVE_SYS_FANOTIFY_H)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(HAVE_RESOLV_H 1)
|
||||||
|
set(HAVE_DIRENT_H 1)
|
||||||
|
set(HAVE_DLFCN_H 1)
|
||||||
|
else()
|
||||||
|
if(APPLE)
|
||||||
|
set(BIND_8_COMPAT 1)
|
||||||
|
endif()
|
||||||
|
check_include_file("resolv.h" HAVE_RESOLV_H) # Disabled, beacuse libfreshclam/dns.c is broken.
|
||||||
|
check_include_file("dirent.h" HAVE_DIRENT_H)
|
||||||
|
check_include_file("dlfcn.h" HAVE_DLFCN_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# int-types variants
|
||||||
|
check_include_file("inttypes.h" HAVE_INTTYPES_H)
|
||||||
|
check_include_file("sys/inttypes.h" HAVE_SYS_INTTYPES_H)
|
||||||
|
check_include_file("sys/int_types.h" HAVE_SYS_INT_TYPES_H)
|
||||||
|
check_include_file("stdint.h" HAVE_STDINT_H)
|
||||||
|
|
||||||
|
include(CheckTypeSize)
|
||||||
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
|
# AC_TYPE_SIZE_T
|
||||||
|
check_type_size("ssize_t" SIZEOF_SSIZE_T)
|
||||||
|
if(SIZEOF_SSIZE_T STREQUAL "")
|
||||||
|
# ssize_t is a signed type in POSIX storing at least -1.
|
||||||
|
# Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools).
|
||||||
|
set(ssize_t int)
|
||||||
|
endif()
|
||||||
|
check_type_size("off_t" SIZEOF_OFF_T)
|
||||||
|
if(SIZEOF_OFF_T STREQUAL "")
|
||||||
|
# off_t is a signed type in POSIX no narrower than int.
|
||||||
|
# Set it to "long int" to match the behavior of AC_TYPE_OFF_T (autotools).
|
||||||
|
set(off_t long int)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_type_size("int" SIZEOF_INT)
|
||||||
|
check_type_size("short" SIZEOF_SHORT)
|
||||||
|
check_type_size("long" SIZEOF_LONG)
|
||||||
|
check_type_size("long long" SIZEOF_LONG_LONG)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Variables for clamav-types.h.in
|
||||||
|
#
|
||||||
|
if(HAVE_SYS_INT_TYPES_H)
|
||||||
|
set(INT_TYPES_HEADER "#include <sys/int_types.h>")
|
||||||
|
elseif(HAVE_INTTYPES_H)
|
||||||
|
set(INT_TYPES_HEADER "#include <inttypes.h>")
|
||||||
|
elseif(HAVE_STDINT_H)
|
||||||
|
set(INT_TYPES_HEADER "#include <stdint.h>")
|
||||||
|
elseif(WIN32 AND MSVC)
|
||||||
|
# Windows / Visual C++ (not Cygwin), stdint.h should exist.
|
||||||
|
set(INT_TYPES_HEADER "#include <stdint.h>")
|
||||||
|
else()
|
||||||
|
# No int types header available. We'll define the types manually.
|
||||||
|
set(INT8_DEF "typedef signed char int8_t;")
|
||||||
|
set(UINT8_DEF "typedef unsigned char uint8_t;")
|
||||||
|
|
||||||
|
if(SIZEOF_INT EQUAL 2)
|
||||||
|
set(INT16_DEF "typedef signed int int16_t;")
|
||||||
|
set(UINT16_DEF "typedef unsigned int uint16_t;")
|
||||||
|
elif(SIZEOF_SHORT EQUAL 2)
|
||||||
|
set(INT16_DEF "typedef signed short int16_t;")
|
||||||
|
set(UINT16_DEF "typedef unsigned short uint16_t;")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIZEOF_INT EQUAL 4)
|
||||||
|
set(INT32_DEF "typedef signed int int32_t;")
|
||||||
|
set(UINT32_DEF "typedef unsigned int uint32_t;")
|
||||||
|
elif(SIZEOF_LONG EQUAL 4)
|
||||||
|
set(INT32_DEF "typedef signed long int32_t;")
|
||||||
|
set(UINT32_DEF "typedef unsigned long uint32_t;")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIZEOF_LONG EQUAL 8)
|
||||||
|
set(INT64_DEF "typedef signed long int64_t;")
|
||||||
|
set(UINT64_DEF "typedef unsigned long uint64_t;")
|
||||||
|
elif(SIZEOF_LONG_LONG EQUAL 8)
|
||||||
|
set(INT64_DEF "typedef signed long long int64_t;")
|
||||||
|
set(UINT64_DEF "typedef unsigned long long uint64_t;")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check for restrict keyword
|
||||||
|
#TODO: Move this to a .cmake file
|
||||||
|
foreach( ac_kw __restrict __restrict__ _Restrict restrict )
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
typedef int * int_ptr;
|
||||||
|
int foo (int_ptr ${ac_kw} ip) {
|
||||||
|
return ip[0];
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int s[1];
|
||||||
|
int * ${ac_kw} t = s;
|
||||||
|
t[0] = 0;
|
||||||
|
return foo(t);
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_RESTRICT )
|
||||||
|
|
||||||
|
if( HAVE_RESTRICT )
|
||||||
|
set( ac_cv_c_restrict ${ac_kw} )
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if( HAVE_RESTRICT )
|
||||||
|
set( restrict ${ac_cv_c_restrict} )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Define inline macro as needed.
|
||||||
|
include(TestInline)
|
||||||
|
# Determine if _FILE_OFFSET_BITS 64 needs to be set to handle large files.
|
||||||
|
include(CheckFileOffsetBits)
|
||||||
|
# Determine how to pack structs on this platform.
|
||||||
|
include(CheckStructPacking)
|
||||||
|
# Check for signed right shift implementation.
|
||||||
|
include(CheckSignedRightShift)
|
||||||
|
# Check if systtem fts implementation available
|
||||||
|
include(CheckFTS)
|
||||||
|
# Check if uname(2) follows POSIX standard.
|
||||||
|
include(CheckUnamePosix)
|
||||||
|
# Check support for file descriptor passing
|
||||||
|
include(CheckFDPassing)
|
||||||
|
|
||||||
|
# Check if big-endian
|
||||||
|
include(TestBigEndian)
|
||||||
|
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
|
||||||
|
|
||||||
|
include(CheckStructHasMember)
|
||||||
|
check_struct_has_member("struct tm" tm_gmtoff time.h HAVE_STRUCT_TM_TM_GMTOFF)
|
||||||
|
|
||||||
|
# Check size of pointer to decide we need 8 bytes alignment adjustment.
|
||||||
|
check_type_size("int *" SIZEOF_INT_P)
|
||||||
|
check_type_size("time_t" SIZEOF_TIME_T)
|
||||||
|
|
||||||
|
# Checks for library functions.
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
check_symbol_exists(_Exit "stdlib.h" HAVE__EXIT)
|
||||||
|
check_symbol_exists(accept4 "sys/types.h" HAVE_ACCEPT4)
|
||||||
|
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
|
||||||
|
check_symbol_exists(stat64 "sys/stat.h" HAVE_STAT64)
|
||||||
|
check_symbol_exists(strcasestr "string.h" HAVE_STRCASESTR)
|
||||||
|
check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
|
||||||
|
check_symbol_exists(strlcat "string.h" HAVE_STRLCAT)
|
||||||
|
check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY)
|
||||||
|
check_symbol_exists(strndup "string.h" HAVE_STRNDUP)
|
||||||
|
check_symbol_exists(strnlen "string.h" HAVE_STRNLEN)
|
||||||
|
check_symbol_exists(strnstr "string.h" HAVE_STRNSTR)
|
||||||
|
check_symbol_exists(sysctlbyname "sysctl.h" HAVE_SYSCTLBYNAME)
|
||||||
|
check_symbol_exists(timegm "time.h" HAVE_TIMEGM)
|
||||||
|
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
#set(HAVE_FSEEKO 1)
|
||||||
|
set(HAVE_GETADDRINFO 1)
|
||||||
|
set(HAVE_GETPAGESIZE 1)
|
||||||
|
set(HAVE_MKSTEMP 1)
|
||||||
|
set(HAVE_POLL 1)
|
||||||
|
else()
|
||||||
|
check_symbol_exists(fseeko "stdio.h" HAVE_FSEEKO)
|
||||||
|
check_symbol_exists(getaddrinfo "netdb.h" HAVE_GETADDRINFO)
|
||||||
|
check_symbol_exists(getpagesize "unistd.h" HAVE_GETPAGESIZE)
|
||||||
|
check_symbol_exists(mkstemp "unistd.h" HAVE_MKSTEMP)
|
||||||
|
check_symbol_exists(poll "poll.h" HAVE_POLL)
|
||||||
|
check_symbol_exists(setgroups "unistd.h" HAVE_SETGROUPS)
|
||||||
|
check_symbol_exists(setsid "unistd.h" HAVE_SETSID)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
# XXX does this correctly detect initgroups (un)availability on cygwin?
|
||||||
|
check_symbol_exists(initgroups grp.h HAVE_INITGROUPS)
|
||||||
|
if(NOT HAVE_INITGROUPS AND HAVE_UNISTD_H)
|
||||||
|
# FreeBSD declares initgroups() in unistd.h
|
||||||
|
check_symbol_exists(initgroups unistd.h HAVE_INITGROUPS2)
|
||||||
|
if(HAVE_INITGROUPS2)
|
||||||
|
set(HAVE_INITGROUPS 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(WARNCFLAGS)
|
||||||
|
set(WARNCXXFLAGS)
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||||
|
if(ENABLE_WERROR)
|
||||||
|
set(WARNCFLAGS /WX)
|
||||||
|
set(WARNCXXFLAGS /WX)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(ENABLE_WERROR)
|
||||||
|
extract_valid_c_flags(WARNCFLAGS -Werror)
|
||||||
|
extract_valid_c_flags(WARNCXXFLAGS -Werror)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# For C compiler
|
||||||
|
extract_valid_c_flags(WARNCFLAGS
|
||||||
|
-Wall -Wextra
|
||||||
|
-Wformat-security
|
||||||
|
)
|
||||||
|
if(ENABLE_ALL_THE_WARNINGS)
|
||||||
|
extract_valid_c_flags(WARNCFLAGS
|
||||||
|
-Waddress
|
||||||
|
-Wattributes
|
||||||
|
-Wclobbered
|
||||||
|
-Wconversion
|
||||||
|
-Wdeclaration-after-statement
|
||||||
|
-Wdiv-by-zero
|
||||||
|
-Wempty-body
|
||||||
|
-Wendif-labels
|
||||||
|
-Wfloat-equal
|
||||||
|
-Wformat-nonliteral
|
||||||
|
-Winline
|
||||||
|
-Wmissing-declarations
|
||||||
|
-Wmissing-field-initializers
|
||||||
|
-Wmissing-noreturn
|
||||||
|
-Wmissing-prototypes
|
||||||
|
-Wnested-externs
|
||||||
|
#-Wno-format-nonliteral # May be required to pass format string as "const char*.
|
||||||
|
-Wpointer-arith
|
||||||
|
-Wpragmas
|
||||||
|
-Wredundant-decls
|
||||||
|
-Wshadow
|
||||||
|
-Wunreachable-code
|
||||||
|
-Wunused-parameter
|
||||||
|
-Wvla
|
||||||
|
-Wwrite-strings
|
||||||
|
-Wstrict-prototypes
|
||||||
|
-Wundef
|
||||||
|
-Wcast-align
|
||||||
|
-Wextended-offsetof # May be missing from GCC
|
||||||
|
-Wheader-guard # Only work with Clang for the moment
|
||||||
|
-Wlanguage-extension-token # May be missing from GCC
|
||||||
|
-Wmissing-variable-declarations # May be missing from GCC
|
||||||
|
#-Wpadded # Not used because we cannot change public structs
|
||||||
|
-Wshorten-64-to-32 # May be missing from GCC
|
||||||
|
-Wsign-conversion
|
||||||
|
#-Wswitch-enum # Not used because this basically disallows default case
|
||||||
|
-Wunreachable-code-break # May be missing from GCC
|
||||||
|
-Wunused-macros
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# For C++ compiler
|
||||||
|
extract_valid_cxx_flags(WARNCXXFLAGS
|
||||||
|
-Wall
|
||||||
|
-Wformat-security
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# autotools-compatible names
|
||||||
|
# Sphinx expects relative paths in the .rst files. Use the fact that the files
|
||||||
|
# below are all one directory level deep.
|
||||||
|
file(RELATIVE_PATH top_srcdir "${CMAKE_CURRENT_BINARY_DIR}/dir" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
file(RELATIVE_PATH top_builddir "${CMAKE_CURRENT_BINARY_DIR}/dir" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
set(abs_top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
set(abs_top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
# libclamav.pc (pkg-config file)
|
||||||
|
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
|
||||||
|
set(sbindir "${CMAKE_INSTALL_FULL_SBINDIR}")
|
||||||
|
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||||
|
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
|
||||||
|
set(VERSION "${PACKAGE_VERSION}")
|
||||||
|
|
||||||
|
# DBDIR for systemd service.in files
|
||||||
|
set(DBDIR "${DATABASE_DIRECTORY}")
|
||||||
|
|
||||||
|
if(ENABLE_DEBUG)
|
||||||
|
set(CL_DEBUG 1)
|
||||||
|
endif()
|
||||||
|
if(ENABLE_EXPERIMENTAL)
|
||||||
|
set(CL_EXPERIMENTAL 1)
|
||||||
|
endif()
|
||||||
|
if(ENABLE_STRN_INTERNAL)
|
||||||
|
set(HAVE_STRNI 1)
|
||||||
|
endif()
|
||||||
|
if(ENABLE_FRESHCLAM_DNS_FIX)
|
||||||
|
set(FRESHCLAM_DNS_FIX 1)
|
||||||
|
endif()
|
||||||
|
if(ENABLE_FRESHCLAM_NO_CACHE)
|
||||||
|
set(FRESHCLAM_NO_CACHE 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SCANBUFF 131072) # scan buffer size
|
||||||
|
set(FILEBUFF 8192) # file i/o buffer size
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
set(C_DARWIN 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(config)
|
||||||
|
if(WIN32)
|
||||||
|
set(USE_MPOOL 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
|
configure_file(clamav-config.h.cmake.in clamav-config.h)
|
||||||
|
configure_file(target.h.cmake.in target.h)
|
||||||
|
configure_file(platform.h.in platform.h)
|
||||||
|
configure_file(clamav-version.h.in clamav-version.h)
|
||||||
|
configure_file(clamav-types.h.in clamav-types.h)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
#
|
||||||
|
# Windows-specific config stuff
|
||||||
|
#
|
||||||
|
|
||||||
|
# Windows resource file
|
||||||
|
set(CLAMAV_RES "")
|
||||||
|
configure_file(
|
||||||
|
win32/res/common.rc.in
|
||||||
|
${CMAKE_BINARY_DIR}/version.rc
|
||||||
|
@ONLY)
|
||||||
|
else()
|
||||||
|
#
|
||||||
|
# POSIX-specific config stuff
|
||||||
|
#
|
||||||
|
|
||||||
|
# Don't confuse clamav-config.in with clamav-config.h.in or clamav-config.h.cmake.in
|
||||||
|
configure_file(clamav-config.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/clamav-config
|
||||||
|
@ONLY)
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/clamav-config"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
|
PERMISSIONS
|
||||||
|
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||||
|
GROUP_READ GROUP_EXECUTE
|
||||||
|
WORLD_READ WORLD_EXECUTE)
|
||||||
|
|
||||||
|
# pkg-config
|
||||||
|
configure_file(
|
||||||
|
libclamav.pc.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libclamav.pc
|
||||||
|
@ONLY)
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libclamav.pc"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# ClamAV Build targets!
|
||||||
|
#
|
||||||
|
|
||||||
|
# Build targets for libraries.
|
||||||
|
if(ENABLE_UNRAR)
|
||||||
|
# Only build libclamunrar if enabled.
|
||||||
|
# We still define the libclamunrar_iface's interface regardless,
|
||||||
|
# so that libclamav will have unrar_iface.h in the include path.
|
||||||
|
add_subdirectory( libclamunrar )
|
||||||
|
endif()
|
||||||
|
add_subdirectory( libclamunrar_iface )
|
||||||
|
|
||||||
|
if(NOT ENABLE_EXTERNAL_MSPACK)
|
||||||
|
add_subdirectory(libclammspack)
|
||||||
|
else()
|
||||||
|
find_package(MSPack)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_subdirectory( win32/compat )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory( libclamav )
|
||||||
|
|
||||||
|
if(NOT LIBCLAMAV_ONLY)
|
||||||
|
add_subdirectory( shared )
|
||||||
|
|
||||||
|
add_subdirectory( libfreshclam )
|
||||||
|
|
||||||
|
if(ENABLE_APP)
|
||||||
|
# Build targets for primary applications.
|
||||||
|
add_subdirectory( clamconf )
|
||||||
|
|
||||||
|
add_subdirectory( clamd )
|
||||||
|
|
||||||
|
add_subdirectory( clamdscan )
|
||||||
|
|
||||||
|
if(LINUX AND ENABLE_CLAMONACC)
|
||||||
|
add_subdirectory( clamonacc )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WIN32 AND ENABLE_MILTER)
|
||||||
|
add_subdirectory( clamav-milter )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory( clamscan )
|
||||||
|
|
||||||
|
add_subdirectory( sigtool )
|
||||||
|
|
||||||
|
add_subdirectory( clambc )
|
||||||
|
|
||||||
|
add_subdirectory( clamsubmit )
|
||||||
|
|
||||||
|
add_subdirectory( freshclam )
|
||||||
|
|
||||||
|
add_subdirectory( clamdtop )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_subdirectory( win32/conf_examples )
|
||||||
|
else()
|
||||||
|
add_subdirectory( etc )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_EXAMPLES)
|
||||||
|
add_subdirectory( examples )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_DOCS)
|
||||||
|
add_subdirectory( docs )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_FUZZ)
|
||||||
|
add_subdirectory( fuzz )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# The Summary Info.
|
||||||
|
#
|
||||||
|
include(ColourMessage)
|
||||||
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
|
||||||
|
message(STATUS "${Y}Configuration Options Summary${e} --
|
||||||
|
${c} Package Version: ${e}${PACKAGE_STRING}
|
||||||
|
${c} libclamav version: ${e}${LIBCLAMAV_CURRENT}:${LIBCLAMAV_REVISION}:${LIBCLAMAV_AGE}
|
||||||
|
${c} libfreshclam version: ${e}${LIBFRESHCLAM_CURRENT}:${LIBFRESHCLAM_REVISION}:${LIBFRESHCLAM_AGE}
|
||||||
|
${c} Install prefix: ${e}${CMAKE_INSTALL_PREFIX}
|
||||||
|
${c} Target system: ${e}${CMAKE_SYSTEM}
|
||||||
|
${c} Compiler: ${e}
|
||||||
|
${b} Build type: ${e}${CMAKE_BUILD_TYPE}
|
||||||
|
${b} C compiler: ${e}${CMAKE_C_COMPILER}
|
||||||
|
${b} CFLAGS: ${e}${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS}
|
||||||
|
${b} WARNCFLAGS: ${e}${WARNCFLAGS}
|
||||||
|
${c} Build Options: ${e}
|
||||||
|
${b} Build apps: ${e}${ENABLE_APP}
|
||||||
|
${b} Shared library: ${e}${ENABLE_SHARED_LIB}
|
||||||
|
${b} Static library: ${e}${ENABLE_STATIC_LIB}
|
||||||
|
${b} Enable UnRAR: ${e}${ENABLE_UNRAR}
|
||||||
|
${b} Examples: ${e}${ENABLE_EXAMPLES}
|
||||||
|
${b} Build man pages: ${e}${ENABLE_DOCS}
|
||||||
|
${b} Build doxygen HTML: ${e}${ENABLE_DOXYGEN}")
|
||||||
|
if(NOT WIN32)
|
||||||
|
message("\
|
||||||
|
${c} Build Extras: ${e}")
|
||||||
|
message("\
|
||||||
|
${b} Build milter: ${e}${ENABLE_MILTER} (toggle with -DENABLE_MILTER=ON/OFF)")
|
||||||
|
if(LINUX)
|
||||||
|
message("\
|
||||||
|
${b} Build clamonacc: ${e}${ENABLE_CLAMONACC} (toggle with -DENABLE_CLAMONACC=ON/OFF)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LLVM_FOUND)
|
||||||
|
message(STATUS "${C}Engine Options${e} --
|
||||||
|
${b} Bytecode Runtime: ${e}
|
||||||
|
${_} ${BYTECODE_RUNTIME} ${e}${LLVM_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${LLVM_LDFLAGS} ${LLVM_LIBRARIES}
|
||||||
|
${_} ${e}${LLVM_LIBRARY_DIRS}")
|
||||||
|
else()
|
||||||
|
message(STATUS "${C}Engine Options${e} --
|
||||||
|
${b} Bytecode Runtime: ${e}
|
||||||
|
${_} ${BYTECODE_RUNTIME} ${e}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "${C}libclamav Dependencies${e} --
|
||||||
|
${b} Compression support:${e}
|
||||||
|
${_} bzip2 ${e}${BZIP2_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${BZIP2_LIBRARIES}
|
||||||
|
${_} zlib ${e}${ZLIB_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${ZLIB_LIBRARIES}
|
||||||
|
${b} XML support: ${e}
|
||||||
|
${_} libxml2 ${e}${LIBXML2_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${LIBXML2_LIBRARIES}
|
||||||
|
${b} RegEx support: ${e}
|
||||||
|
${_} libpcre2 ${e}${PCRE2_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${PCRE2_LIBRARIES}
|
||||||
|
${b} Crypto support: ${e}
|
||||||
|
${_} openssl ${e}${OPENSSL_INCLUDE_DIR}
|
||||||
|
${_} ${e}${OPENSSL_LIBRARIES}
|
||||||
|
${b} JSON support: ${e}
|
||||||
|
${_} json-c ${e}${JSONC_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${JSONC_LIBRARIES}
|
||||||
|
${b} Threading support: ${e}")
|
||||||
|
if (WIN32)
|
||||||
|
message("\
|
||||||
|
${_} pthread-win32 ${e}${PThreadW32_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${PThreadW32_LIBRARIES}")
|
||||||
|
elseif(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
|
||||||
|
message("\
|
||||||
|
${_} pthread ${e}")
|
||||||
|
else()
|
||||||
|
message("\
|
||||||
|
${o} no ${e}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "${C}libfreshclam Extra Dependencies${e} --
|
||||||
|
${b} HTTP support: ${e}
|
||||||
|
${_} curl ${e}${CURL_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${CURL_LIBRARIES}")
|
||||||
|
|
||||||
|
if(HAVE_LIBNCURSES)
|
||||||
|
message(STATUS "${C}Application Extra Dependencies${e} --
|
||||||
|
${b} GUI support: ${e}
|
||||||
|
${_} ncurses ${e}${CURSES_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${CURSES_LIBRARIES}")
|
||||||
|
elseif(HAVE_LIBPDCURSES)
|
||||||
|
message(STATUS "${C}Application Extra Dependencies${e} --
|
||||||
|
${b} GUI support: ${e}
|
||||||
|
${_} pdcurses ${e}${CURSES_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${CURSES_LIBRARIES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LINUX)
|
||||||
|
if(SYSTEMD_PROGRAM_FOUND)
|
||||||
|
message("\
|
||||||
|
${b} systemd: ${e}
|
||||||
|
${_} unit directory ${e}${SYSTEMD_UNIT_DIR}
|
||||||
|
${b} systemd ctl support: ${e}")
|
||||||
|
if(SYSTEMD_FOUND)
|
||||||
|
message("\
|
||||||
|
${_} libsystemd ${e}${SYSTEMD_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${SYSTEMD_LIBRARIES}")
|
||||||
|
else()
|
||||||
|
message("\
|
||||||
|
${_} libsystemd ${e}not found")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message("\
|
||||||
|
${b} systemd: ${e}not found")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_MILTER)
|
||||||
|
message("\
|
||||||
|
${b} Milter Support: ${e}
|
||||||
|
${_} libmilter ${e}${Milter_INCLUDE_DIRS}
|
||||||
|
${_} ${e}${Milter_LIBRARIES}")
|
||||||
|
endif()
|
||||||
|
message("")
|
||||||
|
|
||||||
|
if(NOT JSONC_USE_STATIC)
|
||||||
|
message(STATUS "${g}Warning:${e} libjson-c is known to share symbol names with other JSON libraries which may result in crashes for applications that use libclamav. Consider providing a static json-c library that was compiled with: CFLAGS=\"-fPIC\". Default build settings for json-c 0.15+ should also work. Use the `-DENABLE_JSON_SHARED=OFF` option to prefer detection of the static library, or use -DJSONC_INCLUDE_DIR and -DJSONC_LIBRARY to specify the static JSON library.")
|
||||||
|
endif()
|
108
CMakeOptions.cmake
Normal file
108
CMakeOptions.cmake
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# Features that can be enabled for cmake (see CMakeLists.txt)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(APP_CONFIG_DIRECTORY
|
||||||
|
"${CMAKE_INSTALL_PREFIX}" CACHE STRING
|
||||||
|
"App Config directory.")
|
||||||
|
set(DATABASE_DIRECTORY
|
||||||
|
"${CMAKE_INSTALL_PREFIX}/database" CACHE STRING
|
||||||
|
"Database directory.")
|
||||||
|
else()
|
||||||
|
set(APP_CONFIG_DIRECTORY
|
||||||
|
"${CMAKE_INSTALL_PREFIX}/etc" CACHE STRING
|
||||||
|
"App Config directory.")
|
||||||
|
set(DATABASE_DIRECTORY
|
||||||
|
"${CMAKE_INSTALL_PREFIX}/share/clamav" CACHE STRING
|
||||||
|
"Database directory.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CLAMAV_USER "clamav" CACHE STRING "ClamAV User")
|
||||||
|
set(CLAMAV_GROUP "clamav" CACHE STRING "ClamAV Group")
|
||||||
|
|
||||||
|
set(MMAP_FOR_CROSSCOMPILING
|
||||||
|
0 CACHE STRING
|
||||||
|
"Force MMAP support for cross-compiling.")
|
||||||
|
set(DISABLE_MPOOL
|
||||||
|
0 CACHE STRING
|
||||||
|
"Disable mpool support entirely.")
|
||||||
|
|
||||||
|
set(BYTECODE_RUNTIME
|
||||||
|
"interpreter" CACHE STRING
|
||||||
|
"Bytecode Runtime, may be: 'llvm', 'interpreter', 'none'.")
|
||||||
|
|
||||||
|
option(OPTIMIZE
|
||||||
|
"Allow compiler optimizations. Set to OFF to disable (i.e. to set -O0)."
|
||||||
|
ON)
|
||||||
|
|
||||||
|
option(ENABLE_WERROR
|
||||||
|
"Compile time warnings will cause build failures.")
|
||||||
|
|
||||||
|
option(ENABLE_ALL_THE_WARNINGS
|
||||||
|
"Enable as many compiler warnings as possible.")
|
||||||
|
|
||||||
|
option(ENABLE_DEBUG
|
||||||
|
"Turn on extra debug output.")
|
||||||
|
|
||||||
|
option(ENABLE_EXPERIMENTAL
|
||||||
|
"Turn on experimental features (if any).")
|
||||||
|
|
||||||
|
option(ENABLE_FRESHCLAM_DNS_FIX
|
||||||
|
"Enable workaround for broken DNS servers.")
|
||||||
|
|
||||||
|
option(ENABLE_FRESHCLAM_NO_CACHE
|
||||||
|
"Use 'Cache-Control: no-cache' in freshclam.")
|
||||||
|
|
||||||
|
option(ENABLE_STRN_INTERNAL
|
||||||
|
"Enables explicit use of internal strn functions to support cross-compilation against older libs.")
|
||||||
|
|
||||||
|
option(ENABLE_FUZZ
|
||||||
|
"Build fuzz targets. Will enable ENABLE_STATIC_LIB for you.")
|
||||||
|
|
||||||
|
option(ENABLE_EXTERNAL_MSPACK
|
||||||
|
"Use external mspack instead of internal libclammspack.")
|
||||||
|
|
||||||
|
option(ENABLE_JSON_SHARED
|
||||||
|
"Prefer linking with libjson-c shared library instead of static."
|
||||||
|
ON)
|
||||||
|
|
||||||
|
option(ENABLE_APP
|
||||||
|
"Build applications (clamscan, clamd, clamdscan, clamonacc, sigtool, clambc, clamav-milter, clamdtop, clamsubmit, clamconf)."
|
||||||
|
${ENABLE_APP_DEFAULT})
|
||||||
|
|
||||||
|
option(ENABLE_MILTER
|
||||||
|
"Build clamav-milter (requires ENABLE_APP))."
|
||||||
|
${ENABLE_MILTER_DEFAULT})
|
||||||
|
|
||||||
|
option(ENABLE_CLAMONACC
|
||||||
|
"Build clamonacc (Linux-only, requires ENABLE_APP))."
|
||||||
|
${ENABLE_CLAMONACC_DEFAULT})
|
||||||
|
|
||||||
|
option(ENABLE_DOCS
|
||||||
|
"Generate documentation."
|
||||||
|
${ENABLE_DOCS_DEFAULT})
|
||||||
|
|
||||||
|
option(ENABLE_DOXYGEN
|
||||||
|
"Generate doxygen HTML documentation for clamav.h, libfreshclam.h."
|
||||||
|
${ENABLE_DOXYGEN_DEFAULT})
|
||||||
|
|
||||||
|
option(ENABLE_EXAMPLES
|
||||||
|
"Build examples."
|
||||||
|
${ENABLE_EXAMPLES_DEFAULT})
|
||||||
|
|
||||||
|
option(ENABLE_LIBCLAMAV_ONLY
|
||||||
|
"Build libclamav only. Excludes libfreshclam too!")
|
||||||
|
|
||||||
|
option(ENABLE_STATIC_LIB
|
||||||
|
"Build libclamav and/or libfreshclam static libraries.")
|
||||||
|
|
||||||
|
option(ENABLE_SHARED_LIB
|
||||||
|
"Build libclamav and/or libfreshclam shared libraries."
|
||||||
|
ON)
|
||||||
|
|
||||||
|
option(ENABLE_UNRAR
|
||||||
|
"Build & install libclamunrar."
|
||||||
|
${ENABLE_UNRAR_DEFAULT})
|
||||||
|
|
||||||
|
option(ENABLE_SYSTEMD
|
||||||
|
"Install systemd service files if systemd is found."
|
||||||
|
${ENABLE_SYSTEMD_DEFAULT})
|
548
INSTALL.cmake.md
Normal file
548
INSTALL.cmake.md
Normal file
|
@ -0,0 +1,548 @@
|
||||||
|
# Installation Instructions
|
||||||
|
|
||||||
|
**CAUTION**: ClamAV CMake support is experimental in this release and is not
|
||||||
|
recommended for production systems!!!
|
||||||
|
|
||||||
|
Please help us stabilize it so we can deprecate autotools and Visual Studio.
|
||||||
|
|
||||||
|
_Known Issues / To-do:_
|
||||||
|
|
||||||
|
- Support for building unit tests / feature tests and running with CTest
|
||||||
|
- A portion of this task will involve converting the shell scripts portions
|
||||||
|
to Python unit tests.
|
||||||
|
- Build fuzz targets.
|
||||||
|
- LLVM bytecode runtime support.
|
||||||
|
- Presently only the bytecode intepreter is supported. LLVM is preferable
|
||||||
|
because it is faster. This task also requires updating to use a modern
|
||||||
|
version of LLVM. Currently ClamAV is limited to LLVM 3.6.
|
||||||
|
- The built-in LLVM runtime is not supported in the CMake tooling with no
|
||||||
|
plans to add support. It will likely be removed when system-LLVM support
|
||||||
|
is updated.
|
||||||
|
- Complete the MAINTAINER_MODE option to generate files with GPerf.
|
||||||
|
|
||||||
|
- [Installation Instructions](#installation-instructions)
|
||||||
|
- [CMake Basics](#cmake-basics)
|
||||||
|
- [Basic Release build & system install](#basic-release-build--system-install)
|
||||||
|
- [Basic Debug build](#basic-debug-build)
|
||||||
|
- [Build and install to a specific install location (prefix)](#build-and-install-to-a-specific-install-location-prefix)
|
||||||
|
- [Build using Ninja](#build-using-ninja)
|
||||||
|
- [Build and run tests](#build-and-run-tests)
|
||||||
|
- [Custom CMake options](#custom-cmake-options)
|
||||||
|
- [Custom Library Paths](#custom-library-paths)
|
||||||
|
- [Example Build Commands](#example-build-commands)
|
||||||
|
- [Linux release build, install to system](#linux-release-build-install-to-system)
|
||||||
|
- [macOS debug build, custom OpenSSL path, build examples, local install](#macos-debug-build-custom-openssl-path-build-examples-local-install)
|
||||||
|
- [Windows Build](#windows-build)
|
||||||
|
- [External Depedencies](#external-depedencies)
|
||||||
|
- [libclamav dependencies](#libclamav-dependencies)
|
||||||
|
- [libfreshclam dependencies](#libfreshclam-dependencies)
|
||||||
|
- [Application dependencies](#application-dependencies)
|
||||||
|
- [Dependency build options](#dependency-build-options)
|
||||||
|
- [bzip2](#bzip2)
|
||||||
|
- [zlib](#zlib)
|
||||||
|
- [libxml2](#libxml2)
|
||||||
|
- [libpcre2](#libpcre2)
|
||||||
|
- [openssl (libcrypto, libssl)](#openssl-libcrypto-libssl)
|
||||||
|
- [libjson-c](#libjson-c)
|
||||||
|
- [libmspack](#libmspack)
|
||||||
|
- [iconv (POSIX-only)](#iconv-posix-only)
|
||||||
|
- [pthreads-win32 (Windows-only)](#pthreads-win32-windows-only)
|
||||||
|
- [llvm (optional, _see "Bytecode Runtime" section_)](#llvm-optional-see-bytecode-runtime-section)
|
||||||
|
- [libcurl](#libcurl)
|
||||||
|
- [ncurses or pdcurses, for clamdtop](#ncurses-or-pdcurses-for-clamdtop)
|
||||||
|
- [Bytecode Runtime](#bytecode-runtime)
|
||||||
|
- [Compilers and Options](#compilers-and-options)
|
||||||
|
- [Compiling For Multiple Architectures](#compiling-for-multiple-architectures)
|
||||||
|
|
||||||
|
## CMake Basics
|
||||||
|
|
||||||
|
Build requirements:
|
||||||
|
|
||||||
|
- CMake 3.13+
|
||||||
|
- A C-toolchain such as gcc, clang, or Microsoft Visual Studio.
|
||||||
|
- Flex and Bison. On Windows, `choco install winflexbison`.
|
||||||
|
|
||||||
|
_Important_: The following instructions assume that you have created a `build`
|
||||||
|
subdirectory and that subsequent commands are performed from said directory,
|
||||||
|
like so:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir build && cd build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Basic Release build & system install
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE="Release"
|
||||||
|
cmake --build . --config Release
|
||||||
|
sudo cmake --build . --config Release --target install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Basic Debug build
|
||||||
|
|
||||||
|
In CMake, "Debug" builds mean that symbols are compiled in.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE="Debug"
|
||||||
|
cmake --build . --config Debug
|
||||||
|
```
|
||||||
|
|
||||||
|
You will likely also wish to disable compiler/linker optimizations, which you
|
||||||
|
can do like so, using our custom `OPTIMIZE` option:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE="Debug" -DOPTIMIZE=OFF
|
||||||
|
cmake --build . --config Debug
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build and install to a specific install location (prefix)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX:PATH=install ..
|
||||||
|
cmake --build . --target install --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build using Ninja
|
||||||
|
|
||||||
|
This build uses Ninja (ninja-build) instead of Make. It's _really_ fast.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -G Ninja
|
||||||
|
cmake --build . --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build and run tests
|
||||||
|
|
||||||
|
_TODO_: We have not yet added unit test support for CMake.
|
||||||
|
|
||||||
|
- `-V`: Verbose
|
||||||
|
|
||||||
|
- `-C <config>`: Specify build configuration (i.e. Debug / Release), required
|
||||||
|
for Windows builds
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake ..
|
||||||
|
cmake --build . --config Release
|
||||||
|
ctest -C Release -V
|
||||||
|
```
|
||||||
|
|
||||||
|
## Custom CMake options
|
||||||
|
|
||||||
|
The following CMake options can be selected by using `-D`. For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -DENABLE_EXAMPLES
|
||||||
|
cmake --build . --config Debug
|
||||||
|
```
|
||||||
|
|
||||||
|
- `APP_CONFIG_DIRECTORY`: App Config directory.
|
||||||
|
|
||||||
|
_Default: Windows: `{prefix}`, POSIX: `{prefix}/etc`_
|
||||||
|
|
||||||
|
- `DATABASE_DIRECTORY`: Database directory.
|
||||||
|
|
||||||
|
_Default: Windows: `{prefix}/database`, POSIX: `{prefix}/share/clamav`_
|
||||||
|
|
||||||
|
- `CLAMAV_USER`: ClamAV User (POSIX-only).
|
||||||
|
|
||||||
|
_Default: `clamav`_
|
||||||
|
|
||||||
|
- `CLAMAV_GROUP`: ClamAV Group (POSIX-only).
|
||||||
|
|
||||||
|
_Default: `clamav`_
|
||||||
|
|
||||||
|
- `MMAP_FOR_CROSSCOMPILING`: Force MMAP support for cross-compiling.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `DISABLE_MPOOL`: Disable mpool support entirely.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `BYTECODE_RUNTIME`: Bytecode Runtime, may be: `llvm`, `interpreter`, `none`.
|
||||||
|
|
||||||
|
_Default: `interpreter`_
|
||||||
|
|
||||||
|
- `OPTIMIZE`: Allow compiler optimizations (eg. `-O3`). Set to `OFF` to disable
|
||||||
|
them (`-O0`).
|
||||||
|
|
||||||
|
_Default: `ON`_
|
||||||
|
|
||||||
|
- `ENABLE_WERROR`: Compile time warnings will cause build failures (i.e.
|
||||||
|
`-Werror`)
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_ALL_THE_WARNINGS`: By default we use `-Wall -Wextra -Wformat-security`
|
||||||
|
for clamav libs and apps. This option enables a whole lot more.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_DEBUG`: Turn on extra debug output.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_FUZZ`: Build fuzz targets. Will enable `ENABLE_STATIC_LIB` for you.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_EXTERNAL_MSPACK`: Use external mspack instead of internal libclammspack.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_JSON_SHARED`: Prefer linking with libjson-c shared library instead of
|
||||||
|
static. Please set this to `OFF` if you're an application developer that uses
|
||||||
|
a different JSON library in your app, or if you provide libclamav to others.
|
||||||
|
|
||||||
|
_Default: `ON`_
|
||||||
|
|
||||||
|
- `ENABLE_APP`: Build applications (clamscan, clamd, clamdscan, sigtool,
|
||||||
|
clambc, clamdtop, clamsubmit, clamconf).
|
||||||
|
|
||||||
|
_Default: `ON`_
|
||||||
|
|
||||||
|
- `ENABLE_CLAMONACC`: (Linux-only) Build the clamonacc on-access scanning daemon.
|
||||||
|
Requires: `ENABLE_APP`
|
||||||
|
|
||||||
|
_Default: `ON`_
|
||||||
|
|
||||||
|
- `ENABLE_MILTER`: (Posix-only) Build the clamav-milter mail filter daemon.
|
||||||
|
Requires: `ENABLE_APP`
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_UNRAR`: Build & install libclamunrar (UnRAR) and libclamunrar_iface.
|
||||||
|
|
||||||
|
_Default: `ON`_
|
||||||
|
|
||||||
|
- `ENABLE_DOCS`: Generate man pages.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_DOXYGEN`: Generate doxygen HTML documentation for clamav.h,
|
||||||
|
libfreshclam.h. Requires doxygen.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_EXAMPLES`: Build examples.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_LIBCLAMAV_ONLY`: Build libclamav only. Excludes libfreshclam too!
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_STATIC_LIB`: Build libclamav and/or libfreshclam static libraries.
|
||||||
|
|
||||||
|
_Default: `OFF`_
|
||||||
|
|
||||||
|
- `ENABLE_SHARED_LIB`: Build libclamav and/or libfreshclam shared libraries.
|
||||||
|
|
||||||
|
_Default: `ON`_
|
||||||
|
|
||||||
|
- `ENABLE_SYSTEMD`: Install systemd service files if systemd is found.
|
||||||
|
|
||||||
|
_Default: `ON`_
|
||||||
|
|
||||||
|
- `SYSTEMD_UNIT_DIR`: Install systemd service files to a specific directory.
|
||||||
|
This will fail the build if systemd not found.
|
||||||
|
|
||||||
|
_Default: not set_
|
||||||
|
|
||||||
|
## Custom Library Paths
|
||||||
|
|
||||||
|
### Example Build Commands
|
||||||
|
|
||||||
|
#### Linux release build, install to system
|
||||||
|
|
||||||
|
This example sets the build system to Ninja instead of using Make, for speed.
|
||||||
|
You may need to first use `apt`/`dnf`/`pkg` to install `ninja-build`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DENABLE_JSON_SHARED=OFF
|
||||||
|
ninja
|
||||||
|
sudo ninja install
|
||||||
|
```
|
||||||
|
|
||||||
|
#### macOS debug build, custom OpenSSL path, build examples, local install
|
||||||
|
|
||||||
|
macOS builds use Homebrew to install `flex`, `bison`, and each of the library
|
||||||
|
dependencies.
|
||||||
|
|
||||||
|
Note that explicit paths for OpenSSL are requires so as to avoid using an older
|
||||||
|
OpenSSL install provided by the operating system.
|
||||||
|
|
||||||
|
This example also:
|
||||||
|
|
||||||
|
- Build system to Ninja instead of using Make.
|
||||||
|
- You may need to first use `brew` to install `ninja`.
|
||||||
|
- Sets build type to "Debug" and explicitly disables compiler optimizations.
|
||||||
|
- Builds static libraries (and also shared libraries, which are on by default).
|
||||||
|
- Builds the example programs, just to test them out.
|
||||||
|
- Sets the install path (prefix) to ./install
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
|
-DOPTIMIZE=OFF \
|
||||||
|
-DENABLE_JSON_SHARED=OFF \
|
||||||
|
-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1/ \
|
||||||
|
-DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib \
|
||||||
|
-DOPENSSL_SSL_LIBRARY=/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib \
|
||||||
|
-DENABLE_STATIC_LIB=ON \
|
||||||
|
-DENABLE_EXAMPLES=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=install
|
||||||
|
ninja
|
||||||
|
ninja install
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Windows Build
|
||||||
|
|
||||||
|
Chocolatey (`choco`) is used to install `winflexbison` and `cmake`.
|
||||||
|
Visual Studio 2015+ is required, 2017+ recommended.
|
||||||
|
|
||||||
|
These instructions assume that `$env:CLAMAV_DEPENDENCIES` is set to your
|
||||||
|
[Mussels](https://github.com/Cisco-Talos/Mussels) `install\x64` directory and
|
||||||
|
that you've used Mussels to build the `clamav_deps` collection which will
|
||||||
|
provide the required libraries.
|
||||||
|
|
||||||
|
_Tip_: Instead of building manually, try using Mussels to automate your build!
|
||||||
|
|
||||||
|
```ps1
|
||||||
|
$env:CLAMAV_DEPENDENCIES="$env:userprofile\.mussels\install\x64"
|
||||||
|
cmake .. -G "Visual Studio 15 2017" -A x64 `
|
||||||
|
-DJSONC_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include\json-c" `
|
||||||
|
-DJSONC_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\json-c.lib" `
|
||||||
|
-DBZIP2_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DBZIP2_LIBRARY_RELEASE="$env:CLAMAV_DEPENDENCIES\lib\libbz2.lib" `
|
||||||
|
-DCURL_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DCURL_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\libcurl_imp.lib" `
|
||||||
|
-DOPENSSL_ROOT_DIR="$env:CLAMAV_DEPENDENCIES" `
|
||||||
|
-DOPENSSL_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DOPENSSL_CRYPTO_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\libcrypto.lib" `
|
||||||
|
-DZLIB_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\libssl.lib" `
|
||||||
|
-DLIBXML2_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DLIBXML2_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\libxml2.lib" `
|
||||||
|
-DPCRE2_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DPCRE2_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\pcre2-8.lib" `
|
||||||
|
-DCURSES_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DCURSES_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\pdcurses.lib" `
|
||||||
|
-DPThreadW32_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DPThreadW32_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\pthreadVC2.lib" `
|
||||||
|
-DZLIB_INCLUDE_DIR="$env:CLAMAV_DEPENDENCIES\include" `
|
||||||
|
-DZLIB_LIBRARY="$env:CLAMAV_DEPENDENCIES\lib\zlibstatic.lib" `
|
||||||
|
-DCMAKE_INSTALL_PREFIX="install"
|
||||||
|
cmake --build . --config Release --target install
|
||||||
|
copy $env:CLAMAV_DEPENDENCIES\lib\* .\install
|
||||||
|
```
|
||||||
|
|
||||||
|
_Tip_: If you're having include-path issues, try building with detailed verbosity:
|
||||||
|
|
||||||
|
```ps1
|
||||||
|
cmake --build . --config Release --target install -- /verbosity:detailed
|
||||||
|
```
|
||||||
|
|
||||||
|
### External Depedencies
|
||||||
|
|
||||||
|
The CMake tooling is good about finding installed dependencies on POSIX systems.
|
||||||
|
|
||||||
|
_Important_: Linux users will want the "-dev" or "-devel" package variants
|
||||||
|
which include C headers. For macOS, Homebrew doesn't separate the headers.
|
||||||
|
|
||||||
|
#### libclamav dependencies
|
||||||
|
|
||||||
|
App developers that only need libclamav can use the `-DENABLE_LIBCLAMAV_ONLY`
|
||||||
|
option to bypass ClamAV app dependencies.
|
||||||
|
|
||||||
|
libclamav requires these library dependencies:
|
||||||
|
|
||||||
|
- bzip2
|
||||||
|
- zlib
|
||||||
|
- libxml2
|
||||||
|
- libpcre2
|
||||||
|
- openssl
|
||||||
|
- libjson-c
|
||||||
|
- iconv (POSIX-only, may be provided by system)
|
||||||
|
- pthreads (or on Windows: pthreads-win32)
|
||||||
|
- llvm (optional, _see [Bytecode Runtime](#bytecode-runtime))
|
||||||
|
|
||||||
|
#### libfreshclam dependencies
|
||||||
|
|
||||||
|
If you want libclamav _and_ libfreshclam for your app, then use the
|
||||||
|
`-DENABLE_APP=OFF` option instead.
|
||||||
|
|
||||||
|
libfreshclam adds these additional library dependencies:
|
||||||
|
|
||||||
|
- libcurl
|
||||||
|
|
||||||
|
#### Application dependencies
|
||||||
|
|
||||||
|
For regular folk who want the ClamAV apps, you'll also need:
|
||||||
|
|
||||||
|
- ncurses (or pdcurses), for clamdtop.
|
||||||
|
- systemd, so clamd, freshclam, clamonacc may run as a systemd service (Linux).
|
||||||
|
- libsystemd, so clamd will support the clamd.ctl socket (Linux).
|
||||||
|
|
||||||
|
#### Dependency build options
|
||||||
|
|
||||||
|
If you have custom install paths for the dependencies on your system or are
|
||||||
|
on Windows, you may need to use the following options...
|
||||||
|
|
||||||
|
##### bzip2
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DBZIP2_INCLUDE_DIR="_filepath of bzip2 header directory_"
|
||||||
|
-DBZIP2_LIBRARIES="_filepath of bzip2 library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### zlib
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DZLIB_INCLUDE_DIR="_filepath of zlib header directory_"
|
||||||
|
-DZLIB_LIBRARY="_filepath of zlib library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### libxml2
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DLIBXML2_INCLUDE_DIR="_filepath of libxml2 header directory_"
|
||||||
|
-DLIBXML2_LIBRARY="_filepath of libxml2 library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### libpcre2
|
||||||
|
|
||||||
|
Hints to find libcpre2 package:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DPCRE2_DIR="_path to libpcre2 install root_"
|
||||||
|
```
|
||||||
|
|
||||||
|
Or, explicitly set header & library paths:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DPCRE2_INCLUDE_DIR="_filepath of libpcre2 header directory_"
|
||||||
|
-DPCRE2_LIBRARY="_filepath of libcpre2 library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### openssl (libcrypto, libssl)
|
||||||
|
|
||||||
|
Hints to find openssl package:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DOPENSSL_ROOT_DIR="_path to openssl install root_"
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DOPENSSL_INCLUDE_DIR="_filepath of openssl header directory_"
|
||||||
|
-DOPENSSL_CRYPTO_LIBRARY="_filepath of libcrypto library_"
|
||||||
|
-DOPENSSL_SSL_LIBRARY="_filepath of libcrypto library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### libjson-c
|
||||||
|
|
||||||
|
Tip: You're strongly encouraged to link with the a static json-c library.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DJSONC_INCLUDE_DIR="_path to json-c header directory_"
|
||||||
|
-DJSONC_LIBRARY="_filepath of json-c library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### libmspack
|
||||||
|
|
||||||
|
These options only apply if you use the `-DENABLE_EXTERNAL_MSPACK=ON` option.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DMSPack_INCLUDE_DIR="_path to mspack header directory_"
|
||||||
|
-DMSPack_LIBRARY="_filepath of libmspack library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### iconv (POSIX-only)
|
||||||
|
|
||||||
|
On POSIX platforms, iconv might be part of the C library in which case you
|
||||||
|
would not want to specify an external iconv library.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DIconv_INCLUDE_DIR="_path to iconv header directory_"
|
||||||
|
-DIconv_LIBRARY="_filepath of iconv library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### pthreads-win32 (Windows-only)
|
||||||
|
|
||||||
|
On POSIX platforms, pthread support is detected automatically. On Windows, you
|
||||||
|
need to specify the following:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DPThreadW32_INCLUDE_DIR="_path to pthread-win32 header directory_"
|
||||||
|
-DPThreadW32_LIBRARY="_filepath of pthread-win32 library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### llvm (optional, _see "Bytecode Runtime" section_)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DBYTECODE_RUNTIME="llvm"
|
||||||
|
-DLLVM_ROOT_DIR="_path to llvm install root_" -DLLVM_FIND_VERSION="3.6.0"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### libcurl
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DCURL_INCLUDE_DIR="_path to curl header directory_"
|
||||||
|
-DCURL_LIBRARY="_filepath of curl library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### ncurses or pdcurses, for clamdtop
|
||||||
|
|
||||||
|
```sh
|
||||||
|
-DCURSES_INCLUDE_DIR="_path to curses header directory_"
|
||||||
|
-DCURSES_LIBRARY="_filepath of curses library_"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Bytecode Runtime
|
||||||
|
|
||||||
|
Bytecode signatures are a type of executable plugin that provide extra
|
||||||
|
detection capabilities.
|
||||||
|
|
||||||
|
ClamAV has two bytecode runtimes:
|
||||||
|
|
||||||
|
- *LLVM*: LLVM is the preferred runtime.
|
||||||
|
|
||||||
|
With LLVM, ClamAV JIT compiles bytecode signatures at database load time.
|
||||||
|
Bytecode signature execution is faster with LLVM.
|
||||||
|
|
||||||
|
- *Interpreter*: The bytecode interpreter is an option on systems where a
|
||||||
|
a supported LLVM version is not available.
|
||||||
|
|
||||||
|
With the interpreter, signature database (re)loads are faster, but execution
|
||||||
|
time is slower.
|
||||||
|
|
||||||
|
At the moment, the interpreter is the default runtime, while we work out
|
||||||
|
compatibility issues with libLLVM. This default equates to:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -DBYTECODE_RUNTIME="interpreter"
|
||||||
|
```
|
||||||
|
|
||||||
|
To build using LLVM instead of the intereter, use:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. \
|
||||||
|
-DBYTECODE_RUNTIME="llvm" \
|
||||||
|
-DLLVM_ROOT_DIR="/opt/llvm/3.6" \
|
||||||
|
-DLLVM_FIND_VERSION="3.6.0"
|
||||||
|
```
|
||||||
|
|
||||||
|
To disable bytecode signature support entire, you may build with this option:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake .. -DBYTECODE_RUNTIME="none"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compilers and Options
|
||||||
|
|
||||||
|
_TODO_: Describe how to customize compiler toolchain with CMake.
|
||||||
|
|
||||||
|
## Compiling For Multiple Architectures
|
||||||
|
|
||||||
|
_TODO_: Describe how to cross-compile with CMake.
|
|
@ -25,8 +25,8 @@ SUBDIRS = libclamav
|
||||||
bin_SCRIPTS=clamav-config
|
bin_SCRIPTS=clamav-config
|
||||||
|
|
||||||
else
|
else
|
||||||
SUBDIRS = libltdl libclamav libfreshclam clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test clamdtop clambc unit_tests
|
SUBDIRS = libltdl libclamav shared libfreshclam clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test clamdtop clambc unit_tests
|
||||||
EXTRA_DIST = examples shared libclamav.pc.in COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.llvm COPYING.file COPYING.zlib COPYING.getopt COPYING.regex COPYING.YARA COPYING.pcre platform.h.in libclamunrar libclamunrar_iface libclammspack clamdscan/clamdscan.map win32 ChangeLog.md INSTALL.md NEWS.md README.md
|
EXTRA_DIST = examples shared libclamav.pc.in COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.llvm COPYING.file COPYING.zlib COPYING.getopt COPYING.regex COPYING.YARA COPYING.pcre platform.h.in libclamunrar libclamunrar_iface libclammspack clamdscan/clamdscan.map win32 ChangeLog.md INSTALL.cmake.md INSTALL.autotools.md NEWS.md README.md cmake CMakeLists.txt CMakeOptions.cmake $(top_srcdir)/**/CMakeLists.txt libclammspack/config.h.in.cmake clamav-config.h.cmake.in target.h.cmake.in
|
||||||
|
|
||||||
bin_SCRIPTS=clamav-config
|
bin_SCRIPTS=clamav-config
|
||||||
|
|
||||||
|
|
12
NEWS.md
12
NEWS.md
|
@ -51,6 +51,11 @@ ClamAV 0.103.0 includes the following improvements and changes.
|
||||||
at the end of a scan, but for now this detail will help users understand why
|
at the end of a scan, but for now this detail will help users understand why
|
||||||
a given file is being flagged as phishing.
|
a given file is being flagged as phishing.
|
||||||
|
|
||||||
|
- Added new *experimental* CMake build tooling. CMake is not yet recommended for
|
||||||
|
production builds. Our team would appreciate any assistance improving the
|
||||||
|
CMake build tooling so we can one day deprecate Autotools and remove the
|
||||||
|
Visual Studio solutions.
|
||||||
|
|
||||||
### Other improvements
|
### Other improvements
|
||||||
|
|
||||||
- Added ability for freshclam and clamsubmit to override default use of openssl
|
- Added ability for freshclam and clamsubmit to override default use of openssl
|
||||||
|
@ -98,6 +103,13 @@ ClamAV 0.103.0 includes the following improvements and changes.
|
||||||
|
|
||||||
### New Requirements
|
### New Requirements
|
||||||
|
|
||||||
|
- Autotools (automake, autoconf, m4, pkg-config, libtool) are now required in
|
||||||
|
order to build from a Git clone.
|
||||||
|
Users building from the release tarball should be unaffected.
|
||||||
|
|
||||||
|
- Flex and Bison are now required in order to build from a Git clone.
|
||||||
|
Users building from the release tarball should be unaffected.
|
||||||
|
|
||||||
### Acknowledgements
|
### Acknowledgements
|
||||||
|
|
||||||
The ClamAV team thanks the following individuals for their code submissions:
|
The ClamAV team thanks the following individuals for their code submissions:
|
||||||
|
|
|
@ -32,6 +32,9 @@ For detailed instructions specific to building ClamAV please investigate
|
||||||
our the
|
our the
|
||||||
[Linux/Unix/Mac Install instructions in the User Manual](https://www.clamav.net/documents/installing-clamav-on-unix-linux-macos-from-source).
|
[Linux/Unix/Mac Install instructions in the User Manual](https://www.clamav.net/documents/installing-clamav-on-unix-linux-macos-from-source).
|
||||||
|
|
||||||
|
For instructions on how to build ClamAV using our new *experimental* CMake
|
||||||
|
build tooling, see [INSTALL.cmake.md](INSTALL.cmake.md)
|
||||||
|
|
||||||
#### Install from a binary package
|
#### Install from a binary package
|
||||||
|
|
||||||
For binary package distribution installation instructions, head over to
|
For binary package distribution installation instructions, head over to
|
||||||
|
@ -56,6 +59,9 @@ directory.
|
||||||
For details on how to use either option, head over to the
|
For details on how to use either option, head over to the
|
||||||
[Windows Install instructions in the User Manual](https://www.clamav.net/documents/installing-clamav-on-windows).
|
[Windows Install instructions in the User Manual](https://www.clamav.net/documents/installing-clamav-on-windows).
|
||||||
|
|
||||||
|
For instructions on how to build ClamAV using our new *experimental* CMake
|
||||||
|
build tooling, see [INSTALL.cmake.md](INSTALL.cmake.md)
|
||||||
|
|
||||||
### Upgrading from a previous version
|
### Upgrading from a previous version
|
||||||
|
|
||||||
Some tips on [how to upgrade](https://www.clamav.net/documents/upgrading-clamav)
|
Some tips on [how to upgrade](https://www.clamav.net/documents/upgrading-clamav)
|
||||||
|
|
|
@ -72,7 +72,7 @@ git checkout libclamav/inffixed64.h
|
||||||
git checkout libclamav/inflate64.h
|
git checkout libclamav/inflate64.h
|
||||||
git checkout libclamav/inflate64.c
|
git checkout libclamav/inflate64.c
|
||||||
git checkout libclamav/inflate64_priv.h
|
git checkout libclamav/inflate64_priv.h
|
||||||
git checkout shared/queue.h
|
git checkout libclamav/queue.h
|
||||||
git checkout clamonacc/c-thread-pool/thpool.c
|
git checkout clamonacc/c-thread-pool/thpool.c
|
||||||
git checkout clamonacc/c-thread-pool/thpool.h
|
git checkout clamonacc/c-thread-pool/thpool.h
|
||||||
git checkout clamonacc/misc/fts.c
|
git checkout clamonacc/misc/fts.c
|
||||||
|
|
608
clamav-config.h.cmake.in
Normal file
608
clamav-config.h.cmake.in
Normal file
|
@ -0,0 +1,608 @@
|
||||||
|
/* clamav-config.h.cmake.in. Autoconf compatibility layer for CMake. */
|
||||||
|
|
||||||
|
/* Define if building universal (internal helper macro) */
|
||||||
|
#cmakedefine AC_APPLE_UNIVERSAL_BUILD 1
|
||||||
|
|
||||||
|
/* mmap flag for anonymous maps */
|
||||||
|
#cmakedefine ANONYMOUS_MAP @ANONYMOUS_MAP@
|
||||||
|
|
||||||
|
/* bind 8 compatibility mode, required on some systems to get T_TXT, etc from nameser_compat.h */
|
||||||
|
#cmakedefine BIND_8_COMPAT 1
|
||||||
|
|
||||||
|
/* name of the clamav group */
|
||||||
|
#define CLAMAVGROUP "@CLAMAV_GROUP@"
|
||||||
|
|
||||||
|
/* name of the clamav user */
|
||||||
|
#define CLAMAVUSER "@CLAMAV_USER@"
|
||||||
|
|
||||||
|
/* enable debugging */
|
||||||
|
#cmakedefine CL_DEBUG 1
|
||||||
|
|
||||||
|
/* enable experimental code */
|
||||||
|
#cmakedefine CL_EXPERIMENTAL 1
|
||||||
|
|
||||||
|
/* thread safe */
|
||||||
|
#cmakedefine CL_THREAD_SAFE 1
|
||||||
|
|
||||||
|
/* curses header location */
|
||||||
|
#cmakedefine CURSES_INCLUDE @CURSES_INCLUDE@
|
||||||
|
|
||||||
|
/* os is aix */
|
||||||
|
#cmakedefine C_AIX 1
|
||||||
|
|
||||||
|
/* os is beos */
|
||||||
|
#cmakedefine C_BEOS 1
|
||||||
|
|
||||||
|
/* Increase thread stack size. */
|
||||||
|
#cmakedefine C_BIGSTACK 1
|
||||||
|
|
||||||
|
/* os is bsd flavor */
|
||||||
|
#cmakedefine C_BSD 1
|
||||||
|
|
||||||
|
/* os is darwin */
|
||||||
|
#cmakedefine C_DARWIN 1
|
||||||
|
|
||||||
|
/* target is gnu-hurd */
|
||||||
|
#cmakedefine C_GNU_HURD 1
|
||||||
|
|
||||||
|
/* os is hpux */
|
||||||
|
#cmakedefine C_HPUX 1
|
||||||
|
|
||||||
|
/* os is interix */
|
||||||
|
#cmakedefine C_INTERIX 1
|
||||||
|
|
||||||
|
/* os is irix */
|
||||||
|
#cmakedefine C_IRIX 1
|
||||||
|
|
||||||
|
/* target is kfreebsd-gnu */
|
||||||
|
#cmakedefine C_KFREEBSD_GNU 1
|
||||||
|
|
||||||
|
/* target is linux */
|
||||||
|
#cmakedefine C_LINUX 1
|
||||||
|
|
||||||
|
/* os is OS/2 */
|
||||||
|
#cmakedefine C_OS2 1
|
||||||
|
|
||||||
|
/* os is osf/tru64 */
|
||||||
|
#cmakedefine C_OSF 1
|
||||||
|
|
||||||
|
/* os is QNX 6.x.x */
|
||||||
|
#cmakedefine C_QNX6 1
|
||||||
|
|
||||||
|
/* os is solaris */
|
||||||
|
#cmakedefine C_SOLARIS 1
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
/* Path to virus database directory. */
|
||||||
|
#define DATADIR "@DATABASE_DIRECTORY@"
|
||||||
|
|
||||||
|
/* where to look for the config file */
|
||||||
|
#define CONFDIR "@APP_CONFIG_DIRECTORY@"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Have sys/fanotify.h */
|
||||||
|
#cmakedefine HAVE_SYS_FANOTIFY_H 1
|
||||||
|
|
||||||
|
/* whether _XOPEN_SOURCE needs to be defined for fd passing to work */
|
||||||
|
#cmakedefine FDPASS_NEED_XOPEN 1
|
||||||
|
|
||||||
|
/* file i/o buffer size */
|
||||||
|
#cmakedefine FILEBUFF @FILEBUFF@
|
||||||
|
|
||||||
|
/* scan buffer size */
|
||||||
|
#cmakedefine SCANBUFF @SCANBUFF@
|
||||||
|
|
||||||
|
/* enable workaround for broken DNS servers */
|
||||||
|
#cmakedefine FRESHCLAM_DNS_FIX 1
|
||||||
|
|
||||||
|
/* use "Cache-Control: no-cache" in freshclam */
|
||||||
|
#cmakedefine FRESHCLAM_NO_CACHE 1
|
||||||
|
|
||||||
|
/* attrib aligned */
|
||||||
|
#cmakedefine HAVE_ATTRIB_ALIGNED 1
|
||||||
|
|
||||||
|
/* attrib packed */
|
||||||
|
#cmakedefine HAVE_ATTRIB_PACKED 1
|
||||||
|
|
||||||
|
/* have bzip2 */
|
||||||
|
#cmakedefine HAVE_BZLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ctime_r' function. */
|
||||||
|
#cmakedefine HAVE_CTIME_R 1
|
||||||
|
|
||||||
|
/* ctime_r takes 2 arguments */
|
||||||
|
#cmakedefine HAVE_CTIME_R_2 1
|
||||||
|
|
||||||
|
/* ctime_r takes 3 arguments */
|
||||||
|
#cmakedefine HAVE_CTIME_R_3 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if
|
||||||
|
you don't. */
|
||||||
|
#cmakedefine HAVE_DECL_CYGWIN_CONV_PATH 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have a deprecated version of the 'libjson' library
|
||||||
|
(-ljson). */
|
||||||
|
#cmakedefine HAVE_DEPRECATED_JSON 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dirent.h> header file. */
|
||||||
|
#cmakedefine HAVE_DIRENT_H 1
|
||||||
|
|
||||||
|
/* Define if you have the GNU dld library. */
|
||||||
|
#cmakedefine HAVE_DLD 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dld.h> header file. */
|
||||||
|
#cmakedefine HAVE_DLD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `dlerror' function. */
|
||||||
|
#cmakedefine HAVE_DLERROR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
#cmakedefine HAVE_DLFCN_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dl.h> header file. */
|
||||||
|
#cmakedefine HAVE_DL_H 1
|
||||||
|
|
||||||
|
/* Define if you have the _dyld_func_lookup function. */
|
||||||
|
#cmakedefine HAVE_DYLD 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `enable_extended_FILE_stdio' function. */
|
||||||
|
#cmakedefine HAVE_ENABLE_EXTENDED_FILE_STDIO 1
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `error_t'. */
|
||||||
|
#cmakedefine HAVE_ERROR_T 1
|
||||||
|
|
||||||
|
/* have working file descriptor passing support */
|
||||||
|
#cmakedefine HAVE_FD_PASSING 1
|
||||||
|
|
||||||
|
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||||
|
#cmakedefine HAVE_FSEEKO 1
|
||||||
|
|
||||||
|
/* have getaddrinfo() */
|
||||||
|
#cmakedefine HAVE_GETADDRINFO 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getnameinfo' function. */
|
||||||
|
#cmakedefine HAVE_GETNAMEINFO 1
|
||||||
|
|
||||||
|
/* Define to 1 if getpagesize() is available */
|
||||||
|
#cmakedefine HAVE_GETPAGESIZE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <grp.h> header file. */
|
||||||
|
#cmakedefine HAVE_GRP_H 1
|
||||||
|
|
||||||
|
/* Define if you have the iconv() function and it works. */
|
||||||
|
#cmakedefine HAVE_ICONV 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `initgroups' function. */
|
||||||
|
#cmakedefine HAVE_INITGROUPS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#cmakedefine HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the 'libjson' library (-ljson). */
|
||||||
|
#cmakedefine HAVE_JSON 1
|
||||||
|
|
||||||
|
/* Define to '1' if you have the check.h library */
|
||||||
|
#cmakedefine HAVE_LIBCHECK 1
|
||||||
|
|
||||||
|
/* Define to '1' if you have the ncurses.h library */
|
||||||
|
#cmakedefine HAVE_LIBNCURSES 1
|
||||||
|
|
||||||
|
/* Define to '1' if you have the curses.h library */
|
||||||
|
#cmakedefine HAVE_LIBPDCURSES 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ssl' library (-lssl). */
|
||||||
|
#cmakedefine HAVE_LIBSSL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the 'libxml2' library (-lxml2). */
|
||||||
|
#cmakedefine HAVE_LIBXML2 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `z' library (-lz). */
|
||||||
|
#cmakedefine HAVE_LIBZ 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
|
#cmakedefine HAVE_LIMITS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `madvise' function. */
|
||||||
|
#cmakedefine HAVE_MADVISE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mallinfo' function. */
|
||||||
|
#cmakedefine HAVE_MALLINFO 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <malloc.h> header file. */
|
||||||
|
#cmakedefine HAVE_MALLOC_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mkstemp' function. */
|
||||||
|
#cmakedefine HAVE_MKSTEMP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have a working `mmap' system call that supports
|
||||||
|
MAP_PRIVATE. */
|
||||||
|
#cmakedefine HAVE_MMAP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have a pcre library (-lpcre). */
|
||||||
|
#cmakedefine HAVE_PCRE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you using the pcre2 library. */
|
||||||
|
#cmakedefine USING_PCRE2 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `poll' function. */
|
||||||
|
#cmakedefine HAVE_POLL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <poll.h> header file. */
|
||||||
|
#cmakedefine HAVE_POLL_H 1
|
||||||
|
|
||||||
|
/* "pragma pack" */
|
||||||
|
#cmakedefine HAVE_PRAGMA_PACK 1
|
||||||
|
|
||||||
|
/* "pragma pack hppa/hp-ux style" */
|
||||||
|
#cmakedefine HAVE_PRAGMA_PACK_HPPA 1
|
||||||
|
|
||||||
|
/* Define if libtool can extract symbol lists from object files. */
|
||||||
|
#cmakedefine HAVE_PRELOADED_SYMBOLS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <pthread.h> header file */
|
||||||
|
#cmakedefine HAVE_PTHREAD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <pwd.h> header file. */
|
||||||
|
#cmakedefine HAVE_PWD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `readdir' function. */
|
||||||
|
#cmakedefine HAVE_READDIR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `recvmsg' function. */
|
||||||
|
#cmakedefine HAVE_RECVMSG 1
|
||||||
|
|
||||||
|
/* have resolv.h */
|
||||||
|
#cmakedefine HAVE_RESOLV_H 1
|
||||||
|
|
||||||
|
/* Define signed right shift implementation */
|
||||||
|
#cmakedefine HAVE_SAR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sched_yield' function. */
|
||||||
|
#cmakedefine HAVE_SCHED_YIELD 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sendmsg' function. */
|
||||||
|
#cmakedefine HAVE_SENDMSG 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `setgroups' function. */
|
||||||
|
#cmakedefine HAVE_SETGROUPS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `setsid' function. */
|
||||||
|
#cmakedefine HAVE_SETSID 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `snprintf' function. */
|
||||||
|
#cmakedefine HAVE_SNPRINTF 1
|
||||||
|
|
||||||
|
/* enable stat64 */
|
||||||
|
#cmakedefine HAVE_STAT64 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||||
|
#cmakedefine HAVE_STDBOOL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#cmakedefine HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#cmakedefine HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strcasestr' function. */
|
||||||
|
#cmakedefine HAVE_STRCASESTR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strerror_r' function. */
|
||||||
|
#cmakedefine HAVE_STRERROR_R 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#cmakedefine HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#cmakedefine HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strlcat' function. */
|
||||||
|
#cmakedefine HAVE_STRLCAT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strlcpy' function. */
|
||||||
|
#cmakedefine HAVE_STRLCPY 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strndup' function. */
|
||||||
|
#cmakedefine HAVE_STRNDUP 1
|
||||||
|
|
||||||
|
/* using internal strn functions */
|
||||||
|
#cmakedefine HAVE_STRNI 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strnlen' function. */
|
||||||
|
#cmakedefine HAVE_STRNLEN 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strnstr' function. */
|
||||||
|
#cmakedefine HAVE_STRNSTR 1
|
||||||
|
|
||||||
|
/* Define to 1 if sysconf(_SC_PAGESIZE) is available */
|
||||||
|
#cmakedefine HAVE_SYSCONF_SC_PAGESIZE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sysctlbyname' function. */
|
||||||
|
#cmakedefine HAVE_SYSCTLBYNAME 1
|
||||||
|
|
||||||
|
/* systemd is supported */
|
||||||
|
#cmakedefine HAVE_SYSTEMD 1
|
||||||
|
|
||||||
|
/* Use private fts() implementation which is LFS safe */
|
||||||
|
#cmakedefine HAVE_SYSTEM_LFS_FTS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/cdefs.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_CDEFS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/dl.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_DL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/filio.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_FILIO_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/inttypes.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/int_types.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_INT_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_MMAN_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_PARAM_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/queue.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_QUEUE_H 1
|
||||||
|
|
||||||
|
/* "have <sys/select.h>" */
|
||||||
|
#cmakedefine HAVE_SYS_SELECT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_TIMES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_UIO_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <termios.h> header file. */
|
||||||
|
#cmakedefine HAVE_TERMIOS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `timegm' function. */
|
||||||
|
#cmakedefine HAVE_TIMEGM 1
|
||||||
|
|
||||||
|
/* Define this if uname(2) is POSIX */
|
||||||
|
#cmakedefine HAVE_UNAME_SYSCALL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#cmakedefine HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
|
#cmakedefine HAVE_VSNPRINTF 1
|
||||||
|
|
||||||
|
/* This value is set to 1 to indicate that the system argz facility works */
|
||||||
|
#cmakedefine HAVE_WORKING_ARGZ 1
|
||||||
|
|
||||||
|
/* yara sources are compiled in */
|
||||||
|
#cmakedefine HAVE_YARA 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <zlib.h> header file. */
|
||||||
|
#cmakedefine HAVE_ZLIB_H 1
|
||||||
|
|
||||||
|
/* For internal use only - DO NOT DEFINE */
|
||||||
|
#cmakedefine HAVE__INTERNAL__SHA_COLLECT 1
|
||||||
|
|
||||||
|
/* Define as const if the declaration of iconv() needs const. */
|
||||||
|
#cmakedefine ICONV_CONST @ICONV_CONST@
|
||||||
|
|
||||||
|
/* "Full clamav library version number" */
|
||||||
|
#define LIBCLAMAV_FULLVER "@LIBCLAMAV_VERSION@"
|
||||||
|
|
||||||
|
/* "Major clamav library version number" */
|
||||||
|
#define LIBCLAMAV_MAJORVER @LIBCLAMAV_SOVERSION@
|
||||||
|
|
||||||
|
/* "Full freshclam library version number" */
|
||||||
|
#define LIBFRESHCLAM_FULLVER "@LIBFRESHCLAM_VERSION@"
|
||||||
|
|
||||||
|
/* "Major freshclam library version number" */
|
||||||
|
#define LIBFRESHCLAM_MAJORVER @LIBFRESHCLAM_SOVERSION@
|
||||||
|
|
||||||
|
/* The archive extension */
|
||||||
|
#define LT_LIBEXT "@CMAKE_STATIC_LIBRARY_SUFFIX@"
|
||||||
|
|
||||||
|
/* The archive prefix */
|
||||||
|
#define LT_LIBPREFIX "@CMAKE_STATIC_LIBRARY_PREFIX@"
|
||||||
|
|
||||||
|
/* Define to the extension used for runtime loadable modules, say, ".so" or ".dylib". */
|
||||||
|
#define LT_MODULE_EXT "@CMAKE_SHARED_LIBRARY_SUFFIX@"
|
||||||
|
|
||||||
|
/* Define to the name of the environment variable that determines the run-time
|
||||||
|
module search path. */
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define SEARCH_LIBDIR "@CMAKE_INSTALL_PREFIX@"
|
||||||
|
#else
|
||||||
|
#define SEARCH_LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to the shared library suffix, say, ".dylib". */
|
||||||
|
#define LT_SHARED_EXT "@CMAKE_SHARED_LIBRARY_SUFFIX@"
|
||||||
|
|
||||||
|
/* disable assertions */
|
||||||
|
#cmakedefine NDEBUG 1
|
||||||
|
|
||||||
|
/* Define if dlsym() requires a leading underscore in symbol names. */
|
||||||
|
#cmakedefine NEED_USCORE 1
|
||||||
|
|
||||||
|
/* bzip funtions do not have bz2 prefix */
|
||||||
|
#cmakedefine NOBZ2PREFIX 1
|
||||||
|
|
||||||
|
/* "no fd_set" */
|
||||||
|
#cmakedefine NO_FD_SET 1
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "@PACKAGE_NAME@"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#cmakedefine PACKAGE_URL "@PACKAGE_URL@"
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||||
|
|
||||||
|
/* Libprelude support enabled */
|
||||||
|
#cmakedefine PRELUDE 1
|
||||||
|
|
||||||
|
/* Define whether application use libtool >= 2.0 */
|
||||||
|
#cmakedefine PRELUDE_APPLICATION_USE_LIBTOOL2 1
|
||||||
|
|
||||||
|
/* Define to if the `setpgrp' function takes no argument. */
|
||||||
|
#cmakedefine SETPGRP_VOID 1
|
||||||
|
|
||||||
|
/* The number of bytes in type int */
|
||||||
|
#cmakedefine SIZEOF_INT @SIZEOF_INT@
|
||||||
|
|
||||||
|
/* The number of bytes in type long */
|
||||||
|
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
|
||||||
|
|
||||||
|
/* The number of bytes in type long long */
|
||||||
|
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
|
||||||
|
|
||||||
|
/* The number of bytes in type short */
|
||||||
|
#cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@
|
||||||
|
|
||||||
|
/* The number of bytes in type void * */
|
||||||
|
#define SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@
|
||||||
|
|
||||||
|
/* Define to if you have the ANSI C header files. */
|
||||||
|
#cmakedefine STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Support for IPv6 */
|
||||||
|
#cmakedefine SUPPORT_IPv6 1
|
||||||
|
|
||||||
|
/* enable memory pools */
|
||||||
|
#cmakedefine USE_MPOOL 1
|
||||||
|
|
||||||
|
/* use syslog */
|
||||||
|
#cmakedefine USE_SYSLOG 1
|
||||||
|
|
||||||
|
/* Enable extensions on AIX 3, Interix. */
|
||||||
|
#ifndef _ALL_SOURCE
|
||||||
|
#cmakedefine _ALL_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable GNU extensions on systems that have them. */
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
#cmakedefine _GNU_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable threading extensions on Solaris. */
|
||||||
|
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||||
|
#cmakedefine _POSIX_PTHREAD_SEMANTICS 1
|
||||||
|
#endif
|
||||||
|
/* Enable extensions on HP NonStop. */
|
||||||
|
#ifndef _TANDEM_SOURCE
|
||||||
|
#cmakedefine _TANDEM_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable general extensions on Solaris. */
|
||||||
|
#ifndef __EXTENSIONS__
|
||||||
|
#cmakedefine __EXTENSIONS__ 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* LLVM version (if found) */
|
||||||
|
#cmakedefine LLVM_VERSION @LLVM_VERSION_MAJOR@@LLVM_VERSION_MINOR@
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#cmakedefine VERSION "@PACKAGE_VERSION@"
|
||||||
|
|
||||||
|
/* Version suffix for package */
|
||||||
|
#cmakedefine VERSION_SUFFIX "@VERSION_SUFFIX@"
|
||||||
|
|
||||||
|
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||||
|
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||||
|
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||||
|
# if defined __BIG_ENDIAN__
|
||||||
|
# define WORDS_BIGENDIAN 1
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifndef WORDS_BIGENDIAN
|
||||||
|
#cmakedefine WORDS_BIGENDIAN 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||||
|
`char[]'. */
|
||||||
|
#cmakedefine YYTEXT_POINTER 1
|
||||||
|
|
||||||
|
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||||
|
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||||
|
# define _DARWIN_USE_64_BIT_INODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
|
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
|
||||||
|
|
||||||
|
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||||
|
#cmakedefine _LARGEFILE_SOURCE 1
|
||||||
|
|
||||||
|
/* Define for large files, on AIX-style hosts. */
|
||||||
|
#cmakedefine _LARGE_FILES 1
|
||||||
|
|
||||||
|
/* Define to 1 if on MINIX. */
|
||||||
|
#cmakedefine _MINIX 1
|
||||||
|
|
||||||
|
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||||
|
this defined. */
|
||||||
|
#cmakedefine _POSIX_1_SOURCE 2
|
||||||
|
|
||||||
|
/* POSIX compatibility */
|
||||||
|
#cmakedefine _POSIX_PII_SOCKET 1
|
||||||
|
|
||||||
|
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||||
|
#cmakedefine _POSIX_SOURCE 1
|
||||||
|
|
||||||
|
/* thread safe */
|
||||||
|
#cmakedefine _REENTRANT 1
|
||||||
|
|
||||||
|
/* Define so that glibc/gnulib argp.h does not typedef error_t. */
|
||||||
|
#cmakedefine __error_t_defined 1
|
||||||
|
|
||||||
|
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||||
|
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#define inline @INLINE_KEYWORD@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to `long int' if <sys/types.h> does not define. */
|
||||||
|
#cmakedefine off_t @off_t@
|
||||||
|
|
||||||
|
/* Define to `int' if <sys/types.h> does not define. */
|
||||||
|
#cmakedefine ssize_t @ssize_t@
|
||||||
|
|
||||||
|
/* Define to the equivalent of the C99 'restrict' keyword, or to
|
||||||
|
nothing if this is not supported. Do not define if restrict is
|
||||||
|
supported directly. */
|
||||||
|
#cmakedefine restrict @restrict@
|
||||||
|
|
||||||
|
/* Work around a bug in Sun C++: it does not support _Restrict or
|
||||||
|
__restrict__, even though the corresponding Sun C compiler ends up with
|
||||||
|
"#define restrict _Restrict" or "#define restrict __restrict__" in the
|
||||||
|
previous line. Perhaps some future version of Sun C++ will work with
|
||||||
|
restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
|
||||||
|
#if defined __SUNPRO_CC && !defined __RESTRICT
|
||||||
|
# define _Restrict
|
||||||
|
# define __restrict__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to "int" if <sys/socket.h> does not define. */
|
||||||
|
#cmakedefine socklen_t @socklen_t@
|
||||||
|
|
||||||
|
#include "platform.h"
|
|
@ -87,9 +87,6 @@
|
||||||
/* "default FD_SETSIZE value" */
|
/* "default FD_SETSIZE value" */
|
||||||
#undef DEFAULT_FD_SETSIZE
|
#undef DEFAULT_FD_SETSIZE
|
||||||
|
|
||||||
/* use fanotify */
|
|
||||||
#undef FANOTIFY
|
|
||||||
|
|
||||||
/* whether _XOPEN_SOURCE needs to be defined for fd passing to work */
|
/* whether _XOPEN_SOURCE needs to be defined for fd passing to work */
|
||||||
#undef FDPASS_NEED_XOPEN
|
#undef FDPASS_NEED_XOPEN
|
||||||
|
|
||||||
|
@ -414,6 +411,9 @@
|
||||||
/* Define to 1 if you have the <sys/dl.h> header file. */
|
/* Define to 1 if you have the <sys/dl.h> header file. */
|
||||||
#undef HAVE_SYS_DL_H
|
#undef HAVE_SYS_DL_H
|
||||||
|
|
||||||
|
/* use fanotify */
|
||||||
|
#undef HAVE_SYS_FANOTIFY_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/filio.h> header file. */
|
/* Define to 1 if you have the <sys/filio.h> header file. */
|
||||||
#undef HAVE_SYS_FILIO_H
|
#undef HAVE_SYS_FILIO_H
|
||||||
|
|
||||||
|
|
27
clamav-milter/CMakeLists.txt
Normal file
27
clamav-milter/CMakeLists.txt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
# The clamav-milter executable.
|
||||||
|
add_executable( clamav-milter )
|
||||||
|
target_sources( clamav-milter
|
||||||
|
PRIVATE
|
||||||
|
clamav-milter.c
|
||||||
|
clamfi.c
|
||||||
|
clamfi.h
|
||||||
|
connpool.c
|
||||||
|
connpool.h
|
||||||
|
netcode.c
|
||||||
|
netcode.h
|
||||||
|
whitelist.c
|
||||||
|
whitelist.h )
|
||||||
|
target_include_directories( clamav-milter
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clamav-milter PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamav-milter
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared
|
||||||
|
Sendmail::milter )
|
||||||
|
install(TARGETS clamav-milter DESTINATION ${CMAKE_INSTALL_SBINDIR})
|
|
@ -24,14 +24,6 @@ if HAVE_MILTER
|
||||||
sbin_PROGRAMS = clamav-milter
|
sbin_PROGRAMS = clamav-milter
|
||||||
|
|
||||||
clamav_milter_SOURCES = \
|
clamav_milter_SOURCES = \
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/output.c \
|
|
||||||
$(top_srcdir)/shared/output.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
whitelist.c \
|
whitelist.c \
|
||||||
whitelist.h \
|
whitelist.h \
|
||||||
connpool.c \
|
connpool.c \
|
||||||
|
@ -47,7 +39,6 @@ AM_CFLAGS=@WERR_CFLAGS_MILTER@
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DEFS = @DEFS@ -DCL_NOLIBCLAMAV
|
LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
|
AM_CPPFLAGS = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface -I$(top_srcdir)/shared -I$(top_srcdir) @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared -I$(top_srcdir) @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
|
||||||
CLEANFILES=*.gcda *.gcno
|
CLEANFILES=*.gcda *.gcno
|
||||||
|
|
|
@ -37,12 +37,14 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <libmilter/mfapi.h>
|
#include <libmilter/mfapi.h>
|
||||||
|
|
||||||
|
// libclamav
|
||||||
#include "clamav.h"
|
#include "clamav.h"
|
||||||
|
#include "default.h"
|
||||||
|
|
||||||
#include "shared/output.h"
|
// shared
|
||||||
#include "shared/optparser.h"
|
#include "output.h"
|
||||||
#include "shared/misc.h"
|
#include "optparser.h"
|
||||||
#include "libclamav/default.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#include "connpool.h"
|
#include "connpool.h"
|
||||||
#include "netcode.h"
|
#include "netcode.h"
|
||||||
|
|
|
@ -34,10 +34,13 @@
|
||||||
|
|
||||||
#include <libmilter/mfapi.h>
|
#include <libmilter/mfapi.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "shared/optparser.h"
|
#include "clamav.h"
|
||||||
#include "shared/output.h"
|
#include "others.h"
|
||||||
#include "libclamav/others.h"
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
#include "connpool.h"
|
#include "connpool.h"
|
||||||
#include "netcode.h"
|
#include "netcode.h"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#ifndef _CLAMFI_H
|
#ifndef _CLAMFI_H
|
||||||
#define _CLAMFI_H
|
#define _CLAMFI_H
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
#include <libmilter/mfapi.h>
|
#include <libmilter/mfapi.h>
|
||||||
|
|
||||||
extern uint64_t maxfilesize;
|
extern uint64_t maxfilesize;
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
#include "shared/output.h"
|
#include "output.h"
|
||||||
#include "shared/misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#include "connpool.h"
|
#include "connpool.h"
|
||||||
#include "netcode.h"
|
#include "netcode.h"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
|
|
||||||
struct CP_ENTRY {
|
struct CP_ENTRY {
|
||||||
struct sockaddr *server;
|
struct sockaddr *server;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define __EXTENSIONS__
|
#define __EXTENSIONS__
|
||||||
#endif
|
#endif
|
||||||
/* must be first because it may define _XOPEN_SOURCE */
|
/* must be first because it may define _XOPEN_SOURCE */
|
||||||
#include "shared/fdpassing.h"
|
#include "fdpassing.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -45,10 +45,14 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "shared/output.h"
|
#include "clamav.h"
|
||||||
#include "shared/optparser.h"
|
#include "others.h"
|
||||||
#include "libclamav/others.h"
|
|
||||||
|
// shared
|
||||||
|
#include "output.h"
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#include "netcode.h"
|
#include "netcode.h"
|
||||||
|
|
||||||
#define strerror_print(msg) logg(msg ": %s\n", cli_strerror(errno, er, sizeof(er)))
|
#define strerror_print(msg) logg(msg ": %s\n", cli_strerror(errno, er, sizeof(er)))
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
#include "connpool.h"
|
#include "connpool.h"
|
||||||
|
|
||||||
void nc_ping_entry(struct CP_ENTRY *cpe);
|
void nc_ping_entry(struct CP_ENTRY *cpe);
|
||||||
|
|
|
@ -27,8 +27,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "libclamav/regex/regex.h"
|
// libclamav
|
||||||
#include "shared/output.h"
|
#include "regex/regex.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
#include "whitelist.h"
|
#include "whitelist.h"
|
||||||
|
|
||||||
struct WHLST {
|
struct WHLST {
|
||||||
|
|
33
clambc/CMakeLists.txt
Normal file
33
clambc/CMakeLists.txt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||||
|
|
||||||
|
# Windows compatibility headers
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/win32/compat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The clambc executable.
|
||||||
|
add_executable( clambc )
|
||||||
|
target_sources( clambc
|
||||||
|
PRIVATE
|
||||||
|
bcrun.c )
|
||||||
|
if(WIN32)
|
||||||
|
target_sources( clambc PRIVATE ${CMAKE_SOURCE_DIR}/win32/res/clambc.rc )
|
||||||
|
endif()
|
||||||
|
target_include_directories( clambc
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clambc PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clambc
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared )
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS clambc DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
install(TARGETS clambc DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
|
@ -1,14 +1,8 @@
|
||||||
bin_PROGRAMS = clambc
|
bin_PROGRAMS = clambc
|
||||||
clambc_SOURCES = \
|
clambc_SOURCES = \
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
bcrun.c
|
bcrun.c
|
||||||
|
|
||||||
AM_CFLAGS=@WERR_CFLAGS@ @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
AM_CFLAGS=@WERR_CFLAGS@ @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@
|
LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @THREAD_LIBS@
|
||||||
CLEANFILES=*.gcda *.gcno
|
CLEANFILES=*.gcda *.gcno
|
||||||
|
|
|
@ -28,13 +28,16 @@
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
#include "dconf.h"
|
||||||
|
#include "others.h"
|
||||||
#include "bytecode.h"
|
#include "bytecode.h"
|
||||||
#include "bytecode_priv.h"
|
#include "bytecode_priv.h"
|
||||||
#include "clamav.h"
|
|
||||||
#include "shared/optparser.h"
|
// shared
|
||||||
#include "shared/misc.h"
|
#include "optparser.h"
|
||||||
#include "libclamav/dconf.h"
|
#include "misc.h"
|
||||||
#include "libclamav/others.h"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
33
clamconf/CMakeLists.txt
Normal file
33
clamconf/CMakeLists.txt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||||
|
|
||||||
|
# Windows compatibility headers
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/win32/compat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The clamconf executable.
|
||||||
|
add_executable( clamconf )
|
||||||
|
target_sources( clamconf
|
||||||
|
PRIVATE
|
||||||
|
clamconf.c )
|
||||||
|
if(WIN32)
|
||||||
|
target_sources( clamconf PRIVATE ${CMAKE_SOURCE_DIR}/win32/res/clamconf.rc )
|
||||||
|
endif()
|
||||||
|
target_include_directories( clamconf
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clamconf PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamconf
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared )
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS clamconf DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
install(TARGETS clamconf DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
|
@ -21,21 +21,15 @@
|
||||||
bin_PROGRAMS = clamconf
|
bin_PROGRAMS = clamconf
|
||||||
|
|
||||||
clamconf_SOURCES = \
|
clamconf_SOURCES = \
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
clamconf.c
|
clamconf.c
|
||||||
|
|
||||||
AM_CFLAGS=@WERR_CFLAGS@ @SSL_CPPFLAGS@
|
AM_CFLAGS=@WERR_CFLAGS@ @SSL_CPPFLAGS@
|
||||||
|
|
||||||
DEFS = @DEFS@ -DCL_NOTHREADS
|
DEFS = @DEFS@
|
||||||
AM_CPPFLAGS = @CLAMCONF_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav\
|
AM_CPPFLAGS = @CLAMCONF_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface \
|
||||||
@ZLIB_CFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@\
|
@ZLIB_CFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@\
|
||||||
-DBUILD_CPPFLAGS="\"$(CPPFLAGS)\"" -DBUILD_CFLAGS="\"$(CFLAGS)\""\
|
-DBUILD_CPPFLAGS="\"$(CPPFLAGS)\"" -DBUILD_CFLAGS="\"$(CFLAGS)\""\
|
||||||
-DBUILD_CXXFLAGS="\"$(CXXFLAGS)\"" -DBUILD_LDFLAGS="\"$(LDFLAGS)\""\
|
-DBUILD_CXXFLAGS="\"$(CXXFLAGS)\"" -DBUILD_LDFLAGS="\"$(LDFLAGS)\""\
|
||||||
-DBUILD_CONFIGURE_FLAGS="\"$(BUILD_CONFIGURE_FLAGS)\""
|
-DBUILD_CONFIGURE_FLAGS="\"$(BUILD_CONFIGURE_FLAGS)\""
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMCONF_LIBS@ @CLAMD_LIBS@ @THREAD_LIBS@ @LIBCLAMAV_LIBS@ @ZLIB_LIBS@
|
LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @CLAMCONF_LIBS@ @CLAMD_LIBS@ @THREAD_LIBS@ @LIBCLAMAV_LIBS@ @ZLIB_LIBS@
|
||||||
CLEANFILES=*.gcda *.gcno
|
CLEANFILES=*.gcda *.gcno
|
||||||
|
|
|
@ -37,19 +37,22 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/misc.h"
|
|
||||||
|
|
||||||
#include "clamav-config.h"
|
#include "clamav-config.h"
|
||||||
#include "libclamav/str.h"
|
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "libclamav/others.h"
|
|
||||||
#include "libclamav/readdb.h"
|
|
||||||
#include "libclamav/bytecode.h"
|
|
||||||
#include "libclamav/bytecode_detect.h"
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
#include "str.h"
|
||||||
|
#include "others.h"
|
||||||
|
#include "readdb.h"
|
||||||
|
#include "bytecode.h"
|
||||||
|
#include "bytecode_detect.h"
|
||||||
#include "fpu.h"
|
#include "fpu.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
extern const struct clam_option *clam_options;
|
extern const struct clam_option *clam_options;
|
||||||
#else
|
#else
|
||||||
|
|
57
clamd/CMakeLists.txt
Normal file
57
clamd/CMakeLists.txt
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||||
|
|
||||||
|
# Windows compatibility headers
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/win32/compat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The clamd executable.
|
||||||
|
add_executable( clamd )
|
||||||
|
target_sources( clamd
|
||||||
|
PRIVATE
|
||||||
|
clamd.c
|
||||||
|
clamd_others.c
|
||||||
|
clamd_others.h
|
||||||
|
localserver.c
|
||||||
|
localserver.h
|
||||||
|
scanner.c
|
||||||
|
scanner.h
|
||||||
|
server-th.c
|
||||||
|
server.h
|
||||||
|
session.c
|
||||||
|
session.h
|
||||||
|
shared.h
|
||||||
|
tcpserver.c
|
||||||
|
tcpserver.h
|
||||||
|
thrmgr.c
|
||||||
|
thrmgr.h )
|
||||||
|
if(WIN32)
|
||||||
|
target_sources( clamd PRIVATE ${CMAKE_SOURCE_DIR}/win32/res/clamd.rc )
|
||||||
|
endif()
|
||||||
|
target_include_directories( clamd
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clamd PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamd
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared )
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS clamd DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
install(TARGETS clamd DESTINATION ${CMAKE_INSTALL_SBINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SYSTEMD_FOUND)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/clamav-daemon.service.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/clamav-daemon.service @ONLY)
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/clamav-daemon.service
|
||||||
|
DESTINATION ${SYSTEMD_UNIT_DIR})
|
||||||
|
endif()
|
|
@ -23,16 +23,6 @@ if BUILD_CLAMD
|
||||||
sbin_PROGRAMS = clamd
|
sbin_PROGRAMS = clamd
|
||||||
|
|
||||||
clamd_SOURCES = \
|
clamd_SOURCES = \
|
||||||
$(top_srcdir)/shared/output.c \
|
|
||||||
$(top_srcdir)/shared/output.h \
|
|
||||||
$(top_srcdir)/shared/idmef_logging.c \
|
|
||||||
$(top_srcdir)/shared/idmef_logging.h \
|
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
clamd.c \
|
clamd.c \
|
||||||
tcpserver.c \
|
tcpserver.c \
|
||||||
tcpserver.h \
|
tcpserver.h \
|
||||||
|
@ -46,8 +36,8 @@ clamd_SOURCES = \
|
||||||
server.h \
|
server.h \
|
||||||
scanner.c \
|
scanner.c \
|
||||||
scanner.h \
|
scanner.h \
|
||||||
others.c \
|
clamd_others.c \
|
||||||
others.h \
|
clamd_others.h \
|
||||||
shared.h
|
shared.h
|
||||||
|
|
||||||
AM_CFLAGS=@WERR_CFLAGS@
|
AM_CFLAGS=@WERR_CFLAGS@
|
||||||
|
@ -58,8 +48,8 @@ endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @THREAD_LIBS@
|
LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @CLAMD_LIBS@ @THREAD_LIBS@
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
||||||
|
|
||||||
# it does support --help and --version but with the default config file
|
# it does support --help and --version but with the default config file
|
||||||
# it outputs an error message which tells us to edit the config files
|
# it outputs an error message which tells us to edit the config files
|
||||||
|
|
|
@ -56,19 +56,21 @@
|
||||||
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/others.h"
|
#include "clamav.h"
|
||||||
#include "libclamav/matcher-ac.h"
|
#include "others.h"
|
||||||
#include "libclamav/readdb.h"
|
#include "matcher-ac.h"
|
||||||
|
#include "readdb.h"
|
||||||
|
|
||||||
#include "shared/output.h"
|
// shared
|
||||||
#include "shared/optparser.h"
|
#include "output.h"
|
||||||
#include "shared/misc.h"
|
#include "optparser.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "tcpserver.h"
|
#include "tcpserver.h"
|
||||||
#include "localserver.h"
|
#include "localserver.h"
|
||||||
#include "others.h"
|
#include "clamd_others.h"
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* must be first because it may define _XOPEN_SOURCE */
|
/* must be first because it may define _XOPEN_SOURCE */
|
||||||
#include "shared/fdpassing.h"
|
#include "fdpassing.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -67,15 +67,19 @@
|
||||||
#endif /* HAVE_POLL */
|
#endif /* HAVE_POLL */
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "libclamav/scanners.h"
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
#include "shared/misc.h"
|
|
||||||
#include "libclamav/others.h"
|
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
#include "scanners.h"
|
||||||
#include "others.h"
|
#include "others.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "clamd_others.h"
|
||||||
|
|
||||||
static pthread_mutex_t virusaction_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t virusaction_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static void xfree(void *p)
|
static void xfree(void *p)
|
|
@ -27,7 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
#include "thrmgr.h"
|
#include "thrmgr.h"
|
||||||
#include "clamav-types.h"
|
#include "clamav-types.h"
|
||||||
|
|
|
@ -36,14 +36,16 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/str.h"
|
#include "clamav.h"
|
||||||
|
#include "str.h"
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
// shared
|
||||||
#include "shared/output.h"
|
#include "optparser.h"
|
||||||
#include "shared/misc.h"
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#include "others.h"
|
#include "clamd_others.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "localserver.h"
|
#include "localserver.h"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#ifndef __LOCALSERVER_H
|
#ifndef __LOCALSERVER_H
|
||||||
#define __LOCALSERVER_H
|
#define __LOCALSERVER_H
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
|
|
||||||
int localserver(const struct optstruct *opts);
|
int localserver(const struct optstruct *opts);
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,18 @@
|
||||||
#endif
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/others.h"
|
#include "clamav.h"
|
||||||
#include "libclamav/scanners.h"
|
|
||||||
|
|
||||||
#include "shared/idmef_logging.h"
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
#include "shared/misc.h"
|
|
||||||
|
|
||||||
#include "others.h"
|
#include "others.h"
|
||||||
|
#include "scanners.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "idmef_logging.h"
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "clamd_others.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "thrmgr.h"
|
#include "thrmgr.h"
|
||||||
|
|
|
@ -24,9 +24,13 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "libclamav/others.h"
|
// libclamav
|
||||||
#include "libclamav/clamav.h"
|
#include "clamav.h"
|
||||||
#include "shared/optparser.h"
|
#include "others.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#include "thrmgr.h"
|
#include "thrmgr.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
||||||
|
|
|
@ -45,21 +45,23 @@
|
||||||
#ifdef C_SOLARIS
|
#ifdef C_SOLARIS
|
||||||
#include <stdio_ext.h>
|
#include <stdio_ext.h>
|
||||||
#endif
|
#endif
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
|
|
||||||
#include "shared/output.h"
|
// libclamav
|
||||||
#include "shared/optparser.h"
|
#include "clamav.h"
|
||||||
#include "shared/misc.h"
|
#include "others.h"
|
||||||
|
#include "readdb.h"
|
||||||
|
|
||||||
#include "shared/idmef_logging.h"
|
// shared
|
||||||
|
#include "output.h"
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "idmef_logging.h"
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "thrmgr.h"
|
#include "thrmgr.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "others.h"
|
#include "clamd_others.h"
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "libclamav/others.h"
|
|
||||||
#include "libclamav/readdb.h"
|
|
||||||
|
|
||||||
#define BUFFSIZE 1024
|
#define BUFFSIZE 1024
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "shared/optparser.h"
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#include "thrmgr.h"
|
#include "thrmgr.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
||||||
struct thrarg {
|
struct thrarg {
|
||||||
int sid;
|
int sid;
|
||||||
struct cl_scan_options *options;
|
struct cl_scan_options *options;
|
||||||
|
|
|
@ -50,15 +50,17 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/str.h"
|
#include "clamav.h"
|
||||||
#include "libclamav/others.h"
|
#include "str.h"
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
#include "shared/misc.h"
|
|
||||||
|
|
||||||
#include "others.h"
|
#include "others.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "clamd_others.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
|
@ -49,10 +49,14 @@
|
||||||
#define CMD23 "GET / HTTP/2"
|
#define CMD23 "GET / HTTP/2"
|
||||||
#define CMD24 ""
|
#define CMD24 ""
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "shared/optparser.h"
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "others.h"
|
#include "clamd_others.h"
|
||||||
|
|
||||||
enum commands {
|
enum commands {
|
||||||
COMMAND_UNKNOWN = 0,
|
COMMAND_UNKNOWN = 0,
|
||||||
|
|
|
@ -37,13 +37,15 @@
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
// shared
|
||||||
#include "shared/output.h"
|
#include "optparser.h"
|
||||||
#include "shared/misc.h"
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#include "others.h"
|
#include "clamd_others.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "tcpserver.h"
|
#include "tcpserver.h"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#ifndef __TCPSERVER_H
|
#ifndef __TCPSERVER_H
|
||||||
#define __TCPSERVER_H
|
#define __TCPSERVER_H
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
|
|
||||||
int tcpserver(int **lsockets, unsigned int *nlsockets, char *ipaddr, const struct optstruct *opts);
|
int tcpserver(int **lsockets, unsigned int *nlsockets, char *ipaddr, const struct optstruct *opts);
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,17 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "shared/output.h"
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "thrmgr.h"
|
|
||||||
#include "others.h"
|
#include "others.h"
|
||||||
#include "mpool.h"
|
#include "mpool.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
|
#include "thrmgr.h"
|
||||||
|
#include "clamd_others.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "libclamav/others.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_MALLINFO
|
#ifdef HAVE_MALLINFO
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
37
clamdscan/CMakeLists.txt
Normal file
37
clamdscan/CMakeLists.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||||
|
|
||||||
|
# Windows compatibility headers
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/win32/compat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The clamdscan executable.
|
||||||
|
add_executable( clamdscan )
|
||||||
|
target_sources( clamdscan
|
||||||
|
PRIVATE
|
||||||
|
clamdscan.c
|
||||||
|
client.c
|
||||||
|
client.h
|
||||||
|
proto.c
|
||||||
|
proto.h )
|
||||||
|
if(WIN32)
|
||||||
|
target_sources( clamdscan PRIVATE ${CMAKE_SOURCE_DIR}/win32/res/clamdscan.rc )
|
||||||
|
endif()
|
||||||
|
target_include_directories( clamdscan
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clamdscan PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamdscan
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared )
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS clamdscan DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
install(TARGETS clamdscan DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
|
@ -22,18 +22,6 @@ if BUILD_CLAMD
|
||||||
bin_PROGRAMS = clamdscan
|
bin_PROGRAMS = clamdscan
|
||||||
|
|
||||||
clamdscan_SOURCES = \
|
clamdscan_SOURCES = \
|
||||||
$(top_srcdir)/shared/output.c \
|
|
||||||
$(top_srcdir)/shared/output.h \
|
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/actions.c \
|
|
||||||
$(top_srcdir)/shared/actions.h \
|
|
||||||
$(top_srcdir)/shared/clamdcom.c \
|
|
||||||
$(top_srcdir)/shared/clamdcom.h \
|
|
||||||
clamdscan.c \
|
clamdscan.c \
|
||||||
proto.c \
|
proto.c \
|
||||||
proto.h \
|
proto.h \
|
||||||
|
@ -44,9 +32,8 @@ AM_CFLAGS=@WERR_CFLAGS@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @SSL_CPPFLAGS@ @CLAMDSCAN_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @CLAMDSCAN_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
LIBS = $(top_builddir)/shared/libshared.la $(top_builddir)/libclamav/libclamav.la @CLAMDSCAN_LIBS@ @THREAD_LIBS@
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la @CLAMDSCAN_LIBS@
|
|
||||||
|
|
||||||
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamdscan$(EXEEXT)
|
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamdscan$(EXEEXT)
|
||||||
CLEANFILES=*.gcda *.gcno
|
CLEANFILES=*.gcda *.gcno
|
||||||
|
|
|
@ -35,13 +35,14 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
// libclamav
|
||||||
#include "clamav.h"
|
#include "clamav.h"
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// shared
|
||||||
#include "shared/output.h"
|
#include "output.h"
|
||||||
#include "shared/misc.h"
|
#include "misc.h"
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
#include "shared/actions.h"
|
#include "actions.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
|
|
|
@ -53,15 +53,17 @@
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "shared/optparser.h"
|
#include "clamav.h"
|
||||||
#include "shared/output.h"
|
#include "str.h"
|
||||||
#include "shared/misc.h"
|
#include "others.h"
|
||||||
#include "shared/actions.h"
|
|
||||||
#include "shared/clamdcom.h"
|
|
||||||
|
|
||||||
#include "libclamav/str.h"
|
// shared
|
||||||
#include "libclamav/others.h"
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "actions.h"
|
||||||
|
#include "clamdcom.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#define CLAMDSCAN_DEFAULT_PING_INTERVAL 1
|
#define CLAMDSCAN_DEFAULT_PING_INTERVAL 1
|
||||||
#define CLAMDSCAN_DEFAULT_PING_ATTEMPTS 30
|
#define CLAMDSCAN_DEFAULT_PING_ATTEMPTS 30
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CONT,
|
CONT,
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* must be first because it may define _XOPEN_SOURCE */
|
/* must be first because it may define _XOPEN_SOURCE */
|
||||||
#include "shared/fdpassing.h"
|
#include "fdpassing.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -52,12 +52,15 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/others.h"
|
#include "clamav.h"
|
||||||
#include "shared/actions.h"
|
#include "others.h"
|
||||||
#include "shared/output.h"
|
|
||||||
#include "shared/misc.h"
|
// shared
|
||||||
#include "shared/clamdcom.h"
|
#include "actions.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "clamdcom.h"
|
||||||
|
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#ifndef PROTO_H
|
#ifndef PROTO_H
|
||||||
#define PROTO_H
|
#define PROTO_H
|
||||||
#include "shared/misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
int dconnect(void);
|
int dconnect(void);
|
||||||
int serial_client_scan(char *file, int scantype, int *infected, int *err, int maxlevel, int flags);
|
int serial_client_scan(char *file, int scantype, int *infected, int *err, int maxlevel, int flags);
|
||||||
|
|
34
clamdtop/CMakeLists.txt
Normal file
34
clamdtop/CMakeLists.txt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||||
|
|
||||||
|
# Windows compatibility headers
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/win32/compat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The clamdtop executable.
|
||||||
|
add_executable( clamdtop )
|
||||||
|
target_sources( clamdtop
|
||||||
|
PRIVATE
|
||||||
|
clamdtop.c )
|
||||||
|
if(WIN32)
|
||||||
|
target_sources( clamdtop PRIVATE ${CMAKE_SOURCE_DIR}/win32/res/clamdtop.rc )
|
||||||
|
endif()
|
||||||
|
target_include_directories( clamdtop
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clamdtop PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamdtop
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared
|
||||||
|
Curses::curses )
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS clamdtop DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
install(TARGETS clamdtop DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
|
@ -2,17 +2,15 @@ if HAVE_CURSES
|
||||||
bin_PROGRAMS = clamdtop
|
bin_PROGRAMS = clamdtop
|
||||||
man_MANS = $(top_builddir)/docs/man/clamdtop.1
|
man_MANS = $(top_builddir)/docs/man/clamdtop.1
|
||||||
clamdtop_SOURCES = \
|
clamdtop_SOURCES = \
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
clamdtop.c
|
clamdtop.c
|
||||||
|
|
||||||
AM_CFLAGS=@WERR_CFLAGS@
|
AM_CFLAGS=@WERR_CFLAGS@
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @CURSES_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @SSL_CPPFLAGS@ @CURSES_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
||||||
clamdtop_LDADD = @SSL_LDFLAGS@ @SSL_LIBS@ @CURSES_LIBS@ $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la
|
clamdtop_LDADD = @SSL_LDFLAGS@ @SSL_LIBS@ @CURSES_LIBS@ @THREAD_LIBS@ $(top_builddir)/shared/libshared.la $(top_builddir)/libclamav/libclamav.la
|
||||||
endif
|
endif
|
||||||
DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
|
|
||||||
|
DEFS = @DEFS@
|
||||||
|
|
||||||
|
# Add clamdtop.c to extra_dist so make dist will include it even if curses
|
||||||
|
# wasn't detected on this dist builder.
|
||||||
EXTRA_DIST = clamdtop.c
|
EXTRA_DIST = clamdtop.c
|
||||||
|
|
|
@ -60,11 +60,15 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/misc.h"
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
/* Types, prototypes and globals*/
|
/* Types, prototypes and globals*/
|
||||||
typedef struct connection {
|
typedef struct connection {
|
||||||
int sd;
|
int sd;
|
||||||
|
@ -441,7 +445,7 @@ static void cleanup(void)
|
||||||
for (i = 0; i < global.num_clamd; i++) {
|
for (i = 0; i < global.num_clamd; i++) {
|
||||||
if (global.conn[i].sd && global.conn[i].sd != -1) {
|
if (global.conn[i].sd && global.conn[i].sd != -1) {
|
||||||
(void)send_string_noreconn(&global.conn[i], "nEND\n");
|
(void)send_string_noreconn(&global.conn[i], "nEND\n");
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
close(global.conn[i].sd);
|
close(global.conn[i].sd);
|
||||||
#else
|
#else
|
||||||
closesocket(global.conn[i].sd);
|
closesocket(global.conn[i].sd);
|
||||||
|
@ -718,7 +722,7 @@ static int make_connection_real(const char *soname, conn_t *conn)
|
||||||
print_con_info(conn, "Connecting to: %s\n", soname);
|
print_con_info(conn, "Connecting to: %s\n", soname);
|
||||||
if (connect(s, p->ai_addr, p->ai_addrlen)) {
|
if (connect(s, p->ai_addr, p->ai_addrlen)) {
|
||||||
perror("connect");
|
perror("connect");
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
close(s);
|
close(s);
|
||||||
#else
|
#else
|
||||||
closesocket(s);
|
closesocket(s);
|
||||||
|
@ -826,7 +830,7 @@ static void reconnect(conn_t *conn)
|
||||||
EXIT_PROGRAM(RECONNECT_FAIL);
|
EXIT_PROGRAM(RECONNECT_FAIL);
|
||||||
}
|
}
|
||||||
if (conn->sd != -1) {
|
if (conn->sd != -1) {
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
close(conn->sd);
|
close(conn->sd);
|
||||||
#else
|
#else
|
||||||
closesocket(conn->sd);
|
closesocket(conn->sd);
|
||||||
|
@ -855,7 +859,7 @@ static int recv_line(conn_t *conn, char *buf, size_t len)
|
||||||
print_con_info(conn, "%s: %s", conn->remote, strerror(errno));
|
print_con_info(conn, "%s: %s", conn->remote, strerror(errno));
|
||||||
/* it could be a timeout, be nice and send an END */
|
/* it could be a timeout, be nice and send an END */
|
||||||
(void)send_string_noreconn(conn, "nEND\n");
|
(void)send_string_noreconn(conn, "nEND\n");
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
close(conn->sd);
|
close(conn->sd);
|
||||||
#else
|
#else
|
||||||
closesocket(conn->sd);
|
closesocket(conn->sd);
|
||||||
|
|
60
clamonacc/CMakeLists.txt
Normal file
60
clamonacc/CMakeLists.txt
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
# The clamonacc executable.
|
||||||
|
add_executable( clamonacc )
|
||||||
|
target_sources( clamonacc
|
||||||
|
PRIVATE
|
||||||
|
clamonacc.c
|
||||||
|
clamonacc.h
|
||||||
|
c-thread-pool/thpool.c
|
||||||
|
c-thread-pool/thpool.h
|
||||||
|
client/client.c
|
||||||
|
client/client.h
|
||||||
|
client/communication.c
|
||||||
|
client/communication.h
|
||||||
|
client/protocol.c
|
||||||
|
client/protocol.h
|
||||||
|
fanotif/fanotif.c
|
||||||
|
fanotif/fanotif.h
|
||||||
|
inotif/inotif.c
|
||||||
|
inotif/inotif.h
|
||||||
|
inotif/hash.c
|
||||||
|
inotif/hash.h
|
||||||
|
misc/priv_fts.h
|
||||||
|
misc/utils.c
|
||||||
|
misc/utils.h
|
||||||
|
scan/onas_queue.c
|
||||||
|
scan/onas_queue.h
|
||||||
|
scan/thread.c
|
||||||
|
scan/thread.h )
|
||||||
|
|
||||||
|
if(NOT HAVE_SYSTEM_LFS_FTS)
|
||||||
|
target_sources( clamonacc
|
||||||
|
PRIVATE
|
||||||
|
misc/fts.c )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories( clamonacc
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR} # So subdir source can #include "clamonacc.h"
|
||||||
|
${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
${CMAKE_SOURCE_DIR}/clamd # Yes, this is a hack! We want to use clamd headers even though clamd isn't a library.
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties( clamonacc PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamonacc
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared )
|
||||||
|
install(TARGETS clamonacc DESTINATION ${CMAKE_INSTALL_SBINDIR})
|
||||||
|
|
||||||
|
if(SYSTEMD_FOUND)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/clamav-clamonacc.service.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/clamav-clamonacc.service @ONLY)
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/clamav-clamonacc.service
|
||||||
|
DESTINATION ${SYSTEMD_UNIT_DIR})
|
||||||
|
endif()
|
|
@ -21,39 +21,29 @@
|
||||||
sbin_PROGRAMS = clamonacc
|
sbin_PROGRAMS = clamonacc
|
||||||
|
|
||||||
clamonacc_SOURCES = \
|
clamonacc_SOURCES = \
|
||||||
$(top_srcdir)/shared/output.c \
|
|
||||||
$(top_srcdir)/shared/output.h \
|
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/actions.c \
|
|
||||||
$(top_srcdir)/shared/actions.h \
|
|
||||||
clamonacc.c \
|
clamonacc.c \
|
||||||
clamonacc.h \
|
clamonacc.h \
|
||||||
./client/client.c \
|
client/client.c \
|
||||||
./client/client.h \
|
client/client.h \
|
||||||
./client/protocol.c \
|
client/protocol.c \
|
||||||
./client/protocol.h \
|
client/protocol.h \
|
||||||
./client/communication.c \
|
client/communication.c \
|
||||||
./client/communication.h \
|
client/communication.h \
|
||||||
./inotif/inotif.c \
|
inotif/inotif.c \
|
||||||
./inotif/inotif.h \
|
inotif/inotif.h \
|
||||||
./fanotif/fanotif.c \
|
fanotif/fanotif.c \
|
||||||
./fanotif/fanotif.h \
|
fanotif/fanotif.h \
|
||||||
./inotif/hash.c \
|
inotif/hash.c \
|
||||||
./inotif/hash.h \
|
inotif/hash.h \
|
||||||
./misc/utils.c \
|
misc/utils.c \
|
||||||
./misc/utils.h \
|
misc/utils.h \
|
||||||
./misc/priv_fts.h \
|
misc/priv_fts.h \
|
||||||
./scan/thread.c \
|
scan/thread.c \
|
||||||
./scan/thread.h \
|
scan/thread.h \
|
||||||
./scan/queue.c \
|
scan/onas_queue.c \
|
||||||
./scan/queue.h \
|
scan/onas_queue.h \
|
||||||
./c-thread-pool/thpool.c \
|
c-thread-pool/thpool.c \
|
||||||
./c-thread-pool/thpool.h
|
c-thread-pool/thpool.h
|
||||||
|
|
||||||
|
|
||||||
if !SYSTEM_LFS_FTS
|
if !SYSTEM_LFS_FTS
|
||||||
|
@ -62,9 +52,12 @@ endif
|
||||||
|
|
||||||
AM_CFLAGS=@WERR_CFLAGS@
|
AM_CFLAGS=@WERR_CFLAGS@
|
||||||
|
|
||||||
DEFS = @DEFS@ -DCL_NOLIBCLAMAV
|
if INSTALL_SYSTEMD_UNITS
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la @CURL_LIBS@ @CLAMONACC_LIBS@ @THREAD_LIBS@
|
systemdsystemunit_DATA = clamav-clamonacc.service
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamonacc -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @CURL_CPPFLAGS@ @SSL_CPPFLAGS@ @CLAMONACC_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
endif
|
||||||
|
|
||||||
|
LIBS = $(top_builddir)/shared/libshared.la $(top_builddir)/libclamav/libclamav.la @CURL_LIBS@ @CLAMONACC_LIBS@ @THREAD_LIBS@
|
||||||
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamonacc -I$(top_srcdir)/shared -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @CURL_CPPFLAGS@ @SSL_CPPFLAGS@ @CLAMONACC_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
||||||
|
|
||||||
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamonacc$(EXEEXT)
|
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamonacc$(EXEEXT)
|
||||||
CLEANFILES=*.gcda *.gcno
|
CLEANFILES=*.gcda *.gcno
|
||||||
|
|
17
clamonacc/clamav-clamonacc.service.in
Normal file
17
clamonacc/clamav-clamonacc.service.in
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# clamonacc systemd service file primarily the work of ChadDevOps & Aaron Brighton
|
||||||
|
# See: https://medium.com/@aaronbrighton/installation-configuration-of-clamav-antivirus-on-ubuntu-18-04-a6416bab3b41#a340
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=ClamAV On-Access Scanner
|
||||||
|
Documentation=man:clamonacc(8) man:clamd.conf(5) https://www.clamav.net/documents
|
||||||
|
Requires=clamav-daemon.service
|
||||||
|
After=clamav-daemon.service syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=root
|
||||||
|
ExecStartPre=/bin/bash -c "while [ ! -S /run/clamav/clamd.ctl ]; do sleep 1; done"
|
||||||
|
ExecStart=@prefix@/sbin/clamonacc -F --config-file=@APP_CONFIG_DIRECTORY@/clamd.conf --log=/var/log/clamav/clamonacc.log --move=/root/quarantine
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -35,25 +35,28 @@
|
||||||
#endif
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
#include <sys/fanotify.h>
|
#include <sys/fanotify.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/others.h"
|
#include "clamav.h"
|
||||||
#include "shared/output.h"
|
#include "others.h"
|
||||||
#include "shared/misc.h"
|
|
||||||
#include "shared/optparser.h"
|
// shared
|
||||||
#include "shared/actions.h"
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "actions.h"
|
||||||
|
|
||||||
#include "clamonacc.h"
|
#include "clamonacc.h"
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
#include "fanotif/fanotif.h"
|
#include "fanotif/fanotif.h"
|
||||||
#include "inotif/inotif.h"
|
#include "inotif/inotif.h"
|
||||||
#include "scan/queue.h"
|
#include "scan/onas_queue.h"
|
||||||
|
|
||||||
pthread_t ddd_pid = 0;
|
pthread_t ddd_pid = 0;
|
||||||
pthread_t scan_queue_pid = 0;
|
pthread_t scan_queue_pid = 0;
|
||||||
|
@ -178,7 +181,7 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
/* Setup fanotify */
|
/* Setup fanotify */
|
||||||
switch (onas_setup_fanotif(&ctx)) {
|
switch (onas_setup_fanotif(&ctx)) {
|
||||||
case CL_SUCCESS:
|
case CL_SUCCESS:
|
||||||
|
@ -294,7 +297,7 @@ int onas_start_eloop(struct onas_context **ctx)
|
||||||
return CL_EARG;
|
return CL_EARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
ret = onas_fan_eloop(ctx);
|
ret = onas_fan_eloop(ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -304,7 +307,7 @@ int onas_start_eloop(struct onas_context **ctx)
|
||||||
static int startup_checks(struct onas_context *ctx)
|
static int startup_checks(struct onas_context *ctx)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
char faerr[128];
|
char faerr[128];
|
||||||
#endif
|
#endif
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -316,7 +319,7 @@ static int startup_checks(struct onas_context *ctx)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
ctx->fan_fd = fanotify_init(FAN_CLASS_CONTENT | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS, O_LARGEFILE | O_RDONLY);
|
ctx->fan_fd = fanotify_init(FAN_CLASS_CONTENT | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS, O_LARGEFILE | O_RDONLY);
|
||||||
if (ctx->fan_fd < 0) {
|
if (ctx->fan_fd < 0) {
|
||||||
logg("!Clamonacc: fanotify_init failed: %s\n", cli_strerror(errno, faerr, sizeof(faerr)));
|
logg("!Clamonacc: fanotify_init failed: %s\n", cli_strerror(errno, faerr, sizeof(faerr)));
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
#ifndef __ONAS_CLAMONACC_H
|
#ifndef __ONAS_CLAMONACC_H
|
||||||
#define __ONAS_CLAMONACC_H
|
#define __ONAS_CLAMONACC_H
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
|
||||||
#ifndef ONAS_DEBUG
|
#ifndef ONAS_DEBUG
|
||||||
#define ONAS_DEBUG
|
#define ONAS_DEBUG
|
||||||
|
|
|
@ -52,14 +52,16 @@
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "shared/optparser.h"
|
#include "clamav.h"
|
||||||
#include "shared/output.h"
|
#include "str.h"
|
||||||
#include "shared/misc.h"
|
#include "others.h"
|
||||||
#include "shared/actions.h"
|
|
||||||
|
|
||||||
#include "libclamav/str.h"
|
// shared
|
||||||
#include "libclamav/others.h"
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "actions.h"
|
||||||
|
|
||||||
#include "communication.h"
|
#include "communication.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
#include "../clamonacc.h"
|
#include "../clamonacc.h"
|
||||||
|
|
||||||
#define ONAS_DEFAULT_PING_INTERVAL 1
|
#define ONAS_DEFAULT_PING_INTERVAL 1
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "shared/output.h"
|
#include "output.h"
|
||||||
|
|
||||||
#include "communication.h"
|
#include "communication.h"
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "shared/misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
struct RCVLN {
|
struct RCVLN {
|
||||||
char buf[PATH_MAX + 1024];
|
char buf[PATH_MAX + 1024];
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* must be first because it may define _XOPEN_SOURCE */
|
/* must be first because it may define _XOPEN_SOURCE */
|
||||||
#include "shared/fdpassing.h"
|
#include "fdpassing.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
@ -53,11 +53,14 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/others.h"
|
#include "clamav.h"
|
||||||
#include "shared/actions.h"
|
#include "others.h"
|
||||||
#include "shared/output.h"
|
|
||||||
#include "shared/misc.h"
|
// shared
|
||||||
|
#include "actions.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#include "communication.h"
|
#include "communication.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "shared/misc.h"
|
#include "misc.h"
|
||||||
#include "../clamonacc.h"
|
#include "../clamonacc.h"
|
||||||
|
|
||||||
int onas_dsresult(CURL *curl, int scantype, uint64_t maxstream, const char *filename, int fd, int64_t timeout, int *printok, int *errors, cl_error_t *ret_code);
|
int onas_dsresult(CURL *curl, int scantype, uint64_t maxstream, const char *filename, int fd, int64_t timeout, int *printok, int *errors, cl_error_t *ret_code);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "clamav-config.h"
|
#include "clamav-config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -36,13 +36,16 @@
|
||||||
|
|
||||||
#include <sys/fanotify.h>
|
#include <sys/fanotify.h>
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
#include "libclamav/scanners.h"
|
#include "clamav.h"
|
||||||
|
#include "scanners.h"
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
// shared
|
||||||
#include "shared/output.h"
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
#include "clamd/server.h"
|
// clamd
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
#include "../inotif/hash.h"
|
#include "../inotif/hash.h"
|
||||||
#include "../inotif/inotif.h"
|
#include "../inotif/inotif.h"
|
||||||
|
@ -50,7 +53,7 @@
|
||||||
#include "../client/client.h"
|
#include "../client/client.h"
|
||||||
|
|
||||||
#include "../scan/thread.h"
|
#include "../scan/thread.h"
|
||||||
#include "../scan/queue.h"
|
#include "../scan/onas_queue.h"
|
||||||
|
|
||||||
#include "../misc/utils.h"
|
#include "../misc/utils.h"
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
#ifndef __ONAS_FAN_H
|
#ifndef __ONAS_FAN_H
|
||||||
#define __ONAS_FAN_H
|
#define __ONAS_FAN_H
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
|
||||||
#include "../clamonacc.h"
|
#include "../clamonacc.h"
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
|
|
||||||
//void *onas_fan_th(void *arg);
|
//void *onas_fan_th(void *arg);
|
||||||
cl_error_t onas_setup_fanotif(struct onas_context **ctx);
|
cl_error_t onas_setup_fanotif(struct onas_context **ctx);
|
||||||
|
|
|
@ -33,28 +33,30 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
#include <sys/fanotify.h>
|
#include <sys/fanotify.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../fanotif/fanotif.h"
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
#include "scanners.h"
|
||||||
|
#include "str.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
|
// clamd
|
||||||
|
#include "server.h"
|
||||||
|
#include "clamd_others.h"
|
||||||
|
#include "scanner.h"
|
||||||
|
|
||||||
|
#include "../fanotif/fanotif.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "inotif.h"
|
#include "inotif.h"
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "libclamav/scanners.h"
|
|
||||||
#include "libclamav/str.h"
|
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
|
|
||||||
#include "clamd/server.h"
|
|
||||||
#include "clamd/others.h"
|
|
||||||
#include "clamd/scanner.h"
|
|
||||||
#include "../misc/priv_fts.h"
|
#include "../misc/priv_fts.h"
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
|
|
||||||
static struct onas_bucket *onas_bucket_init();
|
static struct onas_bucket *onas_bucket_init();
|
||||||
static void onas_free_bucket(struct onas_bucket *bckt);
|
static void onas_free_bucket(struct onas_bucket *bckt);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef __ONAS_HASH_H
|
#ifndef __ONAS_HASH_H
|
||||||
#define __ONAS_HASH_H
|
#define __ONAS_HASH_H
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
|
|
||||||
#define ONAS_FANWATCH 0x1
|
#define ONAS_FANWATCH 0x1
|
||||||
#define ONAS_INWATCH 0x2
|
#define ONAS_INWATCH 0x2
|
||||||
|
|
|
@ -34,31 +34,32 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
#include <sys/fanotify.h>
|
#include <sys/fanotify.h>
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../fanotif/fanotif.h"
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
#include "scanners.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
|
// clamd
|
||||||
|
#include "server.h"
|
||||||
|
#include "clamd_others.h"
|
||||||
|
#include "scanner.h"
|
||||||
|
|
||||||
|
#include "../fanotif/fanotif.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "inotif.h"
|
#include "inotif.h"
|
||||||
|
|
||||||
#include "../scan/thread.h"
|
#include "../scan/thread.h"
|
||||||
#include "../scan/queue.h"
|
#include "../scan/onas_queue.h"
|
||||||
#include "../misc/utils.h"
|
#include "../misc/utils.h"
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
#include "libclamav/scanners.h"
|
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
|
|
||||||
#include "clamd/server.h"
|
|
||||||
#include "clamd/others.h"
|
|
||||||
#include "clamd/scanner.h"
|
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
|
||||||
|
|
||||||
static int onas_ddd_init_ht(uint32_t ht_size);
|
static int onas_ddd_init_ht(uint32_t ht_size);
|
||||||
static int onas_ddd_init_wdlt(uint64_t nwatches);
|
static int onas_ddd_init_wdlt(uint64_t nwatches);
|
||||||
|
|
|
@ -21,10 +21,14 @@
|
||||||
#ifndef __ONAS_IN_H
|
#ifndef __ONAS_IN_H
|
||||||
#define __ONAS_IN_H
|
#define __ONAS_IN_H
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "clamonacc.h"
|
#include "clamonacc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -30,17 +30,23 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "shared/optparser.h"
|
// libclamav
|
||||||
#include "shared/output.h"
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
|
// clamd
|
||||||
|
#include "scanner.h"
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "clamd/scanner.h"
|
|
||||||
#include "../clamonacc.h"
|
#include "../clamonacc.h"
|
||||||
#include "../client/client.h"
|
#include "../client/client.h"
|
||||||
#include "../scan/queue.h"
|
#include "../scan/onas_queue.h"
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
|
|
||||||
extern pthread_cond_t onas_scan_queue_empty_cond;
|
extern pthread_cond_t onas_scan_queue_empty_cond;
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,12 @@
|
||||||
#ifndef __CLAMD_ONAS_OTHERS_H
|
#ifndef __CLAMD_ONAS_OTHERS_H
|
||||||
#define __CLAMD_ONAS_OTHERS_H
|
#define __CLAMD_ONAS_OTHERS_H
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
// libclamav
|
||||||
#include "libclamav/clamav.h"
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#include "../clamonacc.h"
|
#include "../clamonacc.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -31,7 +35,7 @@ typedef enum {
|
||||||
CHK_SELF
|
CHK_SELF
|
||||||
} cli_check_t;
|
} cli_check_t;
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
int onas_fan_checkowner(int pid, const struct optstruct *opts);
|
int onas_fan_checkowner(int pid, const struct optstruct *opts);
|
||||||
#endif
|
#endif
|
||||||
char **onas_get_opt_list(const char *fname, int *num_entries, cl_error_t *err);
|
char **onas_get_opt_list(const char *fname, int *num_entries, cl_error_t *err);
|
||||||
|
|
|
@ -32,17 +32,17 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
#include "../misc/utils.h"
|
#include "../misc/utils.h"
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
|
|
||||||
#include "../c-thread-pool/thpool.h"
|
#include "../c-thread-pool/thpool.h"
|
||||||
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "queue.h"
|
#include "onas_queue.h"
|
||||||
|
|
||||||
static void onas_scan_queue_exit(void *arg);
|
static void onas_scan_queue_exit(void *arg);
|
||||||
static int onas_consume_event(threadpool thpool);
|
static int onas_consume_event(threadpool thpool);
|
|
@ -30,14 +30,17 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
#include <sys/fanotify.h>
|
#include <sys/fanotify.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
// libclamav
|
||||||
#include "shared/output.h"
|
#include "others.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
#include "libclamav/others.h"
|
|
||||||
#include "../misc/priv_fts.h"
|
#include "../misc/priv_fts.h"
|
||||||
#include "../misc/utils.h"
|
#include "../misc/utils.h"
|
||||||
#include "../client/client.h"
|
#include "../client/client.h"
|
||||||
|
@ -110,7 +113,7 @@ static cl_error_t onas_scan_safe(struct onas_scan_event *event_data, const char
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
uint8_t b_fanotify;
|
uint8_t b_fanotify;
|
||||||
|
|
||||||
b_fanotify = event_data->bool_opts & ONAS_SCTH_B_FANOTIFY ? 1 : 0;
|
b_fanotify = event_data->bool_opts & ONAS_SCTH_B_FANOTIFY ? 1 : 0;
|
||||||
|
@ -133,7 +136,7 @@ static cl_error_t onas_scan_safe(struct onas_scan_event *event_data, const char
|
||||||
static cl_error_t onas_scan_thread_scanfile(struct onas_scan_event *event_data, const char *fname, STATBUF sb, int *infected, int *err, cl_error_t *ret_code)
|
static cl_error_t onas_scan_thread_scanfile(struct onas_scan_event *event_data, const char *fname, STATBUF sb, int *infected, int *err, cl_error_t *ret_code)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
struct fanotify_response res;
|
struct fanotify_response res;
|
||||||
uint8_t b_fanotify;
|
uint8_t b_fanotify;
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,7 +154,7 @@ static cl_error_t onas_scan_thread_scanfile(struct onas_scan_event *event_data,
|
||||||
b_scan = event_data->bool_opts & ONAS_SCTH_B_SCAN ? 1 : 0;
|
b_scan = event_data->bool_opts & ONAS_SCTH_B_SCAN ? 1 : 0;
|
||||||
b_deny_on_error = event_data->bool_opts & ONAS_SCTH_B_DENY_ON_E ? 1 : 0;
|
b_deny_on_error = event_data->bool_opts & ONAS_SCTH_B_DENY_ON_E ? 1 : 0;
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
b_fanotify = event_data->bool_opts & ONAS_SCTH_B_FANOTIFY ? 1 : 0;
|
b_fanotify = event_data->bool_opts & ONAS_SCTH_B_FANOTIFY ? 1 : 0;
|
||||||
if (b_fanotify) {
|
if (b_fanotify) {
|
||||||
res.fd = event_data->fmd->fd;
|
res.fd = event_data->fmd->fd;
|
||||||
|
@ -166,7 +169,7 @@ static cl_error_t onas_scan_thread_scanfile(struct onas_scan_event *event_data,
|
||||||
logg("*ClamWorker: scan failed with error code %d\n", *ret_code);
|
logg("*ClamWorker: scan failed with error code %d\n", *ret_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
if (b_fanotify) {
|
if (b_fanotify) {
|
||||||
if ((*err && *ret_code && b_deny_on_error) || *infected) {
|
if ((*err && *ret_code && b_deny_on_error) || *infected) {
|
||||||
res.response = FAN_DENY;
|
res.response = FAN_DENY;
|
||||||
|
@ -175,7 +178,7 @@ static cl_error_t onas_scan_thread_scanfile(struct onas_scan_event *event_data,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
if (b_fanotify) {
|
if (b_fanotify) {
|
||||||
if (event_data->fmd->mask & FAN_ALL_PERM_EVENTS) {
|
if (event_data->fmd->mask & FAN_ALL_PERM_EVENTS) {
|
||||||
ret = write(event_data->fan_fd, &res, sizeof(res));
|
ret = write(event_data->fan_fd, &res, sizeof(res));
|
||||||
|
@ -325,7 +328,7 @@ void *onas_scan_worker(void *arg)
|
||||||
b_inotify = event_data->bool_opts & ONAS_SCTH_B_INOTIFY ? 1 : 0;
|
b_inotify = event_data->bool_opts & ONAS_SCTH_B_INOTIFY ? 1 : 0;
|
||||||
b_fanotify = event_data->bool_opts & ONAS_SCTH_B_FANOTIFY ? 1 : 0;
|
b_fanotify = event_data->bool_opts & ONAS_SCTH_B_FANOTIFY ? 1 : 0;
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
if (b_inotify) {
|
if (b_inotify) {
|
||||||
logg("*ClamWorker: handling inotify event ...\n");
|
logg("*ClamWorker: handling inotify event ...\n");
|
||||||
|
|
||||||
|
@ -363,7 +366,7 @@ done:
|
||||||
event_data->pathname = NULL;
|
event_data->pathname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
if (NULL != event_data->fmd) {
|
if (NULL != event_data->fmd) {
|
||||||
free(event_data->fmd);
|
free(event_data->fmd);
|
||||||
event_data->fmd = NULL;
|
event_data->fmd = NULL;
|
||||||
|
|
|
@ -21,11 +21,15 @@
|
||||||
#ifndef __ONAS_SCTH_H
|
#ifndef __ONAS_SCTH_H
|
||||||
#define __ONAS_SCTH_H
|
#define __ONAS_SCTH_H
|
||||||
|
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
#include <sys/fanotify.h>
|
#include <sys/fanotify.h>
|
||||||
#endif
|
#endif
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "libclamav/clamav.h"
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#define ONAS_SCTH_B_DIR 0x01
|
#define ONAS_SCTH_B_DIR 0x01
|
||||||
#define ONAS_SCTH_B_FILE 0x02
|
#define ONAS_SCTH_B_FILE 0x02
|
||||||
|
@ -51,7 +55,7 @@ struct onas_scan_event {
|
||||||
int64_t portnum;
|
int64_t portnum;
|
||||||
char *pathname;
|
char *pathname;
|
||||||
int fan_fd;
|
int fan_fd;
|
||||||
#if defined(FANOTIFY)
|
#if defined(HAVE_SYS_FANOTIFY_H)
|
||||||
struct fanotify_event_metadata *fmd;
|
struct fanotify_event_metadata *fmd;
|
||||||
#endif
|
#endif
|
||||||
uint8_t retry_attempts;
|
uint8_t retry_attempts;
|
||||||
|
|
36
clamscan/CMakeLists.txt
Normal file
36
clamscan/CMakeLists.txt
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||||
|
|
||||||
|
# Windows compatibility headers
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/win32/compat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The clamscan executable.
|
||||||
|
add_executable( clamscan )
|
||||||
|
target_sources( clamscan
|
||||||
|
PRIVATE
|
||||||
|
clamscan.c
|
||||||
|
manager.c
|
||||||
|
manager.h
|
||||||
|
global.h )
|
||||||
|
if(WIN32)
|
||||||
|
target_sources( clamscan PRIVATE ${CMAKE_SOURCE_DIR}/win32/res/clamscan.rc )
|
||||||
|
endif()
|
||||||
|
target_include_directories( clamscan
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clamscan PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamscan
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared )
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS clamscan DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
install(TARGETS clamscan DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
|
@ -23,24 +23,14 @@
|
||||||
bin_PROGRAMS = clamscan
|
bin_PROGRAMS = clamscan
|
||||||
|
|
||||||
clamscan_SOURCES = \
|
clamscan_SOURCES = \
|
||||||
$(top_srcdir)/shared/output.c \
|
|
||||||
$(top_srcdir)/shared/output.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/actions.c \
|
|
||||||
$(top_srcdir)/shared/actions.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
clamscan.c \
|
clamscan.c \
|
||||||
global.h \
|
global.h \
|
||||||
manager.c \
|
manager.c \
|
||||||
manager.h
|
manager.h
|
||||||
|
|
||||||
AM_CFLAGS=@WERR_CFLAGS@
|
AM_CFLAGS=@WERR_CFLAGS@
|
||||||
DEFS = @DEFS@ -DCL_NOTHREADS
|
DEFS = @DEFS@
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ @CLAMSCAN_LIBS@
|
LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @THREAD_LIBS@ @CLAMSCAN_LIBS@
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ @CLAMSCAN_CPPFLAGS@
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ @CLAMSCAN_CPPFLAGS@
|
||||||
|
|
||||||
CLEANFILES=*.gcda *.gcno
|
CLEANFILES=*.gcda *.gcno
|
||||||
|
|
|
@ -39,18 +39,20 @@
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
#include "others.h"
|
#include "others.h"
|
||||||
|
#include "str.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "misc.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "actions.h"
|
||||||
|
#include "optparser.h"
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
|
|
||||||
#include "shared/misc.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
#include "shared/actions.h"
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
|
|
||||||
#include "libclamav/str.h"
|
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
|
|
||||||
void help(void);
|
void help(void);
|
||||||
|
|
||||||
struct s_info info;
|
struct s_info info;
|
||||||
|
|
|
@ -49,20 +49,23 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <target.h>
|
#include <target.h>
|
||||||
|
|
||||||
|
// libclamav
|
||||||
|
#include "clamav.h"
|
||||||
|
#include "others.h"
|
||||||
|
#include "matcher-ac.h"
|
||||||
|
#include "matcher-pcre.h"
|
||||||
|
#include "str.h"
|
||||||
|
#include "readdb.h"
|
||||||
|
|
||||||
|
// shared
|
||||||
|
#include "optparser.h"
|
||||||
|
#include "actions.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
|
||||||
#include "shared/actions.h"
|
|
||||||
#include "shared/output.h"
|
|
||||||
#include "shared/misc.h"
|
|
||||||
|
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "libclamav/others.h"
|
|
||||||
#include "libclamav/matcher-ac.h"
|
|
||||||
#include "libclamav/matcher-pcre.h"
|
|
||||||
#include "libclamav/str.h"
|
|
||||||
#include "libclamav/readdb.h"
|
|
||||||
|
|
||||||
#ifdef C_LINUX
|
#ifdef C_LINUX
|
||||||
dev_t procdev;
|
dev_t procdev;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#ifndef __MANAGER_H
|
#ifndef __MANAGER_H
|
||||||
#define __MANAGER_H
|
#define __MANAGER_H
|
||||||
|
|
||||||
#include "shared/optparser.h"
|
#include "optparser.h"
|
||||||
|
|
||||||
int scanmanager(const struct optstruct *opts);
|
int scanmanager(const struct optstruct *opts);
|
||||||
|
|
||||||
|
|
40
clamsubmit/CMakeLists.txt
Normal file
40
clamsubmit/CMakeLists.txt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# Copyright (C) 2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.12...3.13 )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||||
|
|
||||||
|
# Windows compatibility headers
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/win32/compat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The clamsubmit executable.
|
||||||
|
add_executable( clamsubmit )
|
||||||
|
target_sources( clamsubmit
|
||||||
|
PRIVATE
|
||||||
|
clamsubmit.c )
|
||||||
|
if(WIN32)
|
||||||
|
target_sources( clamsubmit PRIVATE ${CMAKE_SOURCE_DIR}/win32/res/clamsubmit.rc )
|
||||||
|
endif()
|
||||||
|
target_include_directories( clamsubmit
|
||||||
|
PRIVATE ${CMAKE_BINARY_DIR} # For clamav-config.h
|
||||||
|
)
|
||||||
|
set_target_properties( clamsubmit PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )
|
||||||
|
target_link_libraries( clamsubmit
|
||||||
|
PRIVATE
|
||||||
|
ClamAV::libclamav
|
||||||
|
ClamAV::shared
|
||||||
|
JSONC::jsonc )
|
||||||
|
if(APPLE)
|
||||||
|
target_link_libraries( clamsubmit
|
||||||
|
PUBLIC
|
||||||
|
${APPLE_CORE_FOUNDATION}
|
||||||
|
${APPLE_SECURITY} )
|
||||||
|
endif()
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS clamsubmit DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
else()
|
||||||
|
install(TARGETS clamsubmit DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
|
@ -19,40 +19,12 @@
|
||||||
bin_PROGRAMS = clamsubmit
|
bin_PROGRAMS = clamsubmit
|
||||||
|
|
||||||
clamsubmit_SOURCES = \
|
clamsubmit_SOURCES = \
|
||||||
$(top_srcdir)/shared/output.c \
|
|
||||||
$(top_srcdir)/shared/output.h \
|
|
||||||
$(top_srcdir)/shared/optparser.c \
|
|
||||||
$(top_srcdir)/shared/optparser.h \
|
|
||||||
$(top_srcdir)/shared/getopt.c \
|
|
||||||
$(top_srcdir)/shared/getopt.h \
|
|
||||||
$(top_srcdir)/shared/misc.c \
|
|
||||||
$(top_srcdir)/shared/misc.h \
|
|
||||||
$(top_srcdir)/shared/cert_util.c \
|
|
||||||
$(top_srcdir)/shared/cert_util.h \
|
|
||||||
$(top_srcdir)/shared/cert_util_internal.h \
|
|
||||||
clamsubmit.c
|
clamsubmit.c
|
||||||
|
|
||||||
if MACOS
|
|
||||||
clamsubmit_SOURCES += \
|
|
||||||
$(top_srcdir)/shared/mac/cert_util_mac.m \
|
|
||||||
$(top_srcdir)/shared/cert_util.h
|
|
||||||
endif
|
|
||||||
if WINDOWS
|
|
||||||
clamsubmit_SOURCES += \
|
|
||||||
$(top_srcdir)/shared/win/cert_util_win.c \
|
|
||||||
$(top_srcdir)/shared/cert_util.h
|
|
||||||
endif
|
|
||||||
if LINUX
|
|
||||||
clamsubmit_SOURCES += \
|
|
||||||
$(top_srcdir)/shared/linux/cert_util_linux.c \
|
|
||||||
$(top_srcdir)/shared/cert_util.h
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
AM_CFLAGS=@WERR_CFLAGS@ @CLAMSUBMIT_CFLAGS@
|
AM_CFLAGS=@WERR_CFLAGS@ @CLAMSUBMIT_CFLAGS@
|
||||||
DEFS = @DEFS@ -DCL_NOTHREADS
|
DEFS = @DEFS@
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
|
||||||
LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMSUBMIT_LIBS@ @THREAD_LIBS@ @JSON_LIBS@ @SSL_LIBS@
|
LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @CLAMSUBMIT_LIBS@ @THREAD_LIBS@ @JSON_LIBS@ @SSL_LIBS@
|
||||||
|
|
||||||
if MACOS
|
if MACOS
|
||||||
AM_LDFLAGS = -framework CoreFoundation -framework Security
|
AM_LDFLAGS = -framework CoreFoundation -framework Security
|
||||||
|
|
|
@ -11,13 +11,18 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <json-c/json.h>
|
||||||
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "libclamav/clamav.h"
|
|
||||||
#include "libclamav/others.h"
|
// libclamav
|
||||||
#include "shared/misc.h"
|
#include "clamav.h"
|
||||||
#include "shared/getopt.h"
|
#include "others.h"
|
||||||
#include "shared/cert_util.h"
|
|
||||||
|
// shared
|
||||||
|
#include "misc.h"
|
||||||
|
#include "getopt.h"
|
||||||
|
#include "cert_util.h"
|
||||||
|
|
||||||
#define OPTS "e:p:n:N:V:H:h?v?d"
|
#define OPTS "e:p:n:N:V:H:h?v?d"
|
||||||
|
|
||||||
|
|
147
cmake/CheckFDPassing.c
Normal file
147
cmake/CheckFDPassing.c
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef HAVE_SYS_UIO_H
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#endif
|
||||||
|
#include <signal.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#if !defined CMSG_SPACE || !defined CMSG_LEN
|
||||||
|
#ifndef ALIGN
|
||||||
|
#define ALIGN(len) len
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CMSG_SPACE
|
||||||
|
#define CMSG_SPACE(len) (ALIGN(sizeof(struct cmsghdr)) + ALIGN(len))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CMSG_LEN
|
||||||
|
#define CMSG_LEN(len) (ALIGN(sizeof(struct cmsghdr)) + len)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TEST "test"
|
||||||
|
|
||||||
|
static int send_fd(int s, int fd)
|
||||||
|
{
|
||||||
|
struct msghdr msg;
|
||||||
|
struct cmsghdr *cmsg;
|
||||||
|
unsigned char fdbuf[CMSG_SPACE(sizeof(int))];
|
||||||
|
struct iovec iov[1];
|
||||||
|
char dummy[] = "";
|
||||||
|
|
||||||
|
iov[0].iov_base = dummy;
|
||||||
|
iov[0].iov_len = 1;
|
||||||
|
|
||||||
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
msg.msg_control = fdbuf;
|
||||||
|
/* must send/receive at least one byte */
|
||||||
|
msg.msg_iov = iov;
|
||||||
|
msg.msg_iovlen = 1;
|
||||||
|
msg.msg_controllen = CMSG_LEN(sizeof(int));
|
||||||
|
|
||||||
|
cmsg = CMSG_FIRSTHDR(&msg);
|
||||||
|
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
|
||||||
|
cmsg->cmsg_level = SOL_SOCKET;
|
||||||
|
cmsg->cmsg_type = SCM_RIGHTS;
|
||||||
|
*(int *)CMSG_DATA(cmsg) = fd;
|
||||||
|
|
||||||
|
if (sendmsg(s, &msg, 0) == -1) {
|
||||||
|
perror("sendmsg");
|
||||||
|
close(s);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int testfd(int desc)
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
if (read(desc, buf, sizeof(buf)) != sizeof(TEST)) {
|
||||||
|
fprintf(stderr, "test data not received correctly!");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return memcmp(buf, TEST, sizeof(TEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int recv_fd(int desc)
|
||||||
|
{
|
||||||
|
unsigned char buf[CMSG_SPACE(sizeof(int))];
|
||||||
|
struct msghdr msg;
|
||||||
|
struct cmsghdr *cmsg;
|
||||||
|
struct iovec iov[1];
|
||||||
|
char dummy;
|
||||||
|
int ret = 2;
|
||||||
|
|
||||||
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
iov[0].iov_base = &dummy;
|
||||||
|
iov[0].iov_len = 1;
|
||||||
|
msg.msg_iov = iov;
|
||||||
|
msg.msg_iovlen = 1;
|
||||||
|
msg.msg_control = buf;
|
||||||
|
msg.msg_controllen = sizeof(buf);
|
||||||
|
|
||||||
|
if (recvmsg(desc, &msg, 0) == -1) {
|
||||||
|
perror("recvmsg failed!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ((msg.msg_flags & MSG_TRUNC) || (msg.msg_flags & MSG_CTRUNC)) {
|
||||||
|
fprintf(stderr, "control message truncated");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
|
||||||
|
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||||
|
if (cmsg->cmsg_len == CMSG_LEN(sizeof(int)) &&
|
||||||
|
cmsg->cmsg_level == SOL_SOCKET &&
|
||||||
|
cmsg->cmsg_type == SCM_RIGHTS) {
|
||||||
|
int fd = *(int *)CMSG_DATA(cmsg);
|
||||||
|
ret = testfd(fd);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int fd[2];
|
||||||
|
int pip[2];
|
||||||
|
pid_t pid;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
if (pipe(pip)) {
|
||||||
|
perror("pipe");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) {
|
||||||
|
perror("socketpair");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pid = fork()) < 0) {
|
||||||
|
perror("fork");
|
||||||
|
} else if (!pid) {
|
||||||
|
exit(recv_fd(fd[1]));
|
||||||
|
} else {
|
||||||
|
/* parent */
|
||||||
|
if (send_fd(fd[0], pip[0]) == -1) {
|
||||||
|
kill(pid, 9);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (write(pip[1], TEST, sizeof(TEST)) != sizeof(TEST)) {
|
||||||
|
close(pip[1]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
close(pip[1]);
|
||||||
|
waitpid(pid, &status, 0);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
105
cmake/CheckFDPassing.cmake
Normal file
105
cmake/CheckFDPassing.cmake
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
#
|
||||||
|
# Check if file descriptor passing is supported
|
||||||
|
# Derived from work submitted by Richard Lyons <frob-clamav@webcentral.com.au>
|
||||||
|
#
|
||||||
|
|
||||||
|
GET_FILENAME_COMPONENT(_selfdir_CheckFDPassing
|
||||||
|
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
check_symbol_exists(recvmsg "sys/socket.h" HAVE_RECVMSG)
|
||||||
|
check_symbol_exists(sendmsg "sys/socket.h" HAVE_SENDMSG)
|
||||||
|
|
||||||
|
# Extra -D Compile Definitions for check_c_source_compiles()
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS "")
|
||||||
|
if(HAVE_SYS_TYPES_H)
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS};-DHAVE_SYS_TYPES_H=1")
|
||||||
|
endif()
|
||||||
|
if(HAVE_SYS_UIO_H)
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS};-DHAVE_SYS_UIO_H=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check for msg_control field in struct msghdr
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
#define _XOPEN_SOURCE 500
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#ifdef HAVE_SYS_UIO_H
|
||||||
|
# include <sys/uio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
#ifdef msg_control
|
||||||
|
# error msg_control defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct msghdr m;
|
||||||
|
m.msg_control = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_CONTROL_IN_MSGHDR )
|
||||||
|
|
||||||
|
if(HAVE_CONTROL_IN_MSGHDR)
|
||||||
|
#
|
||||||
|
# Check whether BSD 4.4 / RFC2292 style fd passing works
|
||||||
|
#
|
||||||
|
set(EXTRA_COMPILE_DEFINITIONS "")
|
||||||
|
if(HAVE_SYS_TYPES_H)
|
||||||
|
set(EXTRA_COMPILE_DEFINITIONS "${EXTRA_COMPILE_DEFINITIONS} -DHAVE_SYS_TYPES_H=1")
|
||||||
|
endif()
|
||||||
|
if(HAVE_SYS_UIO_H)
|
||||||
|
set(EXTRA_COMPILE_DEFINITIONS "${EXTRA_COMPILE_DEFINITIONS} -DHAVE_SYS_UIO_H=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Try without _XOPEN_SOURCE first
|
||||||
|
try_run(
|
||||||
|
# Name of variable to store the run result (process exit status; number) in:
|
||||||
|
test_run_result
|
||||||
|
# Name of variable to store the compile result (TRUE or FALSE) in:
|
||||||
|
test_compile_result
|
||||||
|
# Binary directory:
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
# Source file to be compiled:
|
||||||
|
${_selfdir_CheckFDPassing}/CheckFDPassing.c
|
||||||
|
# Extra -D Compile Definitions
|
||||||
|
COMPILE_DEFINITIONS ${EXTRA_COMPILE_DEFINITIONS}
|
||||||
|
# Where to store the output produced during compilation:
|
||||||
|
COMPILE_OUTPUT_VARIABLE test_compile_output
|
||||||
|
# Where to store the output produced by running the compiled executable:
|
||||||
|
RUN_OUTPUT_VARIABLE test_run_output )
|
||||||
|
|
||||||
|
# Did compilation succeed and process return 0 (success)?
|
||||||
|
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
|
||||||
|
set(HAVE_FD_PASSING 1)
|
||||||
|
else()
|
||||||
|
# Try again, this time with: #define _XOPEN_SOURCE 500
|
||||||
|
set(EXTRA_COMPILE_DEFINITIONS "${EXTRA_COMPILE_DEFINITIONS} -D_XOPEN_SOURCE=500")
|
||||||
|
|
||||||
|
try_run(
|
||||||
|
# Name of variable to store the run result (process exit status; number) in:
|
||||||
|
test_run_result
|
||||||
|
# Name of variable to store the compile result (TRUE or FALSE) in:
|
||||||
|
test_compile_result
|
||||||
|
# Binary directory:
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
# Source file to be compiled:
|
||||||
|
${_selfdir_CheckFDPassing}/CheckFDPassing.c
|
||||||
|
# Extra -D Compile Definitions
|
||||||
|
COMPILE_DEFINITIONS ${EXTRA_COMPILE_DEFINITIONS}
|
||||||
|
# Where to store the output produced during compilation:
|
||||||
|
COMPILE_OUTPUT_VARIABLE test_compile_output
|
||||||
|
# Where to store the output produced by running the compiled executable:
|
||||||
|
RUN_OUTPUT_VARIABLE test_run_output )
|
||||||
|
|
||||||
|
# Did compilation succeed and process return 0 (success)?
|
||||||
|
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
|
||||||
|
set(HAVE_FD_PASSING 1)
|
||||||
|
set(FDPASS_NEED_XOPEN 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
20
cmake/CheckFTS.cmake
Normal file
20
cmake/CheckFTS.cmake
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#
|
||||||
|
# Check for struct packing features
|
||||||
|
# This feature reworked from m4/reorganization/code_checks/compiler_attribs.m4
|
||||||
|
#
|
||||||
|
|
||||||
|
GET_FILENAME_COMPONENT(_selfdir_CheckFTS
|
||||||
|
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
|
# Check if __attribute__((packed)) is available
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
#include <fts.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
fts_open((void *)0, FTS_PHYSICAL, (void *)0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_SYSTEM_LFS_FTS )
|
14
cmake/CheckFileOffsetBits.c
Normal file
14
cmake/CheckFileOffsetBits.c
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#define KB ((off_t)1024)
|
||||||
|
#define MB ((off_t)1024 * KB)
|
||||||
|
#define GB ((off_t)1024 * MB)
|
||||||
|
#define TB ((off_t)1024 * GB)
|
||||||
|
int t2[(((64 * GB -1) % 671088649) == 268434537)
|
||||||
|
&& (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1];
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
43
cmake/CheckFileOffsetBits.cmake
Normal file
43
cmake/CheckFileOffsetBits.cmake
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# - Check if _FILE_OFFSET_BITS macro needed for large files
|
||||||
|
# CHECK_FILE_OFFSET_BITS ()
|
||||||
|
#
|
||||||
|
# The following variables may be set before calling this macro to
|
||||||
|
# modify the way the check is run:
|
||||||
|
#
|
||||||
|
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||||
|
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||||
|
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||||
|
# Copyright (c) 2009, Michihiro NAKAJIMA
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
#INCLUDE(CheckCSourceCompiles)
|
||||||
|
|
||||||
|
GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits
|
||||||
|
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
|
MACRO (CHECK_FILE_OFFSET_BITS)
|
||||||
|
IF(NOT DEFINED _FILE_OFFSET_BITS)
|
||||||
|
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files")
|
||||||
|
TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
|
||||||
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
|
||||||
|
IF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
|
||||||
|
TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
|
||||||
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
|
||||||
|
ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
|
||||||
|
|
||||||
|
IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
|
||||||
|
SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
|
||||||
|
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - needed")
|
||||||
|
ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
|
||||||
|
SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
|
||||||
|
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed")
|
||||||
|
ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
|
||||||
|
ENDIF(NOT DEFINED _FILE_OFFSET_BITS)
|
||||||
|
|
||||||
|
ENDMACRO (CHECK_FILE_OFFSET_BITS)
|
6
cmake/CheckSignedRightShift.c
Normal file
6
cmake/CheckSignedRightShift.c
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int a = -1;
|
||||||
|
int b = a >> 1;
|
||||||
|
return (a != b);
|
||||||
|
}
|
26
cmake/CheckSignedRightShift.cmake
Normal file
26
cmake/CheckSignedRightShift.cmake
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#
|
||||||
|
# Check for signed right-shift
|
||||||
|
#
|
||||||
|
|
||||||
|
GET_FILENAME_COMPONENT(_selfdir_CheckSignedRightShift
|
||||||
|
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
|
# Check for signed right-shift (HAVE_SAR)
|
||||||
|
try_run(
|
||||||
|
# Name of variable to store the run result (process exit status; number) in:
|
||||||
|
test_run_result
|
||||||
|
# Name of variable to store the compile result (TRUE or FALSE) in:
|
||||||
|
test_compile_result
|
||||||
|
# Binary directory:
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
# Source file to be compiled:
|
||||||
|
${_selfdir_CheckSignedRightShift}/CheckSignedRightShift.c
|
||||||
|
# Where to store the output produced during compilation:
|
||||||
|
COMPILE_OUTPUT_VARIABLE test_compile_output
|
||||||
|
# Where to store the output produced by running the compiled executable:
|
||||||
|
RUN_OUTPUT_VARIABLE test_run_output )
|
||||||
|
|
||||||
|
# Did compilation succeed and process return 0 (success)?
|
||||||
|
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
|
||||||
|
set(HAVE_SAR 1)
|
||||||
|
endif()
|
72
cmake/CheckStructPacking.cmake
Normal file
72
cmake/CheckStructPacking.cmake
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#
|
||||||
|
# Check for struct packing features
|
||||||
|
# This feature reworked from m4/reorganization/code_checks/compiler_attribs.m4
|
||||||
|
#
|
||||||
|
|
||||||
|
GET_FILENAME_COMPONENT(_selfdir_CheckStructPacking
|
||||||
|
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
|
# Check if __attribute__((packed)) is available
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
#ifdef __GNUC__
|
||||||
|
struct { int i __attribute__((packed)); } s;
|
||||||
|
#else
|
||||||
|
#error Only checking for packed attribute on gcc-like compilers
|
||||||
|
#endif
|
||||||
|
"
|
||||||
|
HAVE_ATTRIB_PACKED )
|
||||||
|
if(NOT HAVE_ATTRIB_PACKED)
|
||||||
|
# Check for packing via pragma (HAVE_PRAGMA_PACK)
|
||||||
|
try_run(
|
||||||
|
# Name of variable to store the run result (process exit status; number) in:
|
||||||
|
test_run_result
|
||||||
|
# Name of variable to store the compile result (TRUE or FALSE) in:
|
||||||
|
test_compile_result
|
||||||
|
# Binary directory:
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
# Source file to be compiled:
|
||||||
|
${_selfdir_CheckStructPacking}/CheckStructPacking_PRAGMA_PACK.c
|
||||||
|
# Where to store the output produced during compilation:
|
||||||
|
COMPILE_OUTPUT_VARIABLE test_compile_output
|
||||||
|
# Where to store the output produced by running the compiled executable:
|
||||||
|
RUN_OUTPUT_VARIABLE test_run_output )
|
||||||
|
|
||||||
|
# Did compilation succeed and process return 0 (success)?
|
||||||
|
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
|
||||||
|
set(HAVE_PRAGMA_PACK 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT HAVE_PRAGMA_PACK)
|
||||||
|
# Check for packing via hppa/hp-uux pragma (HAVE_PRAGMA_PACK_HPPA)
|
||||||
|
try_run(
|
||||||
|
# Name of variable to store the run result (process exit status; number) in:
|
||||||
|
test_run_result
|
||||||
|
# Name of variable to store the compile result (TRUE or FALSE) in:
|
||||||
|
test_compile_result
|
||||||
|
# Binary directory:
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
# Source file to be compiled:
|
||||||
|
${_selfdir_CheckStructPacking}/CheckStructPacking_PRAGMA_PACK_HPPA.c
|
||||||
|
# Where to store the output produced during compilation:
|
||||||
|
COMPILE_OUTPUT_VARIABLE test_compile_output
|
||||||
|
# Where to store the output produced by running the compiled executable:
|
||||||
|
RUN_OUTPUT_VARIABLE test_run_output )
|
||||||
|
|
||||||
|
# Did compilation succeed and process return 0 (success)?
|
||||||
|
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
|
||||||
|
set(HAVE_PRAGMA_PACK_HPPA 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check if struct __attribute__((aligned)) is available
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
typedef int cl_aligned_int __attribute__((aligned));
|
||||||
|
"
|
||||||
|
HAVE_ATTRIB_ALIGNED )
|
||||||
|
|
||||||
|
if (NOT (HAVE_ATTRIB_PACKED OR HAVE_PRAGMA_PACK OR HAVE_PRAGMA_PACK_HPPA))
|
||||||
|
message(FATAL_ERROR "Failed to determine how to pack structs with this compiler!")
|
||||||
|
endif()
|
9
cmake/CheckStructPacking_PRAGMA_PACK.c
Normal file
9
cmake/CheckStructPacking_PRAGMA_PACK.c
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
#pragma pack(1) /* has to be in column 1 ! */
|
||||||
|
struct {
|
||||||
|
char c;
|
||||||
|
long l;
|
||||||
|
} s;
|
||||||
|
return sizeof(s) == sizeof(s.c) + sizeof(s.l) ? 0 : 1;
|
||||||
|
}
|
10
cmake/CheckStructPacking_PRAGMA_PACK_HPPA.c
Normal file
10
cmake/CheckStructPacking_PRAGMA_PACK_HPPA.c
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/* hppa/hp-ux wants pragma outside of function */
|
||||||
|
#pragma pack 1 /* has to be in column 1 ! */
|
||||||
|
struct {
|
||||||
|
char c;
|
||||||
|
long l;
|
||||||
|
} s;
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
return sizeof(s) == sizeof(s.c) + sizeof(s.l) ? 0 : 1;
|
||||||
|
}
|
6
cmake/CheckUnamePosix.c
Normal file
6
cmake/CheckUnamePosix.c
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
struct utsname unm;
|
||||||
|
return uname(&unm);
|
||||||
|
}
|
27
cmake/CheckUnamePosix.cmake
Normal file
27
cmake/CheckUnamePosix.cmake
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#
|
||||||
|
# Check for POSIX compliant uname(2) sys call.
|
||||||
|
# This feature reworked from http://www.gnu.org/software/autoconf-archive/ax_check_uname_syscall.html
|
||||||
|
#
|
||||||
|
|
||||||
|
GET_FILENAME_COMPONENT(_selfdir_CheckUnamePosix
|
||||||
|
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
|
# Check that the POSIX compliant uname(2) call works properly (HAVE_UNAME_SYSCALL)
|
||||||
|
try_run(
|
||||||
|
# Name of variable to store the run result (process exit status; number) in:
|
||||||
|
test_run_result
|
||||||
|
# Name of variable to store the compile result (TRUE or FALSE) in:
|
||||||
|
test_compile_result
|
||||||
|
# Binary directory:
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
# Source file to be compiled:
|
||||||
|
${_selfdir_CheckUnamePosix}/CheckUnamePosix.c
|
||||||
|
# Where to store the output produced during compilation:
|
||||||
|
COMPILE_OUTPUT_VARIABLE test_compile_output
|
||||||
|
# Where to store the output produced by running the compiled executable:
|
||||||
|
RUN_OUTPUT_VARIABLE test_run_output )
|
||||||
|
|
||||||
|
# Did compilation succeed and process return 0 (success)?
|
||||||
|
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
|
||||||
|
set(HAVE_UNAME_SYSCALL 1)
|
||||||
|
endif()
|
20
cmake/ColourMessage.cmake
Normal file
20
cmake/ColourMessage.cmake
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# From https://stackoverflow.com/questions/18968979/how-to-get-colorized-output-with-cmake
|
||||||
|
|
||||||
|
string(ASCII 27 Esc)
|
||||||
|
set(e "${Esc}[m") # Colour Reset
|
||||||
|
set(o "${Esc}[1m") # Colour Bold
|
||||||
|
set(r "${Esc}[31m") # Red
|
||||||
|
set(g "${Esc}[32m") # Green
|
||||||
|
set(y "${Esc}[33m") # Yellow
|
||||||
|
set(b "${Esc}[34m") # Blue
|
||||||
|
set(m "${Esc}[35m") # Magenta
|
||||||
|
set(c "${Esc}[36m") # Cyan
|
||||||
|
set(w "${Esc}[37m") # White
|
||||||
|
set(R "${Esc}[1;31m") # Bold Red
|
||||||
|
set(G "${Esc}[1;32m") # Bold Green
|
||||||
|
set(Y "${Esc}[1;33m") # Bold Yellow
|
||||||
|
set(B "${Esc}[1;34m") # Bold Blue
|
||||||
|
set(M "${Esc}[1;35m") # Bold Magenta
|
||||||
|
set(C "${Esc}[1;36m") # Bold Cyan
|
||||||
|
set(W "${Esc}[1;37m") # Bold White
|
||||||
|
set(_ "") # No-op, for alignment purposes
|
31
cmake/ExtractValidFlags.cmake
Normal file
31
cmake/ExtractValidFlags.cmake
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Convenience function that checks the availability of certain
|
||||||
|
# C or C++ compiler flags and returns valid ones as a string.
|
||||||
|
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
|
function(extract_valid_c_flags varname)
|
||||||
|
set(valid_flags)
|
||||||
|
foreach(flag IN LISTS ARGN)
|
||||||
|
string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
|
||||||
|
set(flag_var "C_FLAG_${flag_var}")
|
||||||
|
check_c_compiler_flag("${flag}" "${flag_var}")
|
||||||
|
if(${flag_var})
|
||||||
|
set(valid_flags "${valid_flags} ${flag}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(${varname} "${valid_flags}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(extract_valid_cxx_flags varname)
|
||||||
|
set(valid_flags)
|
||||||
|
foreach(flag IN LISTS ARGN)
|
||||||
|
string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
|
||||||
|
set(flag_var "CXX_FLAG_${flag_var}")
|
||||||
|
check_cxx_compiler_flag("${flag}" "${flag_var}")
|
||||||
|
if(${flag_var})
|
||||||
|
set(valid_flags "${valid_flags} ${flag}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(${varname} "${valid_flags}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
148
cmake/FindCURSES.cmake
Normal file
148
cmake/FindCURSES.cmake
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
FindCURSES
|
||||||
|
-------
|
||||||
|
|
||||||
|
Finds the CURSES library.
|
||||||
|
|
||||||
|
Imported Targets
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This module provides the following imported targets, if found:
|
||||||
|
|
||||||
|
``Curses::curses``
|
||||||
|
The CURSES library
|
||||||
|
|
||||||
|
Result Variables
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This will define the following variables:
|
||||||
|
|
||||||
|
``CURSES_FOUND``
|
||||||
|
True if the system has the CURSES library.
|
||||||
|
``CURSES_VERSION``
|
||||||
|
The version of the CURSES library which was found.
|
||||||
|
``CURSES_INCLUDE_DIRS``
|
||||||
|
Include directories needed to use CURSES.
|
||||||
|
``CURSES_LIBRARIES``
|
||||||
|
Libraries needed to link to CURSES.
|
||||||
|
|
||||||
|
Cache Variables
|
||||||
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
The following cache variables may also be set:
|
||||||
|
|
||||||
|
``CURSES_INCLUDE_DIR``
|
||||||
|
The directory containing ``foo.h``.
|
||||||
|
``CURSES_LIBRARY``
|
||||||
|
The path to the CURSES library.
|
||||||
|
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
# First try for NCurses
|
||||||
|
pkg_check_modules(PC_NCurses QUIET ncurses)
|
||||||
|
|
||||||
|
find_path(NCURSES_INCLUDE_DIR
|
||||||
|
NAMES ncurses.h
|
||||||
|
PATHS ${PC_NCurses_INCLUDE_DIRS} ${CURSES_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
string(FIND ${NCURSES_INCLUDE_DIR} "-NOTFOUND" NCURSES_NOT_FOUND)
|
||||||
|
if(NCURSES_NOT_FOUND EQUAL -1)
|
||||||
|
#
|
||||||
|
# ncurses WAS found!
|
||||||
|
#
|
||||||
|
set(HAVE_LIBNCURSES 1)
|
||||||
|
set(CURSES_INCLUDE "<ncurses.h>")
|
||||||
|
|
||||||
|
find_library(CURSES_LIBRARY
|
||||||
|
NAMES ncurses
|
||||||
|
PATHS ${PC_NCurses_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CURSES_VERSION ${PC_NCurses_VERSION})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(CURSES
|
||||||
|
FOUND_VAR CURSES_FOUND
|
||||||
|
REQUIRED_VARS
|
||||||
|
CURSES_LIBRARY
|
||||||
|
NCURSES_INCLUDE_DIR
|
||||||
|
VERSION_VAR CURSES_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HAVE_LIBNCURSES 1)
|
||||||
|
set(CURSES_INCLUDE "<ncurses.h>")
|
||||||
|
|
||||||
|
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
|
||||||
|
set(CURSES_INCLUDE_DIRS ${NCURSES_INCLUDE_DIR})
|
||||||
|
set(CURSES_DEFINITIONS ${PC_NCurses_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
if (NOT TARGET Curses::curses)
|
||||||
|
add_library(Curses::curses UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(Curses::curses PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${CURSES_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${PC_NCurses_CFLAGS_OTHER}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${CURSES_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Try for PDCurses
|
||||||
|
pkg_check_modules(PC_PDCurses QUIET curses)
|
||||||
|
|
||||||
|
find_path(PDCURSES_INCLUDE_DIR
|
||||||
|
NAMES curses.h
|
||||||
|
PATHS ${PC_PDCurses_INCLUDE_DIRS} ${CURSES_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
string(FIND ${PDCURSES_INCLUDE_DIR} "-NOTFOUND" PDCURSES_NOT_FOUND)
|
||||||
|
if(PDCURSES_NOT_FOUND EQUAL -1)
|
||||||
|
#
|
||||||
|
# pdcurses WAS found!
|
||||||
|
#
|
||||||
|
set(HAVE_LIBPDCURSES 1)
|
||||||
|
set(CURSES_INCLUDE "<curses.h>")
|
||||||
|
|
||||||
|
find_library(CURSES_LIBRARY
|
||||||
|
NAMES curses
|
||||||
|
PATHS ${PC_PDCurses_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CURSES_VERSION ${PC_PDCurses_VERSION})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(CURSES
|
||||||
|
FOUND_VAR CURSES_FOUND
|
||||||
|
REQUIRED_VARS
|
||||||
|
CURSES_LIBRARY
|
||||||
|
PDCURSES_INCLUDE_DIR
|
||||||
|
VERSION_VAR CURSES_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HAVE_LIBPDCURSES 1)
|
||||||
|
set(CURSES_INCLUDE "<curses.h>")
|
||||||
|
|
||||||
|
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
|
||||||
|
set(CURSES_INCLUDE_DIRS ${PDCURSES_INCLUDE_DIR})
|
||||||
|
set(CURSES_DEFINITIONS ${PC_PDCurses_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
if (NOT TARGET Curses::curses)
|
||||||
|
add_library(Curses::curses UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(Curses::curses PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${CURSES_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${PC_PDCurses_CFLAGS_OTHER}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${CURSES_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unable to find ncurses or pdcurses")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
CURSES_INCLUDE_DIR
|
||||||
|
CURSES_LIBRARY
|
||||||
|
)
|
40
cmake/FindCUnit.cmake
Normal file
40
cmake/FindCUnit.cmake
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# - Try to find cunit
|
||||||
|
# Once done this will define
|
||||||
|
# CUNIT_FOUND - System has cunit
|
||||||
|
# CUNIT_INCLUDE_DIRS - The cunit include directories
|
||||||
|
# CUNIT_LIBRARIES - The libraries needed to use cunit
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
pkg_check_modules(PC_CUNIT QUIET cunit)
|
||||||
|
|
||||||
|
find_path(CUNIT_INCLUDE_DIR
|
||||||
|
NAMES CUnit/CUnit.h
|
||||||
|
HINTS ${PC_CUNIT_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
find_library(CUNIT_LIBRARY
|
||||||
|
NAMES cunit
|
||||||
|
HINTS ${PC_CUNIT_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CUNIT_INCLUDE_DIR)
|
||||||
|
set(_version_regex "^#define[ \t]+CU_VERSION[ \t]+\"([^\"]+)\".*")
|
||||||
|
file(STRINGS "${CUNIT_INCLUDE_DIR}/CUnit/CUnit.h"
|
||||||
|
CUNIT_VERSION REGEX "${_version_regex}")
|
||||||
|
string(REGEX REPLACE "${_version_regex}" "\\1"
|
||||||
|
CUNIT_VERSION "${CUNIT_VERSION}")
|
||||||
|
unset(_version_regex)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set CUNIT_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE and the requested version matches.
|
||||||
|
find_package_handle_standard_args(CUnit REQUIRED_VARS
|
||||||
|
CUNIT_LIBRARY CUNIT_INCLUDE_DIR
|
||||||
|
VERSION_VAR CUNIT_VERSION)
|
||||||
|
|
||||||
|
if(CUNIT_FOUND)
|
||||||
|
set(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
|
||||||
|
set(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(CUNIT_INCLUDE_DIR CUNIT_LIBRARY)
|
48
cmake/FindJSONC.cmake
Normal file
48
cmake/FindJSONC.cmake
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# From https://github.com/fastogt/cmake/blob/master/FindJSON-C.cmake
|
||||||
|
# Copyright (c) 2018, FastoGT
|
||||||
|
# License: BSD 3-Clause
|
||||||
|
# Modified by: Micah Snyder
|
||||||
|
|
||||||
|
# JSONC_FOUND - true if library and headers were found
|
||||||
|
# JSONC_INCLUDE_DIRS - include directories
|
||||||
|
# JSONC_LIBRARIES - library directories
|
||||||
|
|
||||||
|
if(JSONC_USE_STATIC)
|
||||||
|
add_library(jsonc STATIC IMPORTED GLOBAL)
|
||||||
|
else()
|
||||||
|
add_library(jsonc SHARED IMPORTED GLOBAL)
|
||||||
|
endif(JSONC_USE_STATIC)
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
PKG_CHECK_MODULES(PC_JSONC QUIET json-c)
|
||||||
|
|
||||||
|
find_path(JSONC_INCLUDE_DIR json.h
|
||||||
|
HINTS ${PC_JSONC_INCLUDEDIR} ${PC_JSONC_INCLUDE_DIRS} PATH_SUFFIXES json-c json)
|
||||||
|
|
||||||
|
if(JSONC_USE_STATIC)
|
||||||
|
find_library(JSONC_LIBRARY NAMES libjson-c.a libjson-c-static.a
|
||||||
|
HINTS ${PC_JSONC_LIBDIR} ${PC_JSONC_LIBRARY_DIRS})
|
||||||
|
else()
|
||||||
|
find_library(JSONC_LIBRARY NAMES json-c libjson-c
|
||||||
|
HINTS ${PC_JSONC_LIBDIR} ${PC_JSONC_LIBRARY_DIRS})
|
||||||
|
endif(JSONC_USE_STATIC)
|
||||||
|
|
||||||
|
set(JSONC_LIBRARIES ${JSONC_LIBRARY})
|
||||||
|
set(JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIR})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(JSONC DEFAULT_MSG JSONC_LIBRARIES JSONC_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
if(JSONC_FOUND AND NOT TARGET JSONC::jsonc)
|
||||||
|
add_library(JSONC::jsonc UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(JSONC::jsonc PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${JSONC_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${PC_JSONC_CFLAGS_OTHER}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${JSONC_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
JSONC_INCLUDE_DIR
|
||||||
|
JSONC_LIBRARY
|
||||||
|
)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue