Postfix の SMTP認証で pam を使う設定

2009-11-24 22:00
このエントリーをはてなブックマークに追加

CentOS など Red Hat では Postfix の SMTP_AUTH(SMTP認証)では、Cyrus SASL (saslauthd) の sasldb を使うのが一般的になっています。その設定方法はネットにたくさん書かれていますが、pam による認証をする場合の設定方法かあまりまとまったものが無いようなのでここに書いておきます。この方法は saslpasswd2 コマンドではなく、useradd や passwd コマンドによりユーザ管理をしている場合のものです。

環境は CentOS 5.4 (64bit) で試しました。Postfix、Cyrus SASL がインストールされている環境です。Postfix 自体の設定方法は割愛します。

Postfix の設定

/etc/postfix/main.cf を編集して、SMTP 認証を有効にします。

smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_application_name = smtpd
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination
broken_sasl_auth_clients = yes

上記の smtpd_recipient_restrictions などは、その環境やポリシーによって異なると思います。Outlook Express を使用する場合のみ broken_sasl_auth_clientsyes にしてください。

saslauthd の設定

/usr/lib64/sasl2/smtpd.conf (32bit の場合は /usr/lib/sasl2/smtpd.conf) を編集します。

pwcheck_method: saslauthd
mech_list: plain login

次に /etc/sysconfig/saslauthd で MECH の値が pam になっていることを確認します。

MECH=pam

Postfix と Cyrus SASL デーモン(saslauthd) を再起動します。

$ sudo /sbin/service postfix restart
$ sudo /sbin/service saslauthd restart

これで、pam による認証ができるようになります。saslauthd は chkconfig コマンドで自動起動するようにしておきましょう。

secure ログに警告が出力される場合の pam の設定

/var/log/secure ログに次のようにメッセージが出る場合があります。

saslauthd[10662]: Deprecated pam_stack module called from service "smtp"
saslauthd[10662]: Deprecated pam_stack module called from service "smtp"
saslauthd[10662]: Deprecated pam_stack module called from service "smtp"

これは、利用が推奨されなくなった pam_stack モジュールを使う設定にしている場合に出ます。(古い設定方法を書いてあるサイトにはこの記述があるので、コピーして使っている場合に該当します。)

/etc/pam.d/smtp を次のように変更すれば出なくなります。

#%PAM-1.0
#(こちらが初期設定)
auth       include     system-auth
account    include     system-auth
# (以下は推奨されなくなった設定)
#auth       required     pam_stack.so service=system-auth  
#account    required     pam_stack.so service=system-auth

1件のコメント

  1. 設定するの?

    コメント by BlogPetのusausa2009-11-25 14:28

Sorry, the comment form is closed at this time.

35 queries. HTML convert time: 0.084 sec. Powered by WordPress. Valid XHTML
Copyright © 2003-2017 @ futuremix.org ログイン