Skip to content

Commit 720d3a3

Browse files
authored
Revert "Harden monit-access-helper.sh cgroupv2 mount point detection"
1 parent d1790e3 commit 720d3a3

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

stemcell_builder/stages/bosh_monit/assets/monit-access-helper.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@ monit_isolation_classid=2958295041
1919
#
2020
# Prefer cgroup.controllers; also accept stat(2) filesystem type for hosts where
2121
# the file is missing from the mount view but the root is still cgroup2fs.
22-
system_using_unified_cgroup_v2() {
22+
monit_using_unified_cgroup_v2() {
2323
[ -f /sys/fs/cgroup/cgroup.controllers ] && return 0
2424
[ "$(stat -fc %T /sys/fs/cgroup 2>/dev/null)" = "cgroup2fs" ]
2525
}
2626

2727
permit_monit_access() {
28-
if system_using_unified_cgroup_v2; then
28+
if monit_using_unified_cgroup_v2; then
2929
# cgroupv2 (unified hierarchy)
3030
# Create a sub-cgroup under the current process's cgroup and move into it.
3131
# The iptables rules match on this cgroup path.
32-
cgroup_mount="$(awk '$1 == "cgroup2" && $3 == "cgroup2" { print $2 }' /proc/self/mounts)"
33-
nb_matching_cgroup_mounts=$(echo "$cgroup_mount" | grep -c '^.')
32+
cgroup_mount="$(awk '$3 == "cgroup2" { print $2 }' /proc/self/mounts)"
3433
current_cgroup="$(grep '^0::' /proc/self/cgroup | cut -d: -f3)"
35-
if [ "${nb_matching_cgroup_mounts}" -ne 1 ] || [ -z "${current_cgroup}" ]; then
36-
echo "permit_monit_access: unable to resolve cgroup v2 mount or path. current_cgroup=${current_cgroup} cgroup_mount=${cgroup_mount} nb_matching_cgroup_mounts=${nb_matching_cgroup_mounts}" >&2
34+
if [ -z "${cgroup_mount}" ] || [ -z "${current_cgroup}" ]; then
35+
echo "permit_monit_access: unable to resolve cgroup v2 mount or path" >&2
3736
return 1
3837
fi
3938
monit_access_cgroup="${cgroup_mount}${current_cgroup}/monit-api-access"

0 commit comments

Comments
 (0)