mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
f99f0ee14e
This gives more permissions to services (e.g. network access to services which require this) when they are started as an automatic service jail. The sshd patch is important for the sshd-related functionality as described in the man-page in the service jails part. The location of the added env vars is supposed to allow overriding them in rc.conf, and to hard-disable the use of svcj for some parts where it doesn't make sense or will not work. Only a subset of all of the services are fully tested (I'm running this since more than a year with various services started as service jails). The untested parts should be most of the time ok, in some edge-cases more permissions are needed inside the service jail. Differential Revision: https://reviews.freebsd.org/D40371
127 lines
2.4 KiB
Bash
Executable File
127 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
#
|
|
|
|
# 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
|
|
|
|
startmsg -n "Starting RFCOMM PPP profile:"
|
|
|
|
for _p in ${_profile} ; do
|
|
startmsg -n " ${_p}"
|
|
rfcomm_pppd_server_start_profile ${_p}
|
|
done
|
|
|
|
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
|
|
|
|
# doesn't make sense to run in a svcj: nojail keyword
|
|
rfcomm_pppd_server_svcj="NO"
|
|
|
|
run_rc_command $*
|