diff --git a/libexec/rc/rc.d/jail b/libexec/rc/rc.d/jail index 1d544501e32b..d95af40f459e 100755 --- a/libexec/rc/rc.d/jail +++ b/libexec/rc/rc.d/jail @@ -1,604 +1,604 @@ #!/bin/sh # # $FreeBSD$ # # PROVIDE: jail # REQUIRE: LOGIN FILESYSTEMS # BEFORE: securelevel # KEYWORD: shutdown . /etc/rc.subr name="jail" desc="Manage system jails" rcvar="jail_enable" start_cmd="jail_start" start_postcmd="jail_warn" stop_cmd="jail_stop" config_cmd="jail_config" console_cmd="jail_console" status_cmd="jail_status" extra_commands="config console status" : ${jail_program:=/usr/sbin/jail} : ${jail_consolecmd:=/usr/bin/login -f root} : ${jail_jexec:=/usr/sbin/jexec} : ${jail_jls:=/usr/sbin/jls} need_dad_wait= # extract_var jv name param num defval # Extract value from ${jail_$jv_$name} or ${jail_$name} and # set it to $param. If not defined, $defval is used. # When $num is [0-9]*, ${jail_$jv_$name$num} are looked up and # $param is set by using +=. $num=0 is optional (params may start at 1). # When $num is YN or NY, the value is interpreted as boolean. # When $num is @, the value is interpreted as an array separted by IFS. extract_var() { local i _jv _name _param _num _def _name1 _name2 _jv=$1 _name=$2 _param=$3 _num=$4 _def=$5 case $_num in YN) _name1=jail_${_jv}_${_name} _name2=jail_${_name} eval $_name1=\"\${$_name1:-\${$_name2:-$_def}}\" if checkyesno $_name1; then echo " $_param = 1;" else echo " $_param = 0;" fi ;; NY) _name1=jail_${_jv}_${_name} _name2=jail_${_name} eval $_name1=\"\${$_name1:-\${$_name2:-$_def}}\" if checkyesno $_name1; then echo " $_param = 0;" else echo " $_param = 1;" fi ;; [0-9]*) i=$_num while : ; do _name1=jail_${_jv}_${_name}${i} _name2=jail_${_name}${i} eval _tmpargs=\"\${$_name1:-\${$_name2:-$_def}}\" if [ -n "$_tmpargs" ]; then echo " $_param += \"$_tmpargs\";" elif [ $i != 0 ]; then break; fi i=$(($i + 1)) done ;; @) _name1=jail_${_jv}_${_name} _name2=jail_${_name} eval _tmpargs=\"\${$_name1:-\${$_name2:-$_def}}\" set -- $_tmpargs if [ $# -gt 0 ]; then echo -n " $_param = " while [ $# -gt 1 ]; do echo -n "\"$1\", " shift done echo "\"$1\";" fi ;; *) _name1=jail_${_jv}_${_name} _name2=jail_${_name} eval _tmpargs=\"\${$_name1:-\${$_name2:-$_def}}\" if [ -n "$_tmpargs" ]; then echo " $_param = \"$_tmpargs\";" fi ;; esac } # parse_options _j _jv # Parse options and create a temporary configuration file if necessary. # parse_options() { local _j _jv _p _j=$1 _jv=$2 _confwarn=0 if [ -z "$_j" ]; then warn "parse_options: you must specify a jail" return fi eval _jconf=\"\${jail_${_jv}_conf:-/etc/jail.${_j}.conf}\" eval _rootdir=\"\$jail_${_jv}_rootdir\" eval _jconfdir=\"/etc/jail.conf.d/${_j}.conf\" eval _hostname=\"\$jail_${_jv}_hostname\" if [ -z "$_rootdir" -o \ -z "$_hostname" ]; then if [ -r "$_jconf" ]; then _conf="$_jconf" return 0 elif [ -r "$_jconfdir" ]; then _conf="$_jconfdir" return 0 elif [ -r "$jail_conf" ]; then _conf="$jail_conf" return 0 else warn "Invalid configuration for $_j " \ "(no jail.conf, no hostname, or no path). " \ "Jail $_j was ignored." fi return 1 fi eval _ip=\"\$jail_${_jv}_ip\" if [ -z "$_ip" ] && ! check_kern_features vimage; then warn "no ipaddress specified and no vimage support. " \ "Jail $_j was ignored." return 1 fi _conf=/var/run/jail.${_j}.conf # # To relieve confusion, show a warning message. # : ${jail_confwarn:=YES} checkyesno jail_confwarn && _confwarn=1 if [ -r "$jail_conf" -o -r "$_jconf" ]; then if ! checkyesno jail_parallel_start; then warn "$_conf is created and used for jail $_j." fi fi /usr/bin/install -m 0644 -o root -g wheel /dev/null $_conf || return 1 eval : \${jail_${_jv}_flags:=${jail_flags}} eval _exec=\"\$jail_${_jv}_exec\" eval _exec_start=\"\$jail_${_jv}_exec_start\" eval _exec_stop=\"\$jail_${_jv}_exec_stop\" if [ -n "${_exec}" ]; then # simple/backward-compatible execution _exec_start="${_exec}" _exec_stop="" else # flexible execution if [ -z "${_exec_start}" ]; then _exec_start="/bin/sh /etc/rc" if [ -z "${_exec_stop}" ]; then _exec_stop="/bin/sh /etc/rc.shutdown jail" fi fi fi eval _interface=\"\${jail_${_jv}_interface:-${jail_interface}}\" eval _parameters=\"\${jail_${_jv}_parameters:-${jail_parameters}}\" eval _fstab=\"\${jail_${_jv}_fstab:-${jail_fstab:-/etc/fstab.$_j}}\" ( date +"# Generated by rc.d/jail at %Y-%m-%d %H:%M:%S" echo "$_j {" extract_var $_jv hostname host.hostname - "" extract_var $_jv rootdir path - "" if [ -n "$_ip" ]; then extract_var $_jv interface interface - "" jail_handle_ips_option $_ip $_interface alias=0 while : ; do eval _x=\"\$jail_${_jv}_ip_multi${alias}\" [ -z "$_x" ] && break jail_handle_ips_option $_x $_interface alias=$(($alias + 1)) done case $need_dad_wait in 1) # Sleep to let DAD complete before # starting services. echo " exec.start += \"sleep " \ $(($(${SYSCTL_N} net.inet6.ip6.dad_count) + 1)) \ "\";" ;; esac # These are applicable only to non-vimage jails. extract_var $_jv fib exec.fib - "" extract_var $_jv socket_unixiproute_only \ allow.raw_sockets NY YES else echo " vnet;" extract_var $_jv vnet_interface vnet.interface @ "" fi echo " exec.clean;" echo " exec.system_user = \"root\";" echo " exec.jail_user = \"root\";" extract_var $_jv exec_prestart exec.prestart 0 "" extract_var $_jv exec_poststart exec.poststart 0 "" extract_var $_jv exec_prestop exec.prestop 0 "" extract_var $_jv exec_poststop exec.poststop 0 "" echo " exec.start += \"$_exec_start\";" extract_var $_jv exec_afterstart exec.start 0 "" echo " exec.stop = \"$_exec_stop\";" extract_var $_jv consolelog exec.consolelog - \ /var/log/jail_${_j}_console.log if [ -r $_fstab ]; then echo " mount.fstab = \"$_fstab\";" fi eval : \${jail_${_jv}_devfs_enable:=${jail_devfs_enable:-NO}} if checkyesno jail_${_jv}_devfs_enable; then echo " mount.devfs;" eval _ruleset=\${jail_${_jv}_devfs_ruleset:-${jail_devfs_ruleset}} case $_ruleset in "") ;; [0-9]*) echo " devfs_ruleset = \"$_ruleset\";" ;; devfsrules_jail) # XXX: This is the default value, # Let jail(8) to use the default because # mount(8) only accepts an integer. # This should accept a ruleset name. ;; *) warn "devfs_ruleset must be an integer." ;; esac fi eval : \${jail_${_jv}_fdescfs_enable:=${jail_fdescfs_enable:-NO}} if checkyesno jail_${_jv}_fdescfs_enable; then echo " mount.fdescfs;" fi eval : \${jail_${_jv}_procfs_enable:=${jail_procfs_enable:-NO}} if checkyesno jail_${_jv}_procfs_enable; then echo " mount.procfs;" fi eval : \${jail_${_jv}_mount_enable:=${jail_mount_enable:-NO}} if checkyesno jail_${_jv}_mount_enable; then echo " allow.mount;" fi extract_var $_jv set_hostname_allow allow.set_hostname YN NO extract_var $_jv sysvipc_allow allow.sysvipc YN NO extract_var $_jv enforce_statfs enforce_statfs - 2 extract_var $_jv osreldate osreldate extract_var $_jv osrelease osrelease for _p in $_parameters; do echo " ${_p%\;};" done echo "}" ) >> $_conf return 0 } # jail_extract_address argument iface # The second argument is the string from one of the _ip # or the _multi variables. In case of a comma separated list # only one argument must be passed in at a time. # The function alters the _type, _iface, _addr and _mask variables. # jail_extract_address() { local _i _interface _i=$1 _interface=$2 if [ -z "${_i}" ]; then warn "jail_extract_address: called without input" return fi # Check if we have an interface prefix given and split into # iFace and rest. case "${_i}" in *\|*) # ifN|.. prefix there _iface=${_i%%|*} _r=${_i##*|} ;; *) _iface="" _r=${_i} ;; esac # In case the IP has no interface given, check if we have a global one. _iface=${_iface:-${_interface}} # Set address, cut off any prefix/netmask/prefixlen. _addr=${_r} _addr=${_addr%%[/ ]*} # Theoretically we can return here if interface is not set, # as we only care about the _mask if we call ifconfig. # This is not done because we may want to santize IP addresses # based on _type later, and optionally change the type as well. # Extract the prefix/netmask/prefixlen part by cutting off the address. _mask=${_r} _mask=`expr -- "${_mask}" : "${_addr}\(.*\)"` # Identify type {inet,inet6}. case "${_addr}" in *\.*\.*\.*) _type="inet" ;; *:*) _type="inet6" ;; *) warn "jail_extract_address: type not identified" ;; esac # Handle the special /netmask instead of /prefix or # "netmask xxx" case for legacy IP. # We do NOT support shortend class-full netmasks. if [ "${_type}" = "inet" ]; then case "${_mask}" in /*\.*\.*\.*) _mask=" netmask ${_mask#/}" ;; *) ;; esac # In case _mask is still not set use /32. _mask=${_mask:-/32} elif [ "${_type}" = "inet6" ]; then # In case _mask is not set for IPv6, use /128. _mask=${_mask:-/128} fi } # jail_handle_ips_option input iface # Handle a single argument imput which can be a comma separated # list of addresses (theoretically with an option interface and # prefix/netmask/prefixlen). # jail_handle_ips_option() { local _x _type _i _defif _x=$1 _defif=$2 if [ -z "${_x}" ]; then # No IP given. This can happen for the primary address # of each address family. return fi # Loop, in case we find a comma separated list, we need to handle # each argument on its own. while [ ${#_x} -gt 0 ]; do case "${_x}" in *,*) # Extract the first argument and strip it off the list. _i=`expr -- "${_x}" : '^\([^,]*\)'` _x=`expr -- "${_x}" : "^[^,]*,\(.*\)"` ;; *) _i=${_x} _x="" ;; esac _type="" _addr="" _mask="" _iface="" jail_extract_address $_i $_defif # make sure we got an address. case $_addr in "") continue ;; *) ;; esac # Append address to list of addresses for the jail command. case $_type in inet) echo " ip4.addr += \"${_iface:+${_iface}|}${_addr}${_mask}\";" ;; inet6) echo " ip6.addr += \"${_iface:+${_iface}|}${_addr}${_mask}\";" need_dad_wait=1 ;; esac done } jail_config() { local _j _jv case $1 in _ALL) return ;; esac for _j in $@; do _j=$(echo $_j | tr /. _) _jv=$(echo -n $_j | tr -c '[:alnum:]' _) if parse_options $_j $_jv; then echo "$_j: parameters are in $_conf." fi done } jail_console() { local _j _jv _cmd # One argument that is not _ALL. case $#:$1 in 0:*|1:_ALL) err 3 "Specify a jail name." ;; 1:*) ;; esac _j=$(echo $1 | tr /. _) _jv=$(echo -n $1 | tr -c '[:alnum:]' _) shift case $# in 0) eval _cmd=\${jail_${_jv}_consolecmd:-$jail_consolecmd} ;; *) _cmd=$@ ;; esac $jail_jexec $_j $_cmd } jail_status() { $jail_jls -N } jail_start() { local _j _jv _jid _id _name if [ $# = 0 ]; then return fi - echo -n 'Starting jails:' + startmsg -n 'Starting jails:' case $1 in _ALL) command=$jail_program rc_flags=$jail_flags command_args="-f $jail_conf -c" if ! checkyesno jail_parallel_start; then command_args="$command_args -p1" fi _tmp=`mktemp -t jail` || exit 3 if $command $rc_flags $command_args >> $_tmp 2>&1; then $jail_jls jid name | while read _id _name; do - echo -n " $_name" + startmsg -n " $_name" echo $_id > /var/run/jail_${_name}.id done else cat $_tmp fi rm -f $_tmp - echo '.' + startmsg '.' return ;; esac if checkyesno jail_parallel_start; then # # Start jails in parallel and then check jail id when # jail_parallel_start is YES. # for _j in $@; do _j=$(echo $_j | tr /. _) _jv=$(echo -n $_j | tr -c '[:alnum:]' _) parse_options $_j $_jv || continue eval rc_flags=\${jail_${_jv}_flags:-$jail_flags} eval command=\${jail_${_jv}_program:-$jail_program} command_args="-i -f $_conf -c $_j" ( _tmp=`mktemp -t jail_${_j}` || exit 3 if $command $rc_flags $command_args \ >> $_tmp 2>&1 /var/run/jail_${_j}.id else - echo " cannot start jail " \ + startmsg " cannot start jail " \ "\"${_hostname:-${_j}}\": " cat $_tmp fi rm -f $_tmp ) & done wait else # # Start jails one-by-one when jail_parallel_start is NO. # for _j in $@; do _j=$(echo $_j | tr /. _) _jv=$(echo -n $_j | tr -c '[:alnum:]' _) parse_options $_j $_jv || continue eval rc_flags=\${jail_${_jv}_flags:-$jail_flags} eval command=\${jail_${_jv}_program:-$jail_program} command_args="-i -f $_conf -c $_j" _tmp=`mktemp -t jail` || exit 3 if $command $rc_flags $command_args \ >> $_tmp 2>&1 /var/run/jail_${_j}.id else - echo " cannot start jail " \ + startmsg " cannot start jail " \ "\"${_hostname:-${_j}}\": " cat $_tmp fi rm -f $_tmp done fi - echo '.' + startmsg '.' } jail_stop() { local _j _jv if [ $# = 0 ]; then return fi echo -n 'Stopping jails:' case $1 in _ALL) command=$jail_program rc_flags=$jail_flags command_args="-f $jail_conf -r" if checkyesno jail_reverse_stop; then $jail_jls name | tail -r else $jail_jls name fi | while read _j; do echo -n " $_j" _tmp=`mktemp -t jail` || exit 3 $command $rc_flags $command_args $_j >> $_tmp 2>&1 if $jail_jls -j $_j > /dev/null 2>&1; then cat $_tmp else rm -f /var/run/jail_${_j}.id fi rm -f $_tmp done echo '.' return ;; esac checkyesno jail_reverse_stop && set -- $(reverse_list $@) for _j in $@; do _j=$(echo $_j | tr /. _) _jv=$(echo -n $_j | tr -c '[:alnum:]' _) parse_options $_j $_jv || continue if ! $jail_jls -j $_j > /dev/null 2>&1; then continue fi eval command=\${jail_${_jv}_program:-$jail_program} echo -n " ${_hostname:-${_j}}" _tmp=`mktemp -t jail` || exit 3 $command -q -f $_conf -r $_j >> $_tmp 2>&1 if $jail_jls -j $_j > /dev/null 2>&1; then cat $_tmp else rm -f /var/run/jail_${_j}.id fi rm -f $_tmp done echo '.' } jail_warn() { # To relieve confusion, show a warning message. case $_confwarn in 1) warn "Per-jail configuration via jail_* variables " \ "is obsolete. Please consider migrating to $jail_conf." ;; esac } load_rc_config $name case $# in 1) run_rc_command $@ ${jail_list:-_ALL} ;; *) jail_reverse_stop="no" run_rc_command $@ ;; esac diff --git a/libexec/rc/rc.d/local b/libexec/rc/rc.d/local index ba17a674ae9d..53907ad27011 100755 --- a/libexec/rc/rc.d/local +++ b/libexec/rc/rc.d/local @@ -1,37 +1,37 @@ #!/bin/sh # # $FreeBSD$ # # PROVIDE: local # REQUIRE: DAEMON # BEFORE: LOGIN # KEYWORD: shutdown . /etc/rc.subr name="local" desc="Run /etc/rc.local and /etc/rc.shutdown.local" start_cmd="local_start" stop_cmd="local_stop" local_start() { if [ -f /etc/rc.local ]; then - echo -n 'Starting local daemons:' + startmsg -n 'Starting local daemons:' . /etc/rc.local - echo '.' + startmsg '.' fi } local_stop() { if [ -f /etc/rc.shutdown.local ]; then echo -n 'Shutting down local daemons:' . /etc/rc.shutdown.local echo '.' fi } load_rc_config $name run_rc_command "$1" diff --git a/libexec/rc/rc.d/netif b/libexec/rc/rc.d/netif index 3dbb3e1a9588..bb401a6d5ce4 100755 --- a/libexec/rc/rc.d/netif +++ b/libexec/rc/rc.d/netif @@ -1,272 +1,272 @@ #!/bin/sh # # Copyright (c) 2003 The FreeBSD Project. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE PROJECT ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # $FreeBSD$ # # PROVIDE: netif # REQUIRE: FILESYSTEMS iovctl serial sppp sysctl # REQUIRE: hostid # KEYWORD: nojailvnet . /etc/rc.subr . /etc/network.subr name="netif" desc="Network interface setup" rcvar="${name}_enable" start_cmd="netif_start" stop_cmd="netif_stop" wlanup_cmd="wlan_up" wlandown_cmd="wlan_down" cloneup_cmd="clone_up" clonedown_cmd="clone_down" clear_cmd="doclear" vnetup_cmd="vnet_up" vnetdown_cmd="vnet_down" extra_commands="cloneup clonedown clear vnetup vnetdown" cmdifn= set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces set_rcvar_obsolete ipv6_prefer netif_start() { local _if # Set the list of interfaces to work on. # cmdifn=$* if [ -z "$cmdifn" ]; then # # We're operating as a general network start routine. # # disable SIGINT (Ctrl-c) when running at startup trap : 2 fi # Create IEEE802.11 interface wlan_up $cmdifn # Create cloned interfaces clone_up $cmdifn # Rename interfaces. ifnet_rename $cmdifn # Configure the interface(s). netif_common ifn_start $cmdifn if [ -f /etc/rc.d/ipfilter ] ; then # Resync ipfilter /etc/rc.d/ipfilter quietresync fi if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then /etc/rc.d/bridge start $cmdifn fi if [ -f /etc/rc.d/routing -a -n "$cmdifn" ] ; then for _if in $cmdifn; do /etc/rc.d/routing static any $_if done fi } netif_stop() { _clone_down=1 _wlan_down=1 netif_stop0 $* } doclear() { _clone_down= _wlan_down= netif_stop0 $* } netif_stop0() { local _if # Set the list of interfaces to work on. # cmdifn=$* # Deconfigure the interface(s) netif_common ifn_stop $cmdifn # Destroy wlan interfaces if [ -n "$_wlan_down" ]; then wlan_down $cmdifn fi # Destroy cloned interfaces if [ -n "$_clone_down" ]; then clone_down $cmdifn fi if [ -f /etc/rc.d/routing -a -n "$cmdifn" ] ; then for _if in $cmdifn; do /etc/rc.d/routing stop any $_if done fi } vnet_up() { cmdifn=$* netif_common ifn_vnetup $cmdifn } vnet_down() { cmdifn=$* netif_common ifn_vnetdown $cmdifn } # netif_common routine # Common configuration subroutine for network interfaces. This # routine takes all the preparatory steps needed for configuriing # an interface and then calls $routine. netif_common() { local _cooked_list _tmp_list _fail _func _ok _str _cmdifn _func= if [ -z "$1" ]; then err 1 "netif_common(): No function name specified." else _func="$1" shift fi # Set the scope of the command (all interfaces or just one). # _cooked_list= _tmp_list= _cmdifn=$* if [ -n "$_cmdifn" ]; then # Don't check that the interface(s) exist. We need to run # the down code even when the interface doesn't exist to # kill off wpa_supplicant. # XXXBED: is this really true or does wpa_supplicant die? # if so, we should get rid of the devd entry _cooked_list="$_cmdifn" else _cooked_list="`list_net_interfaces`" fi # Expand epair[0-9] to epair[0-9][ab]. for ifn in $_cooked_list; do case ${ifn#epair} in [0-9]*[ab]) ;; # Skip epair[0-9]*[ab]. [0-9]*) for _str in $_cooked_list; do case $_str in $ifn) _tmp_list="$_tmp_list ${ifn}a ${ifn}b" ;; *) _tmp_list="$_tmp_list ${ifn}" ;; esac done _cooked_list=${_tmp_list# } ;; esac done _dadwait= _fail= _ok= for ifn in ${_cooked_list# }; do # Skip if ifn does not exist. case $_func in ifn_stop) if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then warn "$ifn does not exist. Skipped." _fail="${_fail} ${ifn}" continue fi ;; esac if ${_func} ${ifn} $2; then _ok="${_ok} ${ifn}" if ipv6if ${ifn}; then _dadwait=1 fi else _fail="${_fail} ${ifn}" fi done # inet6 address configuration needs sleep for DAD. case ${_func}:${_dadwait} in ifn_start:1|ifn_vnetup:1|ifn_vnetdown:1) sleep `${SYSCTL_N} net.inet6.ip6.dad_count` sleep 1 ;; esac _str= if [ -n "${_ok}" ]; then case ${_func} in ifn_start) _str='Starting' ;; ifn_stop) _str='Stopping' ;; ifn_vnetup) _str='Moving' ;; ifn_vnetdown) _str='Reclaiming' ;; esac - echo "${_str} Network:${_ok}." + startmsg "${_str} Network:${_ok}." case ${_func} in ifn_vnetup) # Clear _ok not to do "ifconfig $ifn" # because $ifn is no longer in the current vnet. _ok= ;; esac if check_startmsgs; then for ifn in ${_ok}; do /sbin/ifconfig ${ifn} done fi fi debug "The following interfaces were not configured: $_fail" } # Load the old "network" config file also for compatibility. # This is needed for mfsBSD at least. load_rc_config network load_rc_config $name run_rc_command $* diff --git a/libexec/rc/rc.d/ppp b/libexec/rc/rc.d/ppp index 93d0655b296f..8dbff30a7e32 100755 --- a/libexec/rc/rc.d/ppp +++ b/libexec/rc/rc.d/ppp @@ -1,135 +1,135 @@ #!/bin/sh # # $FreeBSD$ # # PROVIDE: ppp # REQUIRE: netif # KEYWORD: nojail . /etc/rc.subr name="ppp" desc="Point to Point Protocol" rcvar="ppp_enable" command="/usr/sbin/${name}" start_cmd="ppp_start" stop_cmd="ppp_stop" start_postcmd="ppp_poststart" ppp_start_profile() { local _ppp_profile _ppp_mode _ppp_nat _ppp_unit local _ppp_profile_cleaned _punct _punct_c _ppp_profile=$1 _ppp_profile_cleaned=$1 _punct=". - / +" for _punct_c in $_punct; do _ppp_profile_cleaned=`ltr ${_ppp_profile_cleaned} ${_punct_c} '_'` done # Check for ppp profile mode override. # eval _ppp_mode=\$ppp_${_ppp_profile_cleaned}_mode if [ -z "$_ppp_mode" ]; then _ppp_mode=$ppp_mode fi # Check for ppp profile nat override. # eval _ppp_nat=\$ppp_${_ppp_profile_cleaned}_nat if [ -z "$_ppp_nat" ]; then _ppp_nat=$ppp_nat fi # Establish ppp mode. # if [ "${_ppp_mode}" != "ddial" -a "${_ppp_mode}" != "direct" \ -a "${_ppp_mode}" != "dedicated" \ -a "${_ppp_mode}" != "background" ]; then _ppp_mode="auto" fi rc_flags="-quiet -${_ppp_mode}" # Switch on NAT mode? # case ${_ppp_nat} in [Yy][Ee][Ss]) rc_flags="$rc_flags -nat" ;; esac # Check for hard wired unit eval _ppp_unit=\$ppp_${_ppp_profile_cleaned}_unit if [ -n "${_ppp_unit}" ]; then _ppp_unit="-unit${_ppp_unit}" fi rc_flags="$rc_flags $_ppp_unit" # Run! # su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}" } ppp_start() { local _ppp_profile _p _ppp_profile=$* if [ -z "${_ppp_profile}" ]; then _ppp_profile=$ppp_profile fi - echo -n "Starting PPP profile:" + startmsg -n "Starting PPP profile:" for _p in $_ppp_profile; do - echo -n " $_p" + startmsg -n " $_p" ppp_start_profile $_p done - echo "." + startmsg "." } ppp_poststart() { # Re-Sync ipfilter and pf so they pick up any new network interfaces # if [ -f /etc/rc.d/ipfilter ]; then /etc/rc.d/ipfilter quietresync fi if [ -f /etc/rc.d/pf ]; then /etc/rc.d/pf quietresync fi } ppp_stop_profile() { local _ppp_profile _ppp_profile=$1 /bin/pkill -f "^${command}.*[[:space:]]${_ppp_profile}\$" || \ echo -n "(not running)" } ppp_stop() { local _ppp_profile _p _ppp_profile=$* if [ -z "${_ppp_profile}" ]; then _ppp_profile=$ppp_profile fi echo -n "Stopping PPP profile:" for _p in $_ppp_profile; do echo -n " $_p" ppp_stop_profile $_p done echo "." } load_rc_config $name run_rc_command $* diff --git a/libexec/rc/rc.d/pppoed b/libexec/rc/rc.d/pppoed index 7e848595e833..c368b32008a1 100755 --- a/libexec/rc/rc.d/pppoed +++ b/libexec/rc/rc.d/pppoed @@ -1,34 +1,34 @@ #!/bin/sh # # $FreeBSD$ # # PROVIDE: pppoed # REQUIRE: NETWORKING # BEFORE: DAEMON # KEYWORD: nojail . /etc/rc.subr name="pppoed" desc="Handle incoming PPP over Ethernet connections" rcvar="pppoed_enable" start_cmd="pppoed_start" # XXX stop_cmd will not be straightforward stop_cmd=":" pppoed_start() { local _opts if [ -n "${pppoed_provider}" ]; then pppoed_flags="${pppoed_flags} -p ${pppoed_provider}" fi - echo 'Starting pppoed' + startmsg 'Starting pppoed' _opts=$-; set -f /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface} set +f; set -${_opts} } load_rc_config $name run_rc_command "$1" diff --git a/libexec/rc/rc.d/rfcomm_pppd_server b/libexec/rc/rc.d/rfcomm_pppd_server index 990a22475b0e..a7035f6e4ea7 100755 --- a/libexec/rc/rc.d/rfcomm_pppd_server +++ b/libexec/rc/rc.d/rfcomm_pppd_server @@ -1,123 +1,123 @@ #!/bin/sh # # $FreeBSD$ # # PROVIDE: rfcomm_pppd_server # REQUIRE: DAEMON sdpd # BEFORE: LOGIN # KEYWORD: nojail . /etc/rc.subr name="rfcomm_pppd_server" desc="RFCOMM PPP daemon" rcvar="rfcomm_pppd_server_enable" command="/usr/sbin/rfcomm_pppd" start_cmd="rfcomm_pppd_server_start" stop_cmd="rfcomm_pppd_server_stop" required_modules="ng_btsocket" rfcomm_pppd_server_start_profile() { local _profile _profile_cleaned _punct _punct_c local _bdaddr _channel _x _profile=$1 _profile_cleaned=$1 _punct=". - / +" for _punct_c in ${_punct} ; do _profile_cleaned=`ltr ${_profile_cleaned} ${_punct_c} '_'` done rc_flags="" # Check for RFCOMM PPP profile bdaddr override # eval _bdaddr=\$rfcomm_pppd_server_${_profile_cleaned}_bdaddr if [ -n "${_bdaddr}" ]; then rc_flags="${rc_flags} -a ${_bdaddr}" fi # Check for RFCOMM PPP profile channel override # eval _channel=\$rfcomm_pppd_server_${_profile_cleaned}_channel if [ -z "${_channel}" ]; then _channel=1 fi rc_flags="${rc_flags} -C ${_channel}" # Check for RFCOMM PPP profile register SP override # eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_sp if [ -n "${_x}" ]; then if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_sp" ; then rc_flags="${rc_flags} -S" fi fi # Check for RFCOMM PPP profile register DUN override # eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_dun if [ -n "${_x}" ]; then if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_dun" ; then rc_flags="${rc_flags} -D" fi fi # Run! # $command -s ${rc_flags} -l ${_profile} } rfcomm_pppd_server_stop_profile() { local _profile _profile=$1 /bin/pkill -f "^${command}.*[[:space:]]${_profile}\$" || \ echo -n "(not running)" } rfcomm_pppd_server_start() { local _profile _p _profile=$* if [ -z "${_profile}" ]; then _profile=${rfcomm_pppd_server_profile} fi - echo -n "Starting RFCOMM PPP profile:" + startmsg -n "Starting RFCOMM PPP profile:" for _p in ${_profile} ; do - echo -n " ${_p}" + startmsg -n " ${_p}" rfcomm_pppd_server_start_profile ${_p} done - echo "." + startmsg "." } rfcomm_pppd_server_stop() { local _profile _p _profile=$* if [ -z "${_profile}" ]; then _profile=${rfcomm_pppd_server_profile} fi echo -n "Stopping RFCOMM PPP profile:" for _p in ${_profile} ; do echo -n " ${_p}" rfcomm_pppd_server_stop_profile ${_p} done echo "." } load_rc_config $name run_rc_command $*