Changeset View
Changeset View
Standalone View
Standalone View
head/security/tor/files/tor.in
Show All 15 Lines | |||||
# Default: %%PREFIX%%/etc/tor/torrc | # Default: %%PREFIX%%/etc/tor/torrc | ||||
# tor_user (str): Tor daemon user. Default: %%USER%% | # tor_user (str): Tor daemon user. Default: %%USER%% | ||||
# tor_group (str): Tor group. Default: %%GROUP%% | # tor_group (str): Tor group. Default: %%GROUP%% | ||||
# tor_pidfile (str): Tor pid file. Default: /var/run/tor/tor.pid | # tor_pidfile (str): Tor pid file. Default: /var/run/tor/tor.pid | ||||
# tor_datadir (str): Tor datadir. Default: /var/db/tor | # tor_datadir (str): Tor datadir. Default: /var/db/tor | ||||
# tor_disable_default_instance (str): Doesn't run the default instance. | # tor_disable_default_instance (str): Doesn't run the default instance. | ||||
# Only valid when tor_instances is used. | # Only valid when tor_instances is used. | ||||
# Default: NO | # Default: NO | ||||
# tor_setuid (str): Runtime setuid. Default: NO | |||||
# | # | ||||
# The instance definition that tor_instances expects: | # The instance definition that tor_instances expects: | ||||
# inst_name{:inst_conf:inst_user:inst_group:inst_pidfile:inst_data_dir} | # inst_name{:inst_conf:inst_user:inst_group:inst_pidfile:inst_data_dir} | ||||
# | # | ||||
. /etc/rc.subr | . /etc/rc.subr | ||||
name="tor" | name="tor" | ||||
rcvar=tor_enable | rcvar=tor_enable | ||||
exit_code=0 | exit_code=0 | ||||
load_rc_config ${name} | load_rc_config ${name} | ||||
: ${tor_enable="NO"} | : ${tor_enable="NO"} | ||||
: ${tor_instances=""} | : ${tor_instances=""} | ||||
: ${tor_conf="%%PREFIX%%/etc/tor/torrc"} | : ${tor_conf="%%PREFIX%%/etc/tor/torrc"} | ||||
: ${tor_user="%%USER%%"} | : ${tor_user="%%USER%%"} | ||||
: ${tor_group="%%GROUP%%"} | : ${tor_group="%%GROUP%%"} | ||||
: ${tor_pidfile="/var/run/tor/tor.pid"} | : ${tor_pidfile="/var/run/tor/tor.pid"} | ||||
: ${tor_datadir="/var/db/tor"} | : ${tor_datadir="/var/db/tor"} | ||||
: ${tor_disable_default_instance="NO"} | : ${tor_disable_default_instance="NO"} | ||||
: ${tor_setuid="NO"} | |||||
instance=${slave_instance} | instance=${slave_instance} | ||||
if [ -n "${instance}" ]; then | if [ -n "${instance}" ]; then | ||||
inst_def=${instance} | inst_def=${instance} | ||||
inst_name=${inst_def%%:*} | inst_name=${inst_def%%:*} | ||||
[ "${inst_name}" != "main" ] || err 1 "${name} instance can't be named 'main'" | [ "${inst_name}" != "main" ] || err 1 "${name} instance can't be named 'main'" | ||||
inst_def=${inst_def#$inst_name} | inst_def=${inst_def#$inst_name} | ||||
if [ -n "$inst_def" ]; then | if [ -n "$inst_def" ]; then | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
fi | fi | ||||
required_files=${tor_conf} | required_files=${tor_conf} | ||||
required_dirs=${tor_datadir} | required_dirs=${tor_datadir} | ||||
pidfile=${tor_pidfile} | pidfile=${tor_pidfile} | ||||
command="%%PREFIX%%/bin/${name}" | command="%%PREFIX%%/bin/${name}" | ||||
command_args="-f ${tor_conf} --PidFile ${tor_pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}" | command_args="-f ${tor_conf} --PidFile ${tor_pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}" | ||||
extra_commands="reload" | extra_commands="reload" | ||||
if [ $tor_setuid = "YES" ]; then | |||||
if ! grep -q "^User ${tor_user}$" ${tor_conf}; then | |||||
echo "User ${tor_user}" >> ${tor_conf} | |||||
fi | |||||
tor_user="root" | |||||
tor_group="wheel" | |||||
else | |||||
if grep -q "^User ${tor_user}$" ${tor_conf}; then | |||||
sed -i '' -e "s/^User ${tor_user}$//" ${tor_conf} | |||||
fi | |||||
fi | |||||
if ! run_rc_command "$1"; then | if ! run_rc_command "$1"; then | ||||
exit_code=1 | exit_code=1 | ||||
fi | fi | ||||
return $exit_code | return $exit_code |