ユーザ用ツール

サイト用ツール


サイドバー

Index

はじめてのおつかい






DokuWiki整形記法


PlayGround



serverapps:postfix:smtpauth

SMTP Auth

SMTP Authにはcyrus-sasl2-saslauthdを使用しています。

インストール

 # portsinstall security/cyrus-sasl2-saslauthd
   [X] OPENLDAP ON

Ldap対応の確認

# saslauthd -v
saslauthd 2.1.23
authentication mechanisms: sasldb getpwent kerberos5 pam rimap ldap
                                                                ↑Ldap対応確認

起動

/etc/rc.confに以下を追加。

 saslauthd_enable="YES"
 saslauthd_flags="-a ldap"
 # /usr/local/etc/rc.d/saslauthd start

LDAP認証設定

saslauthd.conf作成

saslauthd.confは作成されていないので自分で作ります。

 # touch /usr/local/etc/saslauthd.conf

中身はこんな感じです。

 ldap_servers: ldap://ldapサーバアドレス/
 ldap_version: 3
 ldap_bind_dn: cn=管理者,dc=yyyy,dc=zzz
 ldap_password: パスワード
 ldap_search_base: ou=xxxx,dc=yyyy,dc=zzz
 ldap_filter: uid=%u
 ldap_deref: search

mailアドレスをキーにしたい場合は

 ldap_filter: mail=%u
または
 ldap_filter: mail=%u@%d

 # %U=info@example.com
 # %d=example.com
 # %u=info 

に変更

起動

 # /usr/local/etc/rc.d/saslauthd start

以下のコマンドでチェック

 # testsaslauthd -u XXX -p *****
   0: OK "Succes."と出力されれば、Cyrus-SASLとOpenLDAPの連係はOK
   0: NO "authentication failed" だと失敗

ただし、IDに@が含まれていると動作が怪しい。 うちではtestsaslauthd がエラーなのに、SMTP AUTHは動作するというケースが出ています。

かなり、特殊な設定のため以下の様に設定しています。

 ldap_filter: (|(mail=%U)(mail=%u@%d))

このときtestsaslauthd はこんな感じです。

 # testsaslauthd -u myname -p password
   0: OK "Success."
 # testsaslauthd -u virtialuser@example.com -p password
   0: NO "authentication failed"

ですが、メールの送信は

 postfix/smtp[xxx]: xxx: to=<hoge@example.net>, relay=xxx.xxx[nnn...]:25, delay=........., status=sent (250 2.0.0 Ok: queued as xxxxx)

のように成功します。う~ん、なぜだろう。:-| FIXME

Postfix設定

/etc/postfix/main.cfを以下の様に変更する。

 smtpd_sasl_auth_enable=yes
 smtpd_recipient_restrictions=・・・・・・permit_sasl_authenticated・・・・・・
                                                   ↑追加
serverapps/postfix/smtpauth.txt · 最終更新: 2017/04/14 14:21 (外部編集)