Skip to content

Commit 34a9285

Browse files
committed
test join other container userns with selinux enabled
Signed-off-by: lifubang <[email protected]>
1 parent c78f3f2 commit 34a9285

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/integration/userns.bats

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,26 @@ function teardown() {
125125
fi
126126
}
127127

128+
# issue: https://github.com/opencontainers/runc/issues/4466
129+
@test "userns join other container userns[selinux enabled]" {
130+
if ! selinuxenabled; then
131+
skip "requires SELinux enabled and in enforcing mode"
132+
fi
133+
# Create a detached container with the id-mapping we want.
134+
update_config '.process.args = ["sleep", "infinity"]'
135+
runc run -d --console-socket "$CONSOLE_SOCKET" target_userns
136+
[ "$status" -eq 0 ]
137+
138+
# Configure our container to attach to the first container's userns.
139+
target_pid="$(__runc state target_userns | jq .pid)"
140+
update_config '.linux.namespaces |= map(if .type == "user" then (.path = "/proc/'"$target_pid"'/ns/" + .type) else . end)
141+
| del(.linux.uidMappings)
142+
| del(.linux.gidMappings)
143+
| .linux.mountLabel="system_u:object_r:container_file_t:s0:c344,c805"'
144+
runc run -d --console-socket "$CONSOLE_SOCKET" in_userns
145+
[ "$status" -eq 0 ]
146+
}
147+
128148
@test "userns join other container userns [bind-mounted nsfd]" {
129149
requires root
130150

0 commit comments

Comments
 (0)