File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5555! tools /mkroot
5656! tools /omegajail-setup
5757! tools /omegajail-container-wrapper
58+ ! tools /omegajail-cgroups-wrapper
5859! policies /* .policy
5960! policies /* .frequency
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ COPY ./cxxopts/include/ ./cxxopts/include/
1919COPY ./minijail/ ./minijail/
2020COPY Makefile *.h *.cpp ./
2121COPY tools/omegajail-setup ./tools/
22+ COPY tools/omegajail-cgroups-wrapper ./tools/
2223COPY ./policies/*.policy ./policies/*.frequency ./policies/
2324
2425ARG OMEGAJAIL_RELEASE
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ policies/%.bpf: policies/%.policy policies/omegajail.policy | minijail/constants
7070install : ${BINARIES} tools/omegajail-setup ${POLICIES}
7171 install -d $(DESTDIR ) /bin
7272 install -t $(DESTDIR ) /bin ${BINARIES} tools/omegajail-setup
73+ install -t $(DESTDIR ) /bin ${BINARIES} tools/omegajail-cgroups-wrapper
7374 install -d $(DESTDIR ) /policies
7475 install -t $(DESTDIR ) /policies -m 0644 ${POLICIES}
7576
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Wraps the original omegaup runner binary to set its cgroups up.
4+
5+ set -e
6+
7+ if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then
8+ mkdir -p " /sys/fs/cgroup/system.slice/omegaup-runner.service" /{omegaup-runner,omegajail}
9+
10+ # Move the process to another group to avoid violating the "no processes in
11+ # intermediate nodes" rule.
12+ echo $$ > " /sys/fs/cgroup/system.slice/omegaup-runner.service/omegaup-runner/cgroup.procs"
13+ # Delegate the memory subtree control for both the OG cgroup and the one where
14+ # all the omegajail processes will live in.
15+ echo ' +memory' > " /sys/fs/cgroup/system.slice/omegaup-runner.service/cgroup.subtree_control"
16+ echo ' +memory' > " /sys/fs/cgroup/system.slice/omegaup-runner.service/omegajail/cgroup.subtree_control"
17+ else
18+ mkdir -p " /sys/fs/cgroup/memory/system.slice/omegaup-runner.service" /{omegaup-runner,omegajail}
19+
20+ # Move the process to another group to avoid violating the "no processes in
21+ # intermediate nodes" rule.
22+ echo $$ > " /sys/fs/cgroup/memory/system.slice/omegaup-runner.service/omegaup-runner/cgroup.procs"
23+ fi
24+
25+ # Now that all the cgroups are set, let's start the process.
26+ exec " $@ "
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- # Performs per-boot setup of the environment needed for omegajail.
3+ # Performs setup of the omegaup cgroups needed for omegajail.
44# Should be run as root.
55
66set -e
77
8- # Create a memory cgroup and make omegaup an admin.
9- /bin/mkdir -p -m 0775 /sys/fs/cgroup/memory/omegajail
10- /bin/chgrp omegaup /sys/fs/cgroup/memory/omegajail
8+ # Make omegup the admin of the delegated memory cgroup.
9+ if [[ ! -f /sys/fs/cgroup/cgroup.controllers ]]; then
10+ chown omegaup:omegaup -R /sys/fs/cgroup/memory/system.slice/omegaup-runner.service
11+ fi
You can’t perform that action at this time.
0 commit comments