返回 CodeWhale
prepare-linux-test-sandbox.sh
根目录 / scripts / ci / prepare-linux-test-sandbox.sh
1 #!/bin/sh
2 # CI-only admission for Ubuntu's restricted unprivileged user namespaces.
3 # Use the distro profile: bwrap can construct its namespaces, while its
4 # children enter unpriv_bwrap with capabilities denied. Global policy stays on.
5 set -eu
6
7 profile=/usr/share/apparmor/extra-profiles/bwrap-userns-restrict
8 installed=/etc/apparmor.d/bwrap-userns-restrict
9 if [ -r "$profile" ]; then
10 sudo install -m 0644 "$profile" "$installed"
11 fi
12 test -r "$installed"
13 sudo apparmor_parser -r "$installed"
14
15 # Match the product's isolated namespace/no-network setup before compiling.
16 # A denied setup is a provisioning failure, never a skipped safety test.
17 env -i /usr/bin/bwrap --unshare-all --die-with-parent \
18 --ro-bind / / --dev /dev --proc /proc --tmpfs /tmp -- /usr/bin/true
19
19 lines BASH