Cyrus-SASL 2.1.23 Install (rpm)


Cyrus-SASL 2.1.23をインストールをした時のメモ。

  • Vine Linux 5.0
  • Cyrus-SASL 2.1.23

まずはSASLライブラリが組み込まれてるかチェック。
後でSMTP認証の際に使用するので一応。
最近のディストリはほぼ間違いなく入っていると思うが念のため。

$ rpm qa | grep sasl
cyrus-sasl-devel-2.1.23-4vl5
cyrus-sasl-2.1.23-4vl5
cyrus-sasl-plain-2.1.23-4vl5
cyrus-sasl-md5-2.1.23-4vl5

SMTP認証にMySQLを使うので必要な物を入れる。

$ su
# apt-get install cyrus-sasl-sql-2.1.23-4vl5


smtpd.confの作成

# touch /usr/lib64/sasl2/smtpd.conf
# vi /usr/lib64/sasl2/smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sql
allowanonymouslogin: no
allowplaintext: yes
mech_list: plain login
sql_engine: mysql
sql_hostnames: localhost
sql_database: db_name
sql_user: sql_user_name
sql_passwd: sql_user_pass
sql_statement: SELECT password FROM mailbox WHERE username = '%u@%r' AND active = '1'
log_level: 3

起動スクリプト。

#! /bin/bash
#
# saslauthd      Start/Stop the SASL authentication daemon.
#
# chkconfig: - 95 05
# description: saslauthd is a server process which handles plaintext \
#              authentication requests on behalf of the cyrus-sasl library.
# processname: saslauthd

# Source function library.
. /etc/init.d/functions

# Source our configuration file for these variables.
SOCKETDIR=/var/run/saslauthd
MECH=shadow
FLAGS=
if [ -f /etc/sysconfig/saslauthd ] ; then
	. /etc/sysconfig/saslauthd
fi

RETVAL=0

# Set up some common variables before we launch into what might be
# considered boilerplate by now.
prog=saslauthd
path=/usr/sbin/saslauthd

# Ugh. Switch to a specific copy of saslauthd if there's one with $MECH
# in its name, in case it wasn't included in the base cyrus-sasl package
# because it would have dragged in too many undesirable dependencies.
if test -x ${path}.${MECH} ; then
	path=/usr/sbin/saslauthd.$MECH
fi

start() {
	echo -n $"Starting $prog: "
	daemon $path -m $SOCKETDIR -a $MECH $FLAGS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc $path
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
	return $RETVAL
}	

restart() {
  	stop
	start
}	

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	restart
	;;
  status)
	status $path
	;;
  condrestart)
  	[ -f /var/lock/subsys/$prog ] && restart || :
	;;
  *)
	echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
	exit 1
esac

exit $?

起動設定後、起動する。

# chkconfig saslauthd on
# service saslauthd start

saslauthdを起動中:				[  OK  ]