ugidfw revision 150800
1135912Strhodes#!/bin/sh
2135912Strhodes#
3135912Strhodes# $FreeBSD: head/etc/rc.d/ugidfw 150800 2005-10-02 07:03:00Z maxim $
4135912Strhodes
5135912Strhodes# PROVIDE: ugidfw
6135912Strhodes# REQUIRE:
7135912Strhodes# BEFORE: LOGIN
8136502Strhodes# KEYWORD: nojail
9135912Strhodes
10135912Strhodes. /etc/rc.subr
11135912Strhodes
12135912Strhodesname="ugidfw"
13135912Strhodesrcvar="ugidfw_enable"
14135912Strhodesstart_cmd="ugidfw_start"
15135912Strhodesstart_precmd="ugidfw_precmd"
16135912Strhodesstop_cmd="ugidfw_stop"
17135912Strhodes
18144515Strhodesugidfw_load()
19144515Strhodes{
20144515Strhodes	if [ -r "${bsdextended_script}" ]; then
21144515Strhodes		. "${bsdextended_script}"
22144515Strhodes	fi
23144515Strhodes}
24144515Strhodes
25135912Strhodesugidfw_precmd()
26135912Strhodes{
27135912Strhodes	if ! sysctl security.mac.bsdextended
28135912Strhodes          then kldload mac_bsdextended
29135912Strhodes	    if [ "$?" -ne "0" ]
30135912Strhodes	      then warn Unable to load the mac_bsdextended module.
31135912Strhodes	      return 1
32135912Strhodes	else
33135912Strhodes	  return 0
34135912Strhodes	  fi
35135912Strhodes	fi
36135912Strhodes	return 0
37135912Strhodes}
38135912Strhodes
39135912Strhodesugidfw_start()
40135912Strhodes{
41150800Smaxim	[ -z "${bsdextended_script}" ] && bsdextended_script=/etc/rc.bsdextended
42135912Strhodes
43150800Smaxim	if [ -r "${bsdextended_script}" ]; then
44150800Smaxim		ugidfw_load
45150800Smaxim		echo "MAC bsdextended rules loaded."
46150800Smaxim	fi
47135912Strhodes}
48135912Strhodes
49135912Strhodesugidfw_stop()
50135912Strhodes{
51135912Strhodes	# Disable the policy
52135912Strhodes	#
53135912Strhodes	kldunload mac_bsdextended
54135912Strhodes}
55135912Strhodes
56135912Strhodesload_rc_config $name
57135912Strhodesrun_rc_command "$1"
58