Skip to content

Commit f939d71

Browse files
authored
Add conf.d-available, set CAP_DAC_READ_SEARCH (#112)
* set CAP_DAC_READ_SEARCH during install Signed-off-by: Justin Kolberg <amd.prophet@gmail.com> * add conf.d-available directory Signed-off-by: Justin Kolberg <amd.prophet@gmail.com> * add missing expected pkg files Signed-off-by: Justin Kolberg <amd.prophet@gmail.com> * move examples to conf.d-available Signed-off-by: Justin Kolberg <amd.prophet@gmail.com> * fix verify_installer.sh Signed-off-by: Justin Kolberg <amd.prophet@gmail.com> --------- Signed-off-by: Justin Kolberg <amd.prophet@gmail.com>
1 parent 1e2db51 commit f939d71

File tree

19 files changed

+61
-12
lines changed

19 files changed

+61
-12
lines changed

assets/productbuild/uninstall.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ collector_files=(
4242
"/Library/LaunchDaemons/com.sumologic.otelcol-sumo.plist"
4343
"/etc/otelcol-sumo/sumologic.yaml"
4444
"/etc/otelcol-sumo/conf.d"
45+
"/etc/otelcol-sumo/conf.d-available"
4546
"/etc/otelcol-sumo"
4647
"/usr/local/bin/otelcol-config"
4748
"/usr/local/bin/otelcol-sumo"
@@ -52,7 +53,7 @@ collector_files=(
5253

5354
# A list of files & directories to remove for hostmetrics
5455
hostmetrics_files=(
55-
"/etc/otelcol-sumo/conf.d/hostmetrics.yaml"
56+
"/etc/otelcol-sumo/conf.d-available/hostmetrics.yaml"
5657
)
5758

5859
function package_is_registered() {

ci/verify_installer.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ expected_collector_files=(
4747
"etc/otelcol-sumo"
4848
"etc/otelcol-sumo/conf.d"
4949
"etc/otelcol-sumo/conf.d/common.yaml"
50-
"etc/otelcol-sumo/conf.d/examples"
50+
"etc/otelcol-sumo/conf.d-available"
51+
"etc/otelcol-sumo/conf.d-available/examples"
5152
"etc/otelcol-sumo/sumologic.yaml"
5253
"Library/Application Support/otelcol-sumo"
5354
"Library/Application Support/otelcol-sumo/uninstall.sh"
@@ -61,7 +62,7 @@ expected_collector_files=(
6162

6263
# a list of files that the hostmetrics package should install
6364
expected_hostmetrics_files=(
64-
"etc/otelcol-sumo/conf.d/hostmetrics.yaml"
65+
"etc/otelcol-sumo/conf.d-available/hostmetrics.yaml"
6566
)
6667

6768
function install_package() {
@@ -229,7 +230,7 @@ for f in "${all_collector_files[@]}"; do
229230
continue
230231
fi
231232

232-
if [[ " $(dirname "${collector_file}") " == " etc/otelcol-sumo/conf.d/examples " ]]; then
233+
if [[ " $(dirname "${collector_file}") " == " etc/otelcol-sumo/conf.d-available/examples " ]]; then
233234
continue
234235
fi
235236

components/otelcol-sumo.cmake

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,31 @@ macro(install_otc_config_fragment_directory)
7979
)
8080
endmacro()
8181

82-
# e.g. /etc/otelcol-sumo/conf.d/examples
82+
# e.g. /etc/otelcol-sumo/conf.d-available
83+
macro(install_otc_config_fragments_available_directory)
84+
require_variables(
85+
"OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR"
86+
)
87+
install(
88+
DIRECTORY
89+
DESTINATION "${OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR}"
90+
DIRECTORY_PERMISSIONS
91+
OWNER_READ OWNER_WRITE OWNER_EXECUTE
92+
GROUP_READ GROUP_WRITE GROUP_EXECUTE
93+
COMPONENT otelcol-sumo
94+
)
95+
endmacro()
96+
97+
# e.g. /etc/otelcol-sumo/conf.d-available/examples
8398
macro(install_otc_config_examples)
8499
require_variables(
85-
"OTC_CONFIG_FRAGMENTS_DIR"
100+
"OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR"
86101
"ASSETS_DIR"
87102
)
88103

89104
install(
90105
DIRECTORY
91-
DESTINATION "${OTC_CONFIG_FRAGMENTS_DIR}/examples"
106+
DESTINATION "${OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR}/examples"
92107
DIRECTORY_PERMISSIONS
93108
OWNER_READ OWNER_WRITE OWNER_EXECUTE
94109
GROUP_READ GROUP_WRITE GROUP_EXECUTE
@@ -100,7 +115,7 @@ macro(install_otc_config_examples)
100115
foreach(example ${examples})
101116
install(
102117
FILES "${example}"
103-
DESTINATION "${OTC_CONFIG_FRAGMENTS_DIR}/examples"
118+
DESTINATION "${OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR}/examples"
104119
PERMISSIONS
105120
OWNER_READ OWNER_WRITE OWNER_EXECUTE
106121
GROUP_READ GROUP_WRITE GROUP_EXECUTE
@@ -282,11 +297,11 @@ endmacro()
282297
macro(install_otc_darwin_hostmetrics_yaml)
283298
require_variables(
284299
"ASSETS_DIR"
285-
"OTC_CONFIG_FRAGMENTS_DIR"
300+
"OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR"
286301
)
287302
install(
288303
FILES "${ASSETS_DIR}/conf.d/darwin.yaml"
289-
DESTINATION "${OTC_CONFIG_FRAGMENTS_DIR}"
304+
DESTINATION "${OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR}"
290305
RENAME "hostmetrics.yaml"
291306
PERMISSIONS
292307
OWNER_READ OWNER_WRITE
@@ -300,11 +315,11 @@ endmacro()
300315
macro(install_otc_linux_hostmetrics_yaml)
301316
require_variables(
302317
"ASSETS_DIR"
303-
"OTC_CONFIG_FRAGMENTS_DIR"
318+
"OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR"
304319
)
305320
install(
306321
FILES "${ASSETS_DIR}/conf.d/linux.yaml"
307-
DESTINATION "${OTC_CONFIG_FRAGMENTS_DIR}"
322+
DESTINATION "${OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR}"
308323
RENAME "hostmetrics.yaml"
309324
PERMISSIONS
310325
OWNER_READ OWNER_WRITE

settings/otc.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ macro(set_otc_settings)
2929
set(OTC_BIN_DIR "usr/local/bin")
3030
set(OTC_CONFIG_DIR "etc/otelcol-sumo")
3131
set(OTC_CONFIG_FRAGMENTS_DIR "${OTC_CONFIG_DIR}/conf.d")
32+
set(OTC_CONFIG_FRAGMENTS_AVAILABLE_DIR "${OTC_CONFIG_DIR}/conf.d-available")
3233
set(OTC_USER_ENV_DIR "${OTC_CONFIG_DIR}/env")
3334
set(OTC_STATE_DIR "var/lib/otelcol-sumo")
3435
set(OTC_FILESTORAGE_STATE_DIR "${OTC_STATE_DIR}/file_storage")
@@ -37,6 +38,7 @@ macro(set_otc_settings)
3738
set(OTC_LOG_DIR "var/log/otelcol-sumo")
3839

3940
# File paths
41+
set(OTC_BIN_PATH "${OTC_BIN_DIR}/${OTC_BINARY}")
4042
set(OTC_SUMOLOGIC_CONFIG_PATH "${OTC_CONFIG_DIR}/${OTC_SUMOLOGIC_CONFIG}")
4143

4244
##

templates/hooks/common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function(render_common_hook_templates)
1515
"OTC_CONFIG_PATH"
1616
"OTC_USER_ENV_DIR"
1717
"OTC_CONFIG_FRAGMENT_DIR"
18+
"OTC_BIN_PATH"
1819
)
1920

2021
set(file_names

templates/hooks/common/darwin-functions.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- mode: sh; -*- vim: ft=sh :
12
# shellcheck disable=SC2148
23

34
# get_uid will print a user's id if found or nothing if not found

templates/hooks/common/linux-functions.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- mode: sh; -*- vim: ft=sh :
12
# shellcheck disable=SC2148
23

34
# user_missing will return 0 if the user exists, non-zero if it does not

templates/hooks/common/otc-darwin-functions.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- mode: sh; -*- vim: ft=sh :
12
# shellcheck disable=SC2148
23
# $0 - path to this script
34
# $1 - path to the package

templates/hooks/common/otc-linux-functions.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- mode: sh; -*- vim: ft=sh :
12
# shellcheck disable=SC2148
23

34
set_file_ownership()
@@ -11,3 +12,15 @@ set_file_ownership()
1112
@OTC_USER_ENV_DIR@ \
1213
@OTC_CONFIG_FRAGMENTS_DIR@
1314
}
15+
16+
set_capabilities()
17+
{
18+
echo -e "Setting the CAP_DAC_READ_SEARCH Linux capability on the " \
19+
"collector binary to allow it to read host metrics from /proc " \
20+
"directory: setcap 'cap_dac_read_search=ep' \"@OTC_BIN_PATH@\""
21+
echo -e "You can remove it with the following command: " \
22+
"sudo setcap -r \"@OTC_BIN_PATH@\""
23+
echo -e "Without this capability, the collector will not be able to " \
24+
"collect some of the host metrics."
25+
setcap 'cap_dac_read_search=ep' "@OTC_BIN_PATH@"
26+
}

templates/hooks/deb/postinst.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/bin/sh
2+
# -*- mode: sh; -*- vim: ft=sh :
23

34
@otc_linux_functions@
45

56
case "$1" in
67
configure)
78
set_file_ownership
9+
set_capabilities
810
;;
911

1012
abort-upgrade|abort-remove|abort-deconfigure)

0 commit comments

Comments
 (0)