File tree Expand file tree Collapse file tree
bosh_go_agent/assets/runit/agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44export PATH=/var/vcap/bosh/bin:$PATH
55exec 2>&1
66
7+ source /var/vcap/bosh/etc/monit-access-helper.sh
8+
9+ permit_monit_access
10+
711cd /var/vcap/bosh
812
913exec nice -n -15 /var/vcap/bosh/bin/bosh-agent -P $( cat /var/vcap/bosh/etc/operating_system) -C /var/vcap/bosh/agent.json
Original file line number Diff line number Diff line change @@ -30,4 +30,12 @@ chmod 0700 $chroot/$bosh_dir/etc/monitrc
3030mkdir -p $chroot /$bosh_app_dir /monit
3131touch $chroot /$bosh_app_dir /monit/empty.monitrc
3232
33- cp $dir /assets/monit-access-helper.sh $chroot /$bosh_dir /etc/
33+ # Monit wrapper script:
34+ mv $chroot /$bosh_dir /bin/monit $chroot /$bosh_dir /bin/monit-actual
35+
36+ cp $dir /assets/monit-access-helper.sh $chroot /$bosh_dir /etc/
37+ cp $dir /assets/monit $chroot /$bosh_dir /bin/monit
38+ chmod +x $chroot /$bosh_dir /bin/monit
39+
40+ cp $dir /assets/restrict-monit-api-access $chroot /etc/network/if-up.d/restrict-monit-api-access
41+ chmod +x $chroot /etc/network/if-up.d/restrict-monit-api-access
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ source /var/vcap/bosh/etc/monit-access-helper.sh
6+
7+ permit_monit_access
8+
9+ exec /var/vcap/bosh/bin/monit-actual " $@ "
Original file line number Diff line number Diff line change 1+ # This is the integer value of the argument "0xb0540001", which is
2+ # b054:0001 . The major number (the left-hand side) is "BOSH", leet-ified.
3+ # The minor number (the right-hand side) is 1, indicating that this is the
4+ # first thing in our "BOSH" classid namespace.
5+ #
6+ # _Hopefully_ noone uses a major number of "b054", and we avoid collisions _forever_!
7+ # If you need to select new classids for firewall rules or traffic control rules, keep
8+ # the major number "b054" for bosh stuff, unless there's a good reason to not.
9+ #
10+ # The net_cls.classid structure is described in more detail here:
11+ # https://www.kernel.org/doc/Documentation/cgroup-v1/net_cls.txt
12+
13+ monit_isolation_classid=2958295041
14+
115permit_monit_access () {
2- /usr/local/sbin/bosh-enable-monit-access
3- }
16+ net_cls_location=" $( cat /proc/self/mounts | grep ^cgroup | grep net_cls | awk ' { print $2 }' ) "
17+ net_cls_subproc=" $( grep net_cls /proc/self/cgroup | awk -F " :" ' { print $3 }' ) "
18+ monit_access_cgroup=" ${net_cls_location} /${net_cls_subproc} /monit-api-access"
19+
20+ mkdir -p " ${monit_access_cgroup} "
21+ echo " ${monit_isolation_classid} " > " ${monit_access_cgroup} /net_cls.classid"
22+
23+ echo $$ > " ${monit_access_cgroup} /tasks"
24+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ source /var/vcap/bosh/etc/monit-access-helper.sh
4+
5+ if iptables -t mangle -C POSTROUTING -d 127.0.0.1 -p tcp --dport 2822 \
6+ -m cgroup \! --cgroup " ${monit_isolation_classid} " -j DROP
7+ then
8+ /bin/true
9+ else
10+ iptables -t mangle -I POSTROUTING -d 127.0.0.1 -p tcp --dport 2822 \
11+ -m cgroup \! --cgroup " ${monit_isolation_classid} " -j DROP
12+ iptables -t mangle -I POSTROUTING -d 127.0.0.1 -p tcp --dport 2822 \
13+ -m state --state ESTABLISHED,RELATED -j ACCEPT
14+ fi
You can’t perform that action at this time.
0 commit comments