diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2015-10-13 18:46:11 +0000 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2015-10-13 18:46:11 +0000 |
commit | 353b157d9add14b1b701ab95fbb68aaf24d09a30 (patch) | |
tree | 5cc58315365c45d675f8f4d60e3c83b572afdf71 /etc | |
parent | 3ce05314f317514541aba0136b13e5277aa0a729 (diff) | |
download | FreeBSD-src-353b157d9add14b1b701ab95fbb68aaf24d09a30.zip FreeBSD-src-353b157d9add14b1b701ab95fbb68aaf24d09a30.tar.gz |
MFC r288390:
When stopping ugidfw, it is not enough to just try unloading the module. If
the module is built-in to the kernel then the kldunload will fail. Rather
than do this just check if there are rules and then remove them all.
Relnotes: yes
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/rc.d/ugidfw | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/etc/rc.d/ugidfw b/etc/rc.d/ugidfw index d65d6a3..09171e4 100755 --- a/etc/rc.d/ugidfw +++ b/etc/rc.d/ugidfw @@ -3,6 +3,7 @@ # $FreeBSD$ # PROVIDE: ugidfw +# REQUIRE: FILESYSTEMS # BEFORE: LOGIN # KEYWORD: nojail shutdown @@ -33,9 +34,17 @@ ugidfw_start() ugidfw_stop() { + local rulecount + # Disable the policy # - kldunload mac_bsdextended + # Check for the existence of rules and flush them if needed. + rulecount=$(sysctl -in security.mac.bsdextended.rule_count) + if [ ${rulecount:-0} -gt 0 ]; then + ugidfw list | sed -n '2,$p' | cut -d ' ' -f 1 | sort -r -n | + xargs -n 1 ugidfw remove + echo "MAC bsdextended rules flushed." + fi } load_rc_config $name |