Skip building ndsudo when it’s not actually needed. (#18191)
In practice, ndsudo is only actually used by the Go plugin, so we only need to build and install it if we are building and installing the Go plugin. This speeds up the build a tiny bit when the Go plugin is not being built, and removes a non-trivial bit of attack surface from the eventual install as well.
Austin S. Hemmelgarn committed
Jul 18, 2024 at 13:30 UTC
f83b02f91f9f6066966b89f365554102a4908a20
1 file changed
+13
-5
CMakeLists.txt
+13
-5
@@ -210,6 +210,12 @@ if(ENABLE_PLUGIN_GO)
210
find_package(Go "${MIN_GO_VERSION}" REQUIRED)
211
endif()
212
213
+if(ENABLE_PLUGIN_GO)
214
+ set(NEED_NDSUDO TRUE)
215
+else()
216
+ set(NEED_NDSUDO FALSE)
217
+endif()
218
+
219
if(ENABLE_WEBRTC)
220
include(FetchContent)
221
include(NetdataFetchContentExtra)
@@ -1926,13 +1932,15 @@ if(ENABLE_PLUGIN_CUPS)
1932
endif()
1933
endif()
1934
1929
-set(NDSUDO_FILES src/collectors/plugins.d/ndsudo.c)
1935
+if(NEED_NDSUDO)
1936
+ set(NDSUDO_FILES src/collectors/plugins.d/ndsudo.c)
1937
1931
-add_executable(ndsudo ${NDSUDO_FILES})
1938
+ add_executable(ndsudo ${NDSUDO_FILES})
1939
1933
-install(TARGETS ndsudo
1934
- COMPONENT netdata
1935
- DESTINATION usr/libexec/netdata/plugins.d)
1940
+ install(TARGETS ndsudo
1941
+ COMPONENT netdata
1942
+ DESTINATION usr/libexec/netdata/plugins.d)
1943
+endif()
1944
1945
if(ENABLE_PLUGIN_CGROUP_NETWORK)
1946
set(CGROUP_NETWORK_FILES src/collectors/cgroups.plugin/cgroup-network.c)