Solaris で sendmail バージョンアップ
はじめに
下では、sendmail-8.14.2 を書いているが、(差し支えなければ)必ず最新の sendmail をインストールしましょう(セキュリティ上の理由). 下記の設定は「うのみ」にしないで、よく理解してから使ってください。インストール後のテストも行ってください。
【関連する外部ページ】 http://www.sendmail.org/
sendmail-8.14.2 インストール手順
- インストールされている sendmail のバージョンの確認
「telnet localhost 25」とやると、(sendmail が動いていれば)情報が出てく るはずです。 見終わったら「QUIT」と入れます。
telnet localhost 25 [情報が表示される] QUIT
- ソースの入手
- http://www.sendmail.org/8.14.2.html
- sendmail.8.14.2.tar.gz をダウンロード
- make
sh cd /tmp rm -rf /tmp/sendmail-8.14.2 gzip -d < sendmail.8.14.2.tar.gz | tar -xvf - cd /tmp/sendmail-8.14.2 CC=gcc sh Build # or, CC=gcc; csh; sh Build
- sendmail の停止
pkill sendmail pkill sendmail pkill sendmail pkill sendmail pkill sendmail sh /etc/rc2.d/S88sendmail stop sleep 5 /usr/bin/ps -eo pid,comm | grep sendmail
- 必要な設定ファイルのバックアップ
8.12 系統の sendmail がインストール済みであれば、次の2つのファイルがあるはずなので、(念のために)バックアップしておく。
/etc/mail/trusted-users /etc/mail/aliases
バックアップですが、cp /etc/mail/trusted-users /etc/mail/aliases /var/tmp などでよいでしょう。
- 古い設定ファイルの削除
rm -f /usr/lib/sendmail rm -f /usr/lib/sendmail.original rm -f /usr/lib/sendmail.script
- インストールと設定
インストールの前に /etc/passwd, /etc/group に smmsp があることを確認。
sh chown smmsp /var/spool/clientmqueue chgrp smmsp /var/spool/clientmqueue mkdir /usr/share/man/cat1 mkdir /usr/share/man/cat8 mkdir /usr/share/man/cat5 cd /tmp/sendmail-8.14.2 CC=gcc sh Build install cd /tmp/sendmail-8.14.2/cf/cf cp generic-solaris.mc sendmail.mc
# ここで、/tmp/sendmail-8.14.2/cf/cf/sendmail.mc の編集を行う必要がある。 この Web ページの下の方に、「sendmail.mc の見本」を付けていますので、参考にしてください。
cd /tmp/sendmail-8.14.2/cf/cf sh Build sendmail.cf cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.BACKUP sh Build install-cf chmod 755 /var chmod 755 /var/spool chmod go-w / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue chown root / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue chmod 0640 /etc/mail/aliases /etc/mail/aliases.db /etc/mail/aliases.pag /etc/mail/aliases.dir chmod 0640 /etc/mail/*.db chmod 0640 /etc/mail/*.pag chmod 0640 /etc/mail/*.dir chmod 0640 /etc/mail/statistics /var/log/sendmail.st chmod 0600 /var/run/sendmail.pid /etc/mail/sendmail.pid
- その他の設定ファイル
- /etc/mail/trusted-users
次のようにするのかな? (確認中)
「username」、「domainname」のところは適当に書き換えてください。username username@domainname
- /etc/mail/aliases
適当に設定します。(うまく設定しないと、メールが「消えて」しまうので注意してください)
- /etc/mail/trusted-users
- 起動
echo build /etc/mail/aliases.db cd /etc/mail touch /etc/mail/aliases /use/lib/sendmail -v -bi newaliases sh /etc/rc2.d/S88sendmail start /usr/bin/ps -eo pid,comm | grep sendmail
- 動作確認
「telnet localhost 25」とやると、情報が出てくるか? を見ます。
telnet localhost 25 [情報が表示される] QUIT
sendmail.mc の見本
手元にマシンがある。 このマシンでは、sendmail のメールのリレーも、メールの受信もしない。 sendmail で何をするかというと、全てのメールを、ある特定の マシン(設定ファイル内の SMART_HOSTの行に書いたマシン)に送信だ けしたいという設定です。 (なお、受信は sendmail では無くて、POP 等の手段で受信すると考えています)
- MASQUERADE_AS の行は, マシンが属するドメイン名によって変えてください(このまま使っても動かない)。
- SMART_HOST の行には、メールサーバの名前を書いてください(このまま使っても動かない)。
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 などで行う.