fix(ci): verify rootless pid namespace without proc links
Some checks failed
ci / verify (pull_request) Failing after 6m9s
Some checks failed
ci / verify (pull_request) Failing after 6m9s
This commit is contained in:
parent
06f95c5d86
commit
5e8fb4276f
@ -270,11 +270,18 @@ docker exec "$PROBE_CONTAINER" docker info --format '{{range .SecurityOptions}}{
|
|||||||
# Complete every slow and capability-sensitive validation before registration;
|
# Complete every slow and capability-sensitive validation before registration;
|
||||||
# otherwise a queued workflow can race the installer for the same image layers.
|
# otherwise a queued workflow can race the installer for the same image layers.
|
||||||
docker exec "$PROBE_CONTAINER" docker pull "$JOB_IMAGE"
|
docker exec "$PROBE_CONTAINER" docker pull "$JOB_IMAGE"
|
||||||
outer_pidns=$(docker exec "$PROBE_CONTAINER" readlink /proc/1/ns/pid)
|
outer_sentinel_pid=$(docker exec "$PROBE_CONTAINER" /bin/sh -c \
|
||||||
inner_host_pidns=$(docker exec "$PROBE_CONTAINER" docker run --rm --pull=never \
|
'sleep 300 >/dev/null 2>&1 & printf "%s\n" "$!"')
|
||||||
--pid=host --entrypoint readlink "$JOB_IMAGE" /proc/1/ns/pid)
|
case $outer_sentinel_pid in
|
||||||
[ "$outer_pidns" != "$inner_host_pidns" ] || \
|
'' | *[!0-9]*) fail "could not create the outer PID namespace sentinel" ;;
|
||||||
|
esac
|
||||||
|
if ! docker exec "$PROBE_CONTAINER" docker run --rm --pull=never \
|
||||||
|
--pid=host --entrypoint /bin/sh "$JOB_IMAGE" \
|
||||||
|
-ec 'test ! -e "/proc/$1"' sh "$outer_sentinel_pid"; then
|
||||||
|
docker exec "$PROBE_CONTAINER" kill "$outer_sentinel_pid" >/dev/null 2>&1 || true
|
||||||
fail "nested --pid=host can see the outer runner PID namespace"
|
fail "nested --pid=host can see the outer runner PID namespace"
|
||||||
|
fi
|
||||||
|
docker exec "$PROBE_CONTAINER" kill "$outer_sentinel_pid" >/dev/null 2>&1 || true
|
||||||
docker exec "$PROBE_CONTAINER" docker run --rm --pull=never \
|
docker exec "$PROBE_CONTAINER" docker run --rm --pull=never \
|
||||||
--volume "$PREFIX:$PREFIX:ro" \
|
--volume "$PREFIX:$PREFIX:ro" \
|
||||||
--entrypoint /bin/sh "$JOB_IMAGE" -ec '
|
--entrypoint /bin/sh "$JOB_IMAGE" -ec '
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user