summaryrefslogtreecommitdiff
path: root/security/cyrus-sasl/files/sasl_pwcheck.sh
blob: d8091bd999a7dc6ecc7aaf45d6f1edb12d54a512 (plain)
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
#! /bin/sh
#
# $NetBSD: sasl_pwcheck.sh,v 1.2 2001/11/21 22:22:10 jlam Exp $
#
# The pwcheck daemon allows UNIX password authentication with Cyrus SASL.
#
# PROVIDE: sasl_pwcheck
# REQUIRE: DAEMON

if [ -e /etc/rc.subr ]
then
	. /etc/rc.subr
fi

name="sasl_pwcheck"
rcvar="${name}"
command="@PREFIX@/sbin/pwcheck"
command_args="& sleep 2"
extra_commands="dbinit"

sasldb=@CONFDIR@/sasldb.db

sasl_pwcheck_dbinit()
{
	(
	saslpasswd=@PREFIX@/sbin/saslpasswd
	umask 002
	if [ -e ${sasldb} ]
	then
		@ECHO@ "You already have an existing SASL password database"
		@ECHO@ "Skipping empty database generation"
	else
		@ECHO@ password | ${saslpasswd} -p user
		${saslpasswd} -d user
		@CHOWN@ @PKG_USER@ ${sasldb}
		@CHMOD@ 0600 ${sasldb}
	fi
	)
}

sasl_pwcheck_precmd()
{
	if [ ! -e ${sasldb} ]
	then
		@RCD_SCRIPTS_DIR@/sasl_pwcheck dbinit
	fi
}

dbinit_cmd=sasl_pwcheck_dbinit
start_precmd=sasl_pwcheck_precmd

if [ -e /etc/rc.subr ]
then
	load_rc_config $name
	run_rc_command "$1"
else
	@ECHO@ -n " ${name}"
	start_precmd
	${command} ${sasl_pwcheck_flags} ${command_args}
fi