#!/bin/sh
#
# $NetBSD: saslauthd.sh,v 1.4 2022/05/10 03:34:16 khorben Exp $
#
# The saslauthd daemon allows cleartext UNIX password authentication via
# several authentication mechanisms with Cyrus SASL.
#
# PROVIDE: saslauthd
# REQUIRE: DAEMON
#
# You will need to set some variables in /etc/rc.conf to start saslauthd:
#
# saslauthd=YES

$_rc_subr_loaded . /etc/rc.subr

name="saslauthd"
rcvar="${name}"
command="/usr/pkg/sbin/saslauthd"
pidfile="/var/run/saslauthd/${name}.pid"
start_precmd="saslauthd_precmd"

# Default to authenticating against local password database.
: ${saslauthd_flags="-a getpwent"}

saslauthd_precmd()
{
        if [ ! -d /var/run/saslauthd ]; then
                /bin/mkdir -p /var/run/saslauthd
                /bin/chmod 0755 /var/run/saslauthd
                /usr/sbin/chown root /var/run/saslauthd
        fi
}

if [ -f /etc/rc.subr ]; then
	load_rc_config $name
	run_rc_command "$1"
else
	echo -n " ${name}"
	${command} ${saslauthd_flags} ${command_args}
fi
