2003-03-24 18:19:27 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2003-04-02 22:00:13 +04:00
|
|
|
# $NetBSD: smmsp,v 1.2 2003/04/02 18:00:14 atatat Exp $
|
2003-03-24 18:19:27 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
# REQUIRE: mail
|
|
|
|
|
2003-04-02 22:00:13 +04:00
|
|
|
# The only function of the smmsp process is to push locally
|
|
|
|
# collected mail (which got stuck in the local client queue)
|
|
|
|
# to a more fully functional smtp relay. It is not a fully
|
|
|
|
# functional smtp daemon.
|
|
|
|
#
|
|
|
|
# It can, however, be used as a completely unprivileged
|
|
|
|
# replacement for hosts that were previously using a "null
|
|
|
|
# client" configuration and a smart relay.
|
|
|
|
|
2003-03-24 18:19:27 +03:00
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="smmsp"
|
|
|
|
rcvar=$name
|
|
|
|
command="/usr/sbin/sendmail"
|
|
|
|
pidfile="/var/spool/clientmqueue/sm-client.pid"
|
|
|
|
required_files="/etc/mail/submit.cf"
|
|
|
|
start_precmd="smmsp_precmd"
|
|
|
|
|
|
|
|
smmsp_precmd()
|
|
|
|
{
|
|
|
|
_suidroot="${sendmail_suidroot:-NO}"
|
|
|
|
if checkyesno _suidroot; then
|
|
|
|
_owner_fmt="%p %Su"
|
|
|
|
_def_owner="104555 root"
|
|
|
|
_def_cqueuemode=""
|
|
|
|
else
|
|
|
|
_owner_fmt="%p %Su %Sg"
|
|
|
|
_def_owner="102555 root smmsp"
|
|
|
|
_def_cqueuemode="40770 smmsp smmsp"
|
|
|
|
fi
|
|
|
|
_def_version="10"
|
|
|
|
_cqueuemode="${_def_cqueuemode}" # changed later if needed
|
|
|
|
|
|
|
|
# check owner and mode of real sendmail binary
|
|
|
|
_owner=$(stat -qf"${_owner_fmt}" /usr/libexec/sendmail/sendmail)
|
|
|
|
if [ "${_owner}" != "${_def_owner}" ]; then
|
2003-04-02 22:00:13 +04:00
|
|
|
warn "${name} /usr/libexec/sendmail/sendmail has " \
|
|
|
|
"wrong owner/mode"
|
2003-03-24 18:19:27 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# check submit.cf existence
|
|
|
|
if checkyesno _suidroot; then
|
|
|
|
if [ -f /etc/mail/submit.cf ]; then
|
2003-04-02 22:00:13 +04:00
|
|
|
warn "${name} starting; " \
|
|
|
|
"sendmail is suid root, but submit.cf exists"
|
2003-03-24 18:19:27 +03:00
|
|
|
else
|
2003-04-02 22:00:13 +04:00
|
|
|
warn "${name} not started; no need for ${name} " \
|
|
|
|
"service when sendmail is suid root"
|
2003-03-24 18:19:27 +03:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ ! -f /etc/mail/submit.cf ]; then
|
2003-04-02 22:00:13 +04:00
|
|
|
warn "${name} not started; /etc/mail/submit.cf missing"
|
2003-03-24 18:19:27 +03:00
|
|
|
return 1
|
|
|
|
else
|
|
|
|
_cqueue=$(sed -n 's/^O *QueueDirectory=\(.*\)/\1/p' \
|
|
|
|
/etc/mail/submit.cf)
|
|
|
|
_cqueuemode=$(stat -qf"%p %Su %Sg" "${_cqueue}")
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check .cf file version
|
|
|
|
_cfversion=$(sed -n 's/^V *\([0-9]*\).*/\1/p' /etc/mail/submit.cf)
|
|
|
|
if [ "${_cfversion}" != "${_def_version}" ]; then
|
2003-04-02 22:00:13 +04:00
|
|
|
warn "${name} not started; " \
|
|
|
|
"/etc/mail/submit.cf has wrong version " \
|
|
|
|
"(have ${_cfversion}, should be ${_def_version})"
|
2003-03-24 18:19:27 +03:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# look at clientmqueue's owner, group, and mode
|
|
|
|
if [ "${_cqueuemode}" != "${_def_cqueuemode}" ]; then
|
2003-04-02 22:00:13 +04:00
|
|
|
warn "${name} not started;" \
|
|
|
|
"queue ${_cqueue} has wrong owner/mode"
|
2003-03-24 18:19:27 +03:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|