@@ -9,11 +9,6 @@ if [ "$(uname -s)" != "Linux" ]; then
99 exit 1
1010fi
1111
12- if ! command -v unshare > /dev/null 2>&1 ; then
13- echo " ACME mount-boundary smoke requires util-linux unshare" >&2
14- exit 1
15- fi
16-
1712test_name=acme_directory::tests::owned_directory_reconciliation_rejects_bind_mount
1813build_output=$( cargo test --locked -p fluxheim-acme --features acme-client \
1914 --no-run --message-format=json)
@@ -25,8 +20,83 @@ if [ -z "$test_binary" ] || [ ! -x "$test_binary" ]; then
2520 exit 1
2621fi
2722
28- unshare --user --map-root-user --mount --propagation private --fork \
29- " $test_binary " \
30- --exact " $test_name " --ignored --nocapture
23+ run_in_user_namespace () {
24+ unshare --user --map-root-user --mount --propagation private --fork \
25+ " $test_binary " \
26+ --exact " $test_name " --ignored --nocapture
27+ }
28+
29+ run_in_constrained_container () {
30+ runtime=${FLUXHEIM_ACME_MOUNT_TEST_RUNTIME:- }
31+ if [ -z " $runtime " ]; then
32+ if command -v podman > /dev/null 2>&1 ; then
33+ runtime=podman
34+ elif command -v docker > /dev/null 2>&1 ; then
35+ runtime=docker
36+ else
37+ echo " ACME mount-boundary smoke requires user namespaces, Podman, or Docker" >&2
38+ exit 1
39+ fi
40+ fi
41+ case " $runtime " in
42+ podman | docker) ;;
43+ * )
44+ echo " unsupported ACME mount-boundary container runtime: $runtime " >&2
45+ exit 1
46+ ;;
47+ esac
48+
49+ image=${FLUXHEIM_ACME_MOUNT_TEST_IMAGE:- docker.io/ library/ debian: 13.3-slim@ sha256: 1d3c811171a08a5adaa4a163fbafd96b61b87aa871bbc7aa15431ac275d3d430}
50+ apparmor_option=
51+ if [ " $runtime " = docker ]; then
52+ # docker-default denies mount(2) independently of CAP_SYS_ADMIN.
53+ apparmor_option=--security-opt=apparmor=unconfined
54+ fi
55+ # apparmor_option is either empty or one fixed argument selected above.
56+ # shellcheck disable=SC2086
57+ " $runtime " run --rm \
58+ --network none \
59+ --read-only \
60+ --cap-drop ALL \
61+ --cap-add SYS_ADMIN \
62+ --security-opt no-new-privileges \
63+ $apparmor_option \
64+ --pids-limit 64 \
65+ --tmpfs /tmp:rw,nosuid,nodev,noexec,size=64m \
66+ --user 0:0 \
67+ --workdir /tmp \
68+ --entrypoint /fluxheim-acme-test \
69+ -v " $test_binary :/fluxheim-acme-test:ro,Z" \
70+ " $image " \
71+ --exact " $test_name " --ignored --nocapture
72+ }
73+
74+ mode=${FLUXHEIM_ACME_MOUNT_TEST_MODE:- auto}
75+ case " $mode " in
76+ auto)
77+ if command -v unshare > /dev/null 2>&1 \
78+ && unshare --user --map-root-user --mount --propagation private --fork true \
79+ > /dev/null 2>&1 ; then
80+ run_in_user_namespace
81+ else
82+ echo " ACME mount-boundary smoke: user namespaces unavailable; using constrained container" >&2
83+ run_in_constrained_container
84+ fi
85+ ;;
86+ userns)
87+ if ! command -v unshare > /dev/null 2>&1 ; then
88+ echo " ACME mount-boundary smoke requires util-linux unshare in userns mode" >&2
89+ exit 1
90+ fi
91+ run_in_user_namespace
92+ ;;
93+ container)
94+ run_in_constrained_container
95+ ;;
96+ * )
97+ echo " unsupported ACME mount-boundary smoke mode: $mode " >&2
98+ exit 1
99+ ;;
100+ esac
31101
32102echo " ACME mount-boundary smoke passed"
0 commit comments