summaryrefslogtreecommitdiff
path: root/security/cyrus-sasl/files/saslauthd.sh
blob: 70a99b42d6cce150500f0d5414288313b96ac807 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
#
# $FreeBSD$
#

action=$1

PREFIX=%%PREFIX%%

# Suck in the configuration variables.
if [ -z "${source_rc_confs_defined}" ]; then
        if [ -r /etc/defaults/rc.conf ]; then
                . /etc/defaults/rc.conf
                source_rc_confs
        elif [ -r /etc/rc.conf ]; then
                . /etc/rc.conf
        fi
fi

# The following sasl_saslauthd_* variables may be defined in rc.conf
#
# 	sasl_saslauthd1_enable  - Set to YES to enable saslauthd
#				 Default: %%ENABLESASLAUTHD%%
#
#	sasl_saslauthd1_program - Path to saslauthd program
#				 Default: ${PREFIX}/sbin/saslauthd1
#
#	sasl_saslauthd1_flags   - Flags to saslauthd program
#				 Default: -a pam

if [ -z "${sasl_saslauthd1_enable}" ]; then
	sasl_saslauthd1_enable=%%ENABLESASLAUTHD%%
fi

if [ -z "${sasl_saslauthd1_program}" ]; then
	sasl_saslauthd1_program=${PREFIX}/sbin/saslauthd1
fi

if [ -z "${sasl_saslauthd1_flags}" ]; then
	sasl_saslauthd1_flags="-a pam"
fi

rc=0

case "${sasl_saslauthd1_enable}" in
    [Yy][Ee][Ss])
	case "${action}" in

	    start)
		if [ -x ${sasl_saslauthd1_program} ] ; then
		    ${sasl_saslauthd1_program} ${sasl_saslauthd1_flags} \
			&& echo -n " saslauthd1"
		fi
		;;

	    stop)
		if [ -r /var/state/saslauthd1/mux.pid ]; then
		    kill `cat /var/state/saslauthd1/mux.pid` && \
			echo -n " saslauthd1"
		    rm /var/state/saslauthd1/mux.pid
		fi
		;;

	    *)
		echo "usage: $0 {start|stop}" 1>&2
		rc=64
		;;
	esac
	;;
    *)
	rc=0
	;;
esac

exit $rc