-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kir Kolyshkin <[email protected]>
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bats | ||
|
||
load helpers | ||
|
||
function setup() { | ||
requires root # for chcon | ||
if ! selinuxenabled; then | ||
skip "requires SELinux enabled and in enforcing mode" | ||
fi | ||
|
||
setup_busybox | ||
|
||
# Use a copy of runc binary with proper selinux label set. | ||
cp "$RUNC" . | ||
export RUNC="$PWD/runc" | ||
chcon -u system_u -r object_r -t container_runtime_exec_t "$RUNC" | ||
|
||
# Label container fs. | ||
chcon -u system_u -r object_r -t container_file_t -R rootfs | ||
|
||
# Save the start date and time for ausearch. | ||
AU_DD="$(date +%x)" | ||
AU_TT="$(date +%H:%M:%S)" | ||
} | ||
|
||
function teardown() { | ||
teardown_bundle | ||
# Show any avc denials. | ||
ausearch -ts "$AU_DD" "$AU_TT" -m avc | ||
} | ||
|
||
# Baseline test, to check that runc works with selinux enabled. | ||
@test "runc run (no selinux label)" { | ||
update_config ' .process.args = ["/bin/true"]' | ||
runc run tst | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
# https://github.com/opencontainers/runc/issues/4057 | ||
@test "runc run (custom selinux label)" { | ||
update_config ' .process.selinuxLabel |= "system_u:system_r:container_t:s0:c4,c5" | ||
| .process.args = ["/bin/true"]' | ||
runc run tst | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "runc run (custom selinux label, RUNC_DMZ=legacy)" { | ||
export RUNC_DMZ=legacy | ||
update_config ' .process.selinuxLabel |= "system_u:system_r:container_t:s0:c4,c5" | ||
| .process.args = ["/bin/true"]' | ||
runc run tst | ||
[ "$status" -eq 0 ] | ||
} |