diff --git a/driver/CMakeLists.txt b/driver/CMakeLists.txt index e78c8af380..5ce41d84fd 100644 --- a/driver/CMakeLists.txt +++ b/driver/CMakeLists.txt @@ -45,6 +45,9 @@ endif() if(NOT DEFINED DRIVER_COMPONENT_NAME) set(DRIVER_COMPONENT_NAME "scap-driver") endif() +if(NOT DEFINED DRIVER_KMOD_COMPONENT_NAME) + set(DRIVER_KMOD_COMPONENT_NAME ${DRIVER_COMPONENT_NAME}) +endif() if(NOT DEFINED DRIVER_PACKAGE_NAME) set(DRIVER_PACKAGE_NAME "scap") @@ -166,7 +169,7 @@ if(ENABLE_DKMS) ${CMAKE_CURRENT_BINARY_DIR}/src/driver_config.h ${DRIVER_SOURCES} DESTINATION "src/${DRIVER_PACKAGE_NAME}-${DRIVER_VERSION}" - COMPONENT ${DRIVER_COMPONENT_NAME}) + COMPONENT ${DRIVER_KMOD_COMPONENT_NAME}) endif() add_subdirectory(bpf) diff --git a/driver/bpf/CMakeLists.txt b/driver/bpf/CMakeLists.txt index f42a1a6c48..db29f10b10 100644 --- a/driver/bpf/CMakeLists.txt +++ b/driver/bpf/CMakeLists.txt @@ -21,13 +21,13 @@ if(BUILD_BPF) endif() add_custom_target(bpf ALL - COMMAND make - COMMAND "${CMAKE_COMMAND}" -E copy_if_different probe.o "${CMAKE_CURRENT_BINARY_DIR}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - VERBATIM) + COMMAND make + COMMAND "${CMAKE_COMMAND}" -E copy_if_different probe.o "${CMAKE_CURRENT_BINARY_DIR}" + WORKING_DIRECTORY src + VERBATIM) endif() -install(FILES +set(BPF_SOURCES bpf_helpers.h builtins.h filler_helpers.h @@ -40,5 +40,27 @@ install(FILES ring_helpers.h missing_definitions.h types.h +) + +# Append driver headers too since they are used by bpf headers +file(GLOB DRIVER_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../*.h) +list(APPEND BPF_SOURCES ${DRIVER_HEADERS}) + +set(INSTALL_SET "") +# Copy all needed sources under src folder in current binary dir +# and add them to the set of installed files +foreach(SOURCE IN LISTS BPF_SOURCES) + get_filename_component(FILENAME ${SOURCE} NAME) + configure_file(${SOURCE} src/${FILENAME} COPYONLY) + list(APPEND INSTALL_SET ${CMAKE_CURRENT_BINARY_DIR}/src/${FILENAME}) +endforeach() + +if(NOT DEFINED DRIVER_BPF_COMPONENT_NAME) + set(DRIVER_BPF_COMPONENT_NAME ${DRIVER_COMPONENT_NAME}) +endif() + +install(FILES + ${INSTALL_SET} DESTINATION "src/${DRIVER_PACKAGE_NAME}-${DRIVER_VERSION}/bpf" - COMPONENT ${DRIVER_COMPONENT_NAME}) + COMPONENT ${DRIVER_BPF_COMPONENT_NAME} +) diff --git a/driver/bpf/filler_helpers.h b/driver/bpf/filler_helpers.h index 838b6d6e52..a2b7115bc8 100644 --- a/driver/bpf/filler_helpers.h +++ b/driver/bpf/filler_helpers.h @@ -19,7 +19,7 @@ or GPL2.txt for full copies of the license. #include #include -#include "../ppm_flag_helpers.h" +#include "ppm_flag_helpers.h" #include "builtins.h" #include "missing_definitions.h" diff --git a/driver/bpf/fillers.h b/driver/bpf/fillers.h index c7d0ec1406..023f2836bd 100644 --- a/driver/bpf/fillers.h +++ b/driver/bpf/fillers.h @@ -10,9 +10,9 @@ or GPL2.txt for full copies of the license. #ifndef __FILLERS_H #define __FILLERS_H -#include "../systype_compat.h" -#include "../ppm_flag_helpers.h" -#include "../ppm_version.h" +#include "systype_compat.h" +#include "ppm_flag_helpers.h" +#include "ppm_version.h" #include "bpf_helpers.h" #include diff --git a/driver/bpf/plumbing_helpers.h b/driver/bpf/plumbing_helpers.h index bbbb9306ab..bddbad65b6 100644 --- a/driver/bpf/plumbing_helpers.h +++ b/driver/bpf/plumbing_helpers.h @@ -16,7 +16,7 @@ or GPL2.txt for full copies of the license. #include "types.h" #include "builtins.h" -#include "../socketcall_to_syscall.h" +#include "socketcall_to_syscall.h" #define _READ(P) ({ typeof(P) _val; \ bpf_probe_read_kernel(&_val, sizeof(_val), &P); \ diff --git a/driver/bpf/probe.c b/driver/bpf/probe.c index ac5596859e..bb1feba3ac 100644 --- a/driver/bpf/probe.c +++ b/driver/bpf/probe.c @@ -16,8 +16,8 @@ or GPL2.txt for full copies of the license. #endif #include -#include "../driver_config.h" -#include "../ppm_events_public.h" +#include "driver_config.h" +#include "ppm_events_public.h" #include "bpf_helpers.h" #include "types.h" #include "maps.h"