精華區beta FreeBSD 關於我們 聯絡資訊
sendmail + sasl2 安裝說明 最近為了把 sendmail 加上 sasl 的功能,找了很多相關的資料, 終於把這兩個東西整合起來了。 網路上有許多同好還在為這項工作努力,所以我也不敢藏私,急忙把心得分享大家。 安裝之前,請先確認系統的版本。我目前實作的系統, 是 Freebsd 4.8 release,sendmail是 8.12.9,sasl 是 2.1.13_2 。 各位可以到 Makefile 裡面去確認版本正不正確。 感謝現在的 ports 已經把許多的相關聯的問題都處理完了,讓我們安裝起來相當的方便, 不過有些問題還是要先說明一下的,以便於了解整個機制的運作。 關於官方站的說明,請參考:SMTP AUTH in sendmail ,或是 rfc 的說明。 至於 sasl 的說明,請參考官方站 SMTP AUTH in sendmail http://www.sendmail.org/~ca/email/auth.html rfc http://www.ietf.org/rfc/rfc2554.txt sasl http://asg.web.cmu.edu/sasl/ 如果之前連 sasl2 都沒有裝過的話,ports 裡提供了一個很簡單的安裝方式, 請進入 ports/mail/sendmail-sasl,make install,它就會先幫忙安裝 sasl2。 或是自行進入 ports/security/cyrus-sasl2,make install 以安裝 sasl2 也可以。 安裝 sasl 時,會先出現一個選單,選擇 sasl 支援的型態。 在這裡我選擇了 DB3 跟 saslauthd 兩種型態。 DB3 的支援型態是為了可以使用 sasldb 的方式來設定使用權限, saslauthd 是為了可以直接讀取系統的 password 檔案, 來確定使用權限。administrator 可以依據自己的需要,來決定哪幾種支援型式。 安裝完畢之後,請檢查 /usr/local/lib/sasl2/Sendmail.conf 裡面, pwcheck_method 的值。如果是要使用系統的帳號則必須為 saslauthd。 如果是要自行定義 sasldb,則必須為 auxprop。 在這裡說明一下,為什麼要使用 sasldb。 假如說,我們只希望讓部分人可以在我們的 relay domain 外使用 sendmail+sasl, 則我們就只需要把這一部分人的身分認證資料,加入 sasl 中, 這樣可以達到控管的目的,又不需要更動到系統的資料檔。 如果是有安裝 saslauthd,並且想要讓 saslauthd 用 system 的 password 作認證的動作 ,請先修改 /usr/local/etc/rc.d/saslauthd.sh, 將 sasl_saslauthd_flags 修改成 sasl_saslauthd_flags="-a getpwent"。 最後啟動 saslauthd,>/usr/local/etc/rc.d/saslauthd.sh start。 相關的說明,可以參考 man saslauthd。 (http://www.freebsd.org/cgi/man.cgi?query=saslauthd&apropos=0&sektion=0& manpath=FreeBSD+Ports+4.7-RELEASE&format=html) 假如是使用 pwcheck_check=auxprop 的方式,在使用之前, 要將可以使用的 user 加進 sasldb 裡面。 請使用 saslpasswd2 -c $username$ 來將 $username$ 加進 database 中。 要看目前 database 裡面有哪些人,請用 sasldblistusers2 來檢視 database。 做完 sasl2 的設定之後,我們回頭到 sendmail 這邊來。運用 ports, 我們可以很簡單的在 sendmail 上加入 sasl 的 support。 請進入 ports/mail/sendmail-sasl,make install 即可。 我們可以到 Makefile 中看看,就可以知道這是在 compile sendmail 的時候, 加上 SENDMAIL_WITH_SASL2= yes 。 compile 完之後,要記得 make mailer.conf 以安裝新的 mailer.conf, 讓它執行 /usr/local/sbin/ 下的 sendmail。 再來就是產生出正確的 sendmail.cf 跟 submit.cf。 假如之前有 compile 過 sendmail, 請把 /etc/mail/ 下的 $hostname$.mc 跟 $hostname$.cf 都先搬走。 然後到 freebsd.mc 裡,在 MAILER(local) 之前加上下面幾行設定: dnl for sendmail with sasl define(`confEBINDIR', `/usr/local/libexec')dnl define(`UUCP_MAILER_PATH', `/usr/local/bin/uux')dnl dnl The group needs to be mail in order to read the sasldb2 file define(`confRUN_AS_USER',`root:mail')dnl TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confAUTH_MECHANISMS',`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confDONT_BLAME_SENDMAIL',`GroupReadableSASLDBFile')dnl 再來是到 freebsd.submit.mc 裡加上 DAEMON_OPTIONS(`Name=NoMTA, Addr=127.0.0.1, M=EA')dnl 這裡在 TRUST_AUTH_MECH 中加上的 LOGIN,是為了配合 outlook express 登入的機制。 而 PLAIN 是為了讓 netscape 可以使用 sendmail+sasl。 修改完畢之後,就可以 compile 新的 sendmail.cf 了。 請在 /etc/mail/ 底下執行 make all,來 make 新的 sendmail.cf, 然後執行 make install 以安裝新的設定檔。 在這裡我們可以先把舊的 sendmail.cf 跟 submit.cf 備分起來,以作為日後回復時使用。 再來就是執行 sendmail 了。請用 /usr/local/sbin/sendmail -bd -q15m, 然後連到 smtp port 看看,有沒有出現下面的字樣: > telnet localhost 25 Trying 127.0.0.1... Connected to localhost.xxx.xxx.xxx. Escape character is '^]'. 220 xxx.xxx.xxx.xxx ESMTP Sendmail 8.12.9/8.12.9; Sun, 1 Jun 2003 22:35:53 +0800(CST) ehlo localhost 250-xxx.xxx.xxx.xxx Hello localhost.xxx.xxx.xxx [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN 250-DELIVERBY 250 HELP 有的話就代表 sendmail+sasl 已經正常啟動。 一切都設定完成之後,你應該就可以使用 sendmail+sasl 了。 如果是要收信的話,別忘了裝 pop3 software,如 qpopper。 你可以到 ports/mail/qpopper/ 安裝。 由 gmchen 發表於 May 30, 2003 04:40 PM 摘錄自 http://www.tans.idv.tw:8080/archives/000014.html#more