Skip to content

Commit 655290b

Browse files
committed
Don't hardcode paths
1 parent 8c2072f commit 655290b

10 files changed

+20
-14
lines changed

CMakeLists.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ if (build_test)
2727
add_subdirectory(test)
2828
endif()
2929

30+
configure_file(cgnoproxy.cmake cgnoproxy)
31+
configure_file(cgproxyd.cmake cgproxyd)
32+
configure_file(cgproxy.service.cmake cgproxy.service)
33+
3034
# instal scripts and other things
31-
install(PROGRAMS cgproxyd TYPE BIN)
32-
install(PROGRAMS cgnoproxy TYPE BIN)
35+
install(PROGRAMS ${CMAKE_BINARY_DIR}/cgproxyd TYPE BIN)
36+
install(PROGRAMS ${CMAKE_BINARY_DIR}/cgnoproxy TYPE BIN)
3337
install(PROGRAMS cgroup-tproxy.sh DESTINATION ${CMAKE_INSTALL_DATADIR}/cgproxy/scripts)
34-
install(FILES cgproxy.service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system)
38+
install(FILES ${CMAKE_BINARY_DIR}/cgproxy.service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system)
3539
install(FILES config.json DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/cgproxy)
3640
install(FILES readme.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
3741

cgnoproxy

-2
This file was deleted.

cgnoproxy.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec @CMAKE_INSTALL_FULL_BINDIR@/cgproxy --noproxy $@

cgproxy.service cgproxy.service.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ After=network.target
44

55
[Service]
66
Type=simple
7-
ExecStart=/usr/bin/cgproxyd --execsnoop
7+
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/cgproxyd --execsnoop
88

99
[Install]
1010
WantedBy=multi-user.target

cgproxyd

-2
This file was deleted.

cgproxyd.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec @CMAKE_INSTALL_FULL_BINDIR@/cgproxy --daemon $@

execsnoop-bcc/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
33

44
add_library(execsnoop MODULE execsnoop.cpp ../src/common.cpp)
55
target_link_libraries(execsnoop bcc)
6-
install(TARGETS execsnoop DESTINATION /usr/lib/cgproxy/ PERMISSIONS ${basic_permission})
6+
install(TARGETS execsnoop DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cgproxy/ PERMISSIONS ${basic_permission})

src/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ find_package(nlohmann_json REQUIRED)
22
include_directories(${PROJECT_SOURCE_DIR})
33
include_directories(${PROJECT_SOURCE_DIR}/execsnoop-kernel/)
44
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
5+
include_directories(${CMAKE_CURRENT_BINARY_DIR})
56

7+
configure_file(common.h.cmake common.h)
68

79
if (build_execsnoop_dl)
810
add_definitions(-DBUIlD_EXECSNOOP_DL)

src/common.h src/common.h.cmake

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
#include <vector>
88
using namespace std;
99

10-
#define TPROXY_IPTABLS_START "/usr/share/cgproxy/scripts/cgroup-tproxy.sh"
11-
#define TPROXY_IPTABLS_CLEAN "/usr/share/cgproxy/scripts/cgroup-tproxy.sh stop"
10+
#define TPROXY_IPTABLS_START "@CMAKE_INSTALL_FULL_DATADIR@/cgproxy/scripts/cgroup-tproxy.sh"
11+
#define TPROXY_IPTABLS_CLEAN "@CMAKE_INSTALL_FULL_DATADIR@/cgproxy/scripts/cgroup-tproxy.sh stop"
1212

13-
#define LIBEXECSNOOP_SO "/usr/lib/cgproxy/libexecsnoop.so"
13+
#define LIBEXECSNOOP_SO "@CMAKE_INSTALL_FULL_LIBDIR@/cgproxy/libexecsnoop.so"
1414
#define CGROUP2_MOUNT_POINT "/var/run/cgproxy/cgroup2"
1515
#define PID_LOCK_FILE "/var/run/cgproxyd.pid"
1616
#define SOCKET_PATH "/tmp/cgproxy_unix_socket"
1717
#define LISTEN_BACKLOG 64
18-
#define DEFAULT_CONFIG_FILE "/etc/cgproxy/config.json"
18+
#define DEFAULT_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/cgproxy/config.json"
1919
#define READ_SIZE_MAX 128
2020

2121
#define CGROUP_PROXY_PRESVERED "/proxy.slice"

tools/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ include_directories(${PROJECT_SOURCE_DIR})
22
include_directories(${PROJECT_SOURCE_DIR}/src)
33

44
add_executable(cgattach cgattach.cpp ../src/cgroup_attach.cpp ../src/common.cpp)
5-
install(TARGETS cgattach DESTINATION /usr/bin PERMISSIONS ${basic_permission})
5+
install(TARGETS cgattach DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} PERMISSIONS ${basic_permission})

0 commit comments

Comments
 (0)