あとはサーバー側にメールサーバーの機能を持たせるだけ
Mac標準でもpostfixは入っていますが、TLSが使えなさそうなため今回はmacportsから導入~
# port install postfix +tls +sasl
......
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_mail_postfix/work/postfix-2.4.6" && make " returned error 2
......
make: *** [libutil.a] Error 1
make: *** [update] Error 1
Error: Status 1 encountered during processing.
あら、こけた。とりあえず原因を探ってみる
# cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_mail_postfix/work/postfix-2.4.6
# make
......
[src/util]
DNO_PCRE -DUSE_TLS -DHAS_SSL -I/opt/local/include -DUSE_CYRUS_SASL -DUSE_SASL_AUTH -I/opt/local/include/sasl -DBIND_8_COMPAT -DNO_NETINFO -g -O -I. -DMACOSX -c alldig.c
make: DNO_PCRE: Command not found
make: [alldig.o] Error 127 (ignored)
出るわ出るわの大量エラー。Cコンパイラーが指定されていないのが原因みたい。
同ディレクトリー直下のMakefileを開き一部修正してみる。
(変更前)CC = -DNO_PCRE -DUSE_TLS -DHAS_SSL -I/opt/local/include -DUSE_CYRUS_SASL -DUSE_SASL_AUTH -I/opt/local/include/sasl -DBIND_8_COMPAT -DNO_NETINFO
(変更後)CC = /usr/bin/gcc -DNO_PCRE -DUSE_TLS -DHAS_SSL -I/opt/local/include -DUSE_CYRUS_SASL -DUSE_SASL_AUTH -I/opt/local/include/sasl -DBIND_8_COMPAT -DNO_NETINFO
再度port install postfixでインストール完了。
saslを設定。
ネ申のつくりたもうた設定を元に再現してみた
# cd /usr/lib/sasl2
# ln -s disabled/libkerberos4.la ./
# ln -s disabled/libsasldb.2.so ./
# ln -s disabled/libsasldb.la ./
# ln -s disabled/libsql.la ./
# ln -s disabled/libsql.so ./
# mkdir /opt/local/etc/sasl
# view /opt/local/etc/sasl/smtp.conf
pwcheck_method: auxprop
auxprop_plugin: sasldb
mech_list: cram-md5 digest-md5
# ln -s /opt/local/etc/sasl/smpt.conf /opt/local/lib/sasl2/
# saslpasswd2 -u [main.cfのsmtpd_sasl_local_domain(=REALMとして使用される)] -c [ユーザー名]
sasldblistuser2で確認できないし、syslogにSASL authentication failure: no user in dbも出てる。
でもパケットキャプチャを見た限りだとAuthentication successfulといっているし、パスワード変えたらauthentication failedが出たので気にしないことにする。
最後にport installでも表示されたlaunchdへの登録aunchctl load -w /Library/LaunchDaemons/org.macports.postfix.plistを実行しておしまい
次にPOP/IMAPのCourier-IMAP
2008/04時点でのバージョンはcourier-imap4.1.3_0/courier-authlib0.60.0_0
# port install Courier-IMAP
ほんでもって準備
# mkdir /data/mail/home
# chown 5000:5000 /data/mail/home
# userdb USER@DOMAIN set mail=/DIRECTORY/DOMAIN/USER home=/data/mail/home uid=5000 gid=5000
# userdbpw -hmac-md5 | userdb USER@DOMAIN set hmac-md5pw
# makeuserdb
ここまでは順調。
launchctl load -w /Library/LaunchDaemon/org.macports.courier-imap.plistでほい起動と思いきや、ps aux | grep imapdで誰もいない。。。
# cd /opt/local/libexec
# sh -x imapd.rc start
......
/opt/local/var/run/imapd.pid.lock: Bad file descriptor
ll_daemon_start: Resource temporarily unavailable
+ exit 0
Macで問い合わせしている先人がおり、どうやらcourier-authlibの問題らしい。
パッチがリリースされていたので、当ててみる。
# port -d -f extract courier-authlib
# port -d -f configure courier-authlib
# port dir courier-authlib
/opt/local/var/macports/sources/rsync.macports.org/release/ports/security/courier-authlib
# cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/security/courier-authlib
# cd work/courier-authlib-0.60.0
# patch -p0 <先人のスレッドにあるJohnny C. Lamが作ったパッチファイル>
# port -d -f build courier-authlib
buildに失敗しないことを確認したら後はinstallのみ。ただし、courier-imapとの依存性があるため、-fオプション付で先にuninstallする
# port -f uninstall courier-authlib
# port -d -f install courier-authlib
おもむろにlaunchctl restart org.macports.courier-imap。コレでimapdは動いた。認証してみると失敗、syslogこんなのが。。。
imapd[60705]: Connection, ip=[::ffff:192.168.75.75]
imapd[60705]: authdaemon: s_connect() failed: No such file or directory
imapd[60705]: LOGIN FAILED, method=CRAM-MD5, ip=[::ffff:192.168.75.75]
imapd[60705]: authentication error: No such file or directory
やはりcourier-authlib周り、デーモンのauthdaemondが起動していないのが問題。
mkdir /opt/local/var/spool/authdaemonした上で/opt/local/sbin/autodaemond startにて起動。でもsyslogにまたこんなのが。。。orz
authdaemond[12749]: modules="authuserdb authpwd authcustom authpipe", daemons=2
authdaemond[12749]: Installing libauthuserdb
authdaemond[12749]: dlopen(/opt/local/lib/courier-authlib/libauthuserdb.so, 9): Symbol not found: _auth_userdb
authdaemond[12749]: Referenced from: /opt/local/lib/courier-authlib/libauthuserdb.so
authdaemond[12749]: Expected in: flat namespace
また世界が知ってました。
先人たちの知恵に従いexport MACOSX_DEPLOYMENT_TARGET=10.5後にport configureからやり直し。
先人たちは0.60.2、macportは0.60.0なのが原因か結局直らず
しようがなくなったので禁じ手のsourceからのmake。ただし今後もmacportは使いたいので0.60.2を0.60.0としてportからconfigure/make/make installする。
# port -f uninstall courier-authlib
# port extract courier-authlib
# port dir courier-authlib
/opt/local/var/macports/sources/rsync.macports.org/release/ports/security/courier-authlib
# cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/security/courier-authlib
# wget http://jaist.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.60.2.tar.bz2
# bzip2 -dc courier-authlib-0.60.2.tar.bz2 | tar xvf -
# mv courier-authlib-0.60.0 courier-authlib-0.60.0.org
# ln -s courier-authlib-0.60.2 courier-authlib-0.60.0
# export MACOSX_DEPLOYMENT_TARGET=10.5
# port -f -v -k configure courier-authlib
# port -f -v -k install courier-authlib
最後に/opt/local/etc/LaunchDaemons/org.macports.courier-imap/courier-imap.wrapperへ/opt/local/sbin/autodaemond [start|stop]を追加して
再度launchctlでrestartしてようやく終了。長かった。。。ちなみにport installを-fオプションなしでやると、どうやらfetch/extract/configureも勝手にやっちゃうみたいなので注意
TLS非対応版imapdも必要なら同じくcourier-imap.wrapperに/opt/local/libexec/imapd.rc [start|stop]も加えるべし。まだTLS対応してないのでそっちは徐々にやってくあるよ
postfix
- http://www.gside.org/Gentoo/postfix/postfix.html
- http://www.tmtm.org/postfix/tutorial/virtual.html
- http://cmf.ohtanz.com/blog/archives/129
Courier-IMAP
- http://www.gside.org/Gentoo/postfix/virtualdomain.html
▲ ...Close