2000-08-22 03:31:24 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2009-12-29 20:06:10 +03:00
|
|
|
# $NetBSD: securelevel,v 1.8 2009/12/29 17:06:10 elad Exp $
|
2000-08-22 03:31:24 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: securelevel
|
2008-11-12 15:35:50 +03:00
|
|
|
# REQUIRE: ipnat mountd
|
2002-03-22 07:33:57 +03:00
|
|
|
# BEFORE: DAEMON
|
2000-08-22 03:31:24 +04:00
|
|
|
|
2004-08-13 22:08:03 +04:00
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
2000-08-22 03:31:24 +04:00
|
|
|
|
|
|
|
name="securelevel"
|
|
|
|
start_cmd="securelevel_start"
|
|
|
|
stop_cmd=":"
|
|
|
|
|
|
|
|
securelevel_start()
|
|
|
|
{
|
2002-03-01 20:58:00 +03:00
|
|
|
# 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.
|
2000-08-22 03:31:24 +04:00
|
|
|
#
|
2009-12-29 20:06:10 +03:00
|
|
|
osecurelevel=$(sysctl -n kern.securelevel 2>&-)
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Can't set securelevel. (kern.securelevel sysctl not present.)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2002-03-01 20:58:00 +03:00
|
|
|
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
|
2000-08-22 03:31:24 +04:00
|
|
|
else
|
2002-03-01 20:58:00 +03:00
|
|
|
if [ "$osecurelevel" = 0 ]; then
|
2000-08-22 03:31:24 +04:00
|
|
|
echo -n "Setting securelevel: "
|
|
|
|
sysctl -w kern.securelevel=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|