diff --git a/CMakeLists.txt b/CMakeLists.txt index 270bed5..54b67b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) project(cgproxy VERSION 0.13) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result") -set(build_tools OFF) -set(build_test OFF) +option(with_execsnoop "enable program level proxy control feature, need bcc installed" ON) +option(build_tools OFF) +option(build_test OFF) set(basic_permission OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cadd249..72012a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,14 +3,15 @@ find_package(nlohmann_json REQUIRED) include_directories(${PROJECT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +if (with_execsnoop) add_library(execsnoop MODULE execsnoop.cpp common.cpp) target_link_libraries(execsnoop bcc) install(TARGETS execsnoop DESTINATION /usr/lib/cgproxy/ PERMISSIONS ${basic_permission}) +endif() add_executable(main main.cpp common.cpp config.cpp cgroup_attach.cpp socket_client.cpp socket_server.cpp) - target_link_libraries(main PRIVATE nlohmann_json::nlohmann_json Threads::Threads dl) set_target_properties(main PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(main PROPERTIES OUTPUT_NAME cgproxy) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9630987..5419a7b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -4,7 +4,9 @@ include_directories(${PROJECT_SOURCE_DIR}/src) add_executable(cgattach cgattach.cpp ../src/cgroup_attach.cpp ../src/common.cpp) install(TARGETS cgattach DESTINATION /usr/bin PERMISSIONS ${basic_permission}) +if (with_execsnoop) add_executable(execsnoop_exec execsnoop.cpp ../src/common.cpp ../src/execsnoop.cpp) set_target_properties(execsnoop_exec PROPERTIES OUTPUT_NAME execsnoop) target_link_libraries(execsnoop_exec bcc) -install(TARGETS execsnoop_exec DESTINATION /usr/bin PERMISSIONS ${basic_permission}) \ No newline at end of file +install(TARGETS execsnoop_exec DESTINATION /usr/bin PERMISSIONS ${basic_permission}) +endif() \ No newline at end of file