金子邦彦研究室インストールSolarisSolaris で sendmail バージョンアップ

Solaris で sendmail バージョンアップ

はじめに

下では、sendmail-8.14.2 を書いているが、(差し支えなければ)必ず最新の sendmail をインストールしましょう(セキュリティ上の理由). 下記の設定は「うのみ」にしないで、よく理解してから使ってください。インストール後のテストも行ってください。

関連する外部ページ http://www.sendmail.org/

sendmail-8.14.2 インストール手順

sendmail.mc の見本

手元にマシンがある。 このマシンでは、sendmail のメールのリレーも、メールの受信もしない。 sendmail で何をするかというと、全てのメールを、ある特定の マシン(設定ファイル内の SMART_HOSTの行に書いたマシン)に送信だ けしたいという設定です。 (なお、受信は sendmail では無くて、POP 等の手段で受信すると考えています)

divert(-1)
#
# Copyright (c) 1998, 1999, 2001 Sendmail, Inc. and its suppliers.
#    All rights reserved.
# Copyright (c) 1983 Eric P. Allman.  All rights reserved.
# Copyright (c) 1988, 1993
#    The Regents of the University of California.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#

#
#  This is a generic configuration file for SunOS 5.x (a.k.a. Solaris 2.x
#  and Solaris 7 through the present version).
#
#  It has support for local and SMTP mail only.  If you want to
#  customize it, copy it to a name appropriate for your environment
#  and do the modifications there.
#

divert(0)dnl
VERSIONID(`$Id: generic-solaris.mc,v 8.13 2001/06/27 21:46:30 gshapiro Exp $')
OSTYPE(solaris2)dnl
DOMAIN(generic)dnl
FEATURE(`masquerade_envelope')dnl
FEATURE(`use_ct_file')dnl
MASQUERADE_AS(`domainname')dnl
MASQUERADE_DOMAIN(`localhost')dnl
EXPOSED_USER(`root')dnl
define(`confPRIVACY_FLAGS', `goaway')dnl
define(`SMART_HOST', `sitename.domainname')dnl
define(`ALIAS_FILE', `/etc/mail/aliases')dnl
MAILER(local)dnl
MAILER(smtp)dnl

/etc/rc2.d/S88sendmail の見本

#!/sbin/sh
#
# Copyright (c) 1992, 1995, 1997 - 1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident    "@(#)sendmail    1.15    99/01/28 SMI"

ERRMSG1='WARNING: /var/mail is NFS-mounted without setting actimeo=0,'
ERRMSG2='this can cause mailbox locking and access problems.'

case "$1" in
'start')
    if [ -f /usr/lib/sendmail -a -f /etc/mail/sendmail.cf ]; then
        if [ ! -d /var/spool/mqueue ]; then
            /usr/bin/mkdir -m 0750 /var/spool/mqueue
            /usr/bin/chown root:bin /var/spool/mqueue
        fi
        MODE="-bd"
        if [ -f /etc/default/sendmail ]; then
            . /etc/default/sendmail
        fi
        #
        # * MODE should be "-bd" or null (MODE= or MODE="") or
        #   left alone.  Anything else and you're on your own.
        # * QUEUEINTERVAL should be set to some legal value;
        #   a sanity check is done below.
        # * OPTIONS is a catch-all; set with care.
        #
        if [ -z "$QUEUEINTERVAL" ]; then
            QUEUEINTERVAL="15m"
        fi
        case $QUEUEINTERVAL in
            *s | *m | *h | *d | *w) ;;
            *)  QUEUEINTERVAL="15m" ;;
        esac
        if [ $QUEUEINTERVAL -le 0 ]; then
            QUEUEINTERVAL="15m"
        fi
        /usr/lib/sendmail $MODE -q$QUEUEINTERVAL $OPTIONS &
    fi    

    if /usr/bin/nawk 'BEGIN{s = 1}
        $2 == "/var/mail" && $3 == "nfs" && $4 !~ /actimeo=0/ &&
        $4 !~ /noac/{s = 0} END{exit s}' /etc/mnttab; then

        /usr/bin/logger -p mail.crit "$ERRMSG1"
        /usr/bin/logger -p mail.crit "$ERRMSG2"
    fi
    ;;

'stop')
    /usr/bin/pkill -x -u 0 sendmail
    ;;

*)
    echo "Usage: $0 { start | stop }"
    exit 1
    ;;
esac
exit 0

古い sendmail で relay をあるサイトに制限する方法

sendmail.mc で無くて, sendmail.def(sendmail.cf の元ファイル) を使うような 「古い」 sendmail で relay をあるサイトに制限(例えば九大)し, それ以外の reply は禁止したいということです.
MAIL_RELAY_RESTRICTION=yes
    (中継の制限をするかどうか)

LOCAL_HOST_IPADDR=133.5
LOCAL_HOST_DOMAIN=kyushu-u.ac.jp
    (受信/中継を無条件に許可する SMTP 接続ホストの IP とドメイン)

ALLOW_RELAY_TO=kyushu-u.ac.jp
    (中継を許可する受信者アドレスのドメイン)
チェックは, http://maps.vix.com/tsi/ar-test.html などで行う.