ports/security/stunnel/files/stunnel.in
Ryan Steinmetz 7b6aed9ac3
security/stunnel: Drop privs by default, update PID file location
- Document changes in UPDATING

PR:		249151
Reported by:	 Tatsuki Makino <tatsuki_makino@hotmail.com>
2022-07-11 09:41:15 -04:00

52 lines
1.3 KiB
Bash

#!/bin/sh
# PROVIDE: stunnel
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add some of the following variables to /etc/rc.conf to configure stunnel:
# stunnel_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable stunnel.
# stunnel_config (str): Default "%%ETCDIR%%/stunnel.conf"
# Set it to the full path to the config file
# that stunnel will use during the automated
# start-up.
# stunnel_pidfile (str): Default "%%STUNNEL_PIDFILE%%"
# Set it to the value of 'pid' in
# the stunnel.conf file.
# stunnel_uid (str): Default "%%STUNNEL_USER%%"
# stunnel_gid (str): Default "%%STUNNEL_GROUP%%"
#
. /etc/rc.subr
name="stunnel"
rcvar=stunnel_enable
load_rc_config $name
: ${stunnel_enable="NO"}
: ${stunnel_config="%%ETCDIR%%/${name}.conf"}
: ${stunnel_pidfile="%%STUNNEL_PIDFILE%%"}
: ${stunnel_uid="%%STUNNEL_USER%%"}
: ${stunnel_gid="%%STUNNEL_GROUP%%"}
command="%%PREFIX%%/bin/stunnel"
command_args=${stunnel_config}
pidfile=${stunnel_pidfile}
required_files="${stunnel_config}"
start_precmd=stunnel_start_precmd
stunnel_start_precmd () {
local piddir
piddir=`/usr/bin/dirname "${pidfile}"`
if [ ! -d "${piddir}" ] ; then
/usr/bin/install -d -o "${stunnel_uid}" -g "${stunnel_gid}" "${piddir}"
fi
}
run_rc_command "$1"