Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/sys/mac/portacl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ TAP_TESTS_SH+= nobody_test
TAP_TESTS_SH+= root_test

.for t in ${TAP_TESTS_SH}
TEST_METADATA.$t+= required_kmods="mac_portacl"
TEST_METADATA.$t+= required_user="root"
TEST_METADATA.$t+= timeout="450"
TEST_METADATA.$t+= is_exclusive="true"
Expand Down
12 changes: 2 additions & 10 deletions tests/sys/mac/portacl/misc.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
#!/bin/sh

sysctl security.mac.portacl >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "1..0 # SKIP MAC_PORTACL is unavailable."
exit 0
fi
if [ $(id -u) -ne 0 ]; then
echo "1..0 # SKIP testcases must be run as root"
exit 0
fi

ntest=1

check_bind() {
Expand Down Expand Up @@ -95,6 +85,7 @@ bind_test() {
sysctl security.mac.portacl.rules= >/dev/null
}

portacl_enabled=$(sysctl -n security.mac.portacl.enabled)
reserved_high=$(sysctl -n net.inet.ip.portrange.reservedhigh)
suser_exempt=$(sysctl -n security.mac.portacl.suser_exempt)
port_high=$(sysctl -n security.mac.portacl.port_high)
Expand All @@ -103,4 +94,5 @@ restore_settings() {
sysctl -n net.inet.ip.portrange.reservedhigh=${reserved_high} >/dev/null
sysctl -n security.mac.portacl.suser_exempt=${suser_exempt} >/dev/null
sysctl -n security.mac.portacl.port_high=${port_high} >/dev/null
sysctl -n security.mac.portacl.enabled=${portacl_enabled} >/dev/null
}
1 change: 1 addition & 0 deletions tests/sys/mac/portacl/nobody_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ trap restore_settings EXIT INT TERM

sysctl security.mac.portacl.suser_exempt=1 >/dev/null
sysctl net.inet.ip.portrange.reservedhigh=78 >/dev/null
sysctl security.mac.portacl.enabled=1 >/dev/null

bind_test fl fl uid nobody tcp 77
bind_test ok ok uid nobody tcp 7777
Expand Down
1 change: 1 addition & 0 deletions tests/sys/mac/portacl/root_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ echo "1..48"
trap restore_settings EXIT INT TERM

sysctl security.mac.portacl.suser_exempt=1 >/dev/null
sysctl security.mac.portacl.enabled=1 >/dev/null

bind_test ok ok uid root tcp 77
bind_test ok ok uid root tcp 7777
Expand Down
Loading