2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $NetBSD: securelevel,v 1.4 2002/03/22 04:34:00 thorpej Exp $
|
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: securelevel
|
|
|
|
# REQUIRE: aftermountlkm ipnat mountd
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: DAEMON
|
|
|
|
# KEYWORD: FreeBSD NetBSD
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="securelevel"
|
|
|
|
start_cmd="securelevel_start"
|
|
|
|
stop_cmd=":"
|
|
|
|
|
|
|
|
securelevel_start()
|
|
|
|
{
|
2002-06-13 22:14:37 +00:00
|
|
|
case `${CMD_OSTYPE}` in
|
|
|
|
FreeBSD)
|
|
|
|
case ${kern_securelevel_enable} in
|
|
|
|
[Yy][Ee][Ss])
|
|
|
|
if [ ${kern_securelevel} -ge 0 ]; then
|
|
|
|
echo 'Raising kernel security level: '
|
|
|
|
${SYSCTL_W} kern.securelevel=${kern_securelevel}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
NetBSD)
|
|
|
|
# if $securelevel is set higher, change it here, else if
|
|
|
|
# it is 0, change it to 1 here, before we start daemons
|
|
|
|
# or login services.
|
|
|
|
#
|
|
|
|
osecurelevel=`sysctl -n kern.securelevel`
|
|
|
|
if [ -n "$securelevel" -a "$securelevel" != "$osecurelevel" ]; then
|
|
|
|
if [ "$securelevel" -lt "$osecurelevel" ]; then
|
|
|
|
echo "Can't lower securelevel."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo -n "Setting securelevel: "
|
|
|
|
${SYSCTL_W} kern.securelevel=$securelevel
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "$osecurelevel" = 0 ]; then
|
|
|
|
echo -n "Setting securelevel: "
|
|
|
|
${SYSCTL_W} kern.securelevel=1
|
|
|
|
fi
|
2001-06-16 07:16:14 +00:00
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
;;
|
|
|
|
esac
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|