1#!/bin/sh 2#
| 1#!/bin/sh 2#
|
3# $NetBSD: securelevel,v 1.1 2000/08/21 23:31:24 lukem Exp $
| 3# $NetBSD: securelevel,v 1.4 2002/03/22 04:34:00 thorpej Exp $ 4# $FreeBSD: head/etc/rc.d/securelevel 98184 2002-06-13 22:14:37Z gordon $
|
4# 5 6# PROVIDE: securelevel 7# REQUIRE: aftermountlkm ipnat mountd
| 5# 6 7# PROVIDE: securelevel 8# REQUIRE: aftermountlkm ipnat mountd
|
| 9# BEFORE: DAEMON 10# KEYWORD: FreeBSD NetBSD
|
8 9. /etc/rc.subr 10 11name="securelevel" 12start_cmd="securelevel_start" 13stop_cmd=":" 14 15securelevel_start() 16{
| 11 12. /etc/rc.subr 13 14name="securelevel" 15start_cmd="securelevel_start" 16stop_cmd=":" 17 18securelevel_start() 19{
|
17 # if $securelevel is set, change it here, else if it is 0, 18 # change it to 1 here, before we start daemons or login services. 19 # 20 if [ -n "$securelevel" ]; then 21 echo -n "Setting securelevel: " 22 sysctl kern.securelevel=$securelevel 23 else 24 securelevel=`sysctl -n kern.securelevel` 25 if [ x"$securelevel" = x0 ]; then 26 echo -n "Setting securelevel: " 27 sysctl kern.securelevel=1
| 20 case `${CMD_OSTYPE}` in 21 FreeBSD) 22 case ${kern_securelevel_enable} in 23 [Yy][Ee][Ss]) 24 if [ ${kern_securelevel} -ge 0 ]; then 25 echo 'Raising kernel security level: ' 26 ${SYSCTL_W} kern.securelevel=${kern_securelevel} 27 fi 28 ;; 29 esac 30 ;; 31 NetBSD) 32 # if $securelevel is set higher, change it here, else if 33 # it is 0, change it to 1 here, before we start daemons 34 # or login services. 35 # 36 osecurelevel=`sysctl -n kern.securelevel` 37 if [ -n "$securelevel" -a "$securelevel" != "$osecurelevel" ]; then 38 if [ "$securelevel" -lt "$osecurelevel" ]; then 39 echo "Can't lower securelevel." 40 exit 1 41 else 42 echo -n "Setting securelevel: " 43 ${SYSCTL_W} kern.securelevel=$securelevel 44 fi 45 else 46 if [ "$osecurelevel" = 0 ]; then 47 echo -n "Setting securelevel: " 48 ${SYSCTL_W} kern.securelevel=1 49 fi
|
28 fi
| 50 fi
|
29 fi
| 51 ;; 52 esac
|
30} 31 32load_rc_config $name 33run_rc_command "$1"
| 53} 54 55load_rc_config $name 56run_rc_command "$1"
|