恥ずかしながら私はメールサーバを構築したことがない.これではいろんな実験,検証をする際に不便な場合があるので,構築してみた.
構築概要
競合するパッケージのアンインストール
ucspi-tcpのインストール
ucspi-tcpのビルド
qmail-srcパッケージのインストール
qmailのビルド
競合するパッケージに連座したパッケージをインストール
qmailの起動確認
構築概要
qmailのバイナリパッケージが見当たらないので(※),作業概要は以下のようになった.
競合するパッケージのアンインストール
ソースパッケージucspi-tcp-srcのインストール
ucspi-tcpのビルド
ソースパッケージqmail-srcのインストール
qmailのビルド
競合するパッケージに連座したパッケージをインストール
qmail-srcインストール時,同時にインストールを推奨されるのがucspi-tcp-src. 推奨ならいらないかと,無視していたが,ビルドされるqmailは,ucspi-tcpに依存するので,結果的にucspi-tcp-srcは推奨ではなく依存である.
※ qmailのライセンス(変更した場合は,ソースとして配布しなければならない)とDebianのポリシー(qmailのディレクトリ構造などがDebianとしてはよろしくない)とが,うまくいかず,折衷案としたこうなったらしい.
競合するパッケージのアンインストール
eximはqmailと競合するので,あらかじめ削除しておく.
apt-get remove exim
私の環境では同時に
at mailx postgresql
が消された. あとで入れ直す.
ucspi-tcpのインストール
# apt-get install ucspi-tcp-src
すると
To build ucspi-tcp binary package, you have to run
build-ucspi-tcp
Press ENTER to continue...
となる. ソースパッケージのインストールは以上.
ucspi-tcpのビルド
ソースパッケージインストール時の案内どおり,以下を実行.
# build-ucspi-tcp
This script unpacks the ucspi-tcp source into a directory, and
compiles it to produce a binary ucspi-tcp*.deb file.
The directory where this is done will end up containing the source
and package files for the ucspi-tcp binary package, along with a
directory containing the unpacked source.
Enter a directory where you would like to do this [/tmp/ucspi-tcp]
build-ucspi-tcpはスクリプトで,ucspi-tcpのソースをアンパックして,コンパイルして,バイナリのucspi-tcp*.debを作成してくれるらしい. そして,その作業ディレクトリの入力を求められる. デフォルトで続けると,パッチを当てるタイミングで一度止まる. パッチは当てないので,Enterを押して続ける. やはりビルドがうまく行くと,以下のようなメッセージが出る.
It seems that all went ok
Do you want to remove all files in /tmp/ucspi-tcp,
except ucspi-tcp_0.88-9_i386.deb now? [Yn]
Yを入力すると,/tmp/qmail以下でdebファイル以外の全ファイルが削除される. 続いてすぐにdebパッケージをいれるか聞かれる.
Do you want to install ucspi-tcp_0.88-9_i386.deb now? [Yn]
Yでインストールする. そしてuscpi-tcp-srcパッケージを消すか聞かれるので,Nと答える.
Do you want to purge ucspi-tcp-src now? [yN]
Remember that you can install ucspi-tcp_0.88-9_i386.deb
on other computers so you don't need to compile it again.
Good luck!
作成したdebファイルは別マシンでもインストール可能らしい... 最後に祝福されて終る.
qmail-srcパッケージのインストール
まず,qmailのソースをインストールする.
# apt-get install qmail-src
すると,
build-qmailしろ
と確認ダイアログが出て来るので,[OK]を押す. 次に警告が出て来る.
build-qmailでビルドされたバイナリパッケージは,パッケージをビルドシステムのuidとgidに依存する.
もし,初めてqmailをビルドしてインストールしている場合,
/etc/passwd, /etc/shadow, /etc/groupをチェックし,
すべてのqmailのuidとgidを削除し,qmail-srcを再インストールするよう,強く推める.
うーん,バイナリパッケージが無い辺りから薄々感じていたが,qmailのインストールには何だか複雑な事情があるらしい.
# grep 'qmail' /etc/{passwd,shadow,group,gshadow}
...mailでgrepすると引っかかるのだが,qmailで引っかからないからいいのだろうか. とりあえず[OK]を押し,継続してみる. インストーラはqmailユーザが新しく作成したりして終了する.
No qmail accounts present, creating them now
Adding group `qmail' (64010)...
Done.
adduser: Warning: The home dir you specified does not exist.
Adding system user `alias'...
Adding new user `alias' (64010) with group `nogroup'.
Not creating home directory.
adduser: Warning: The home dir you specified does not exist.
Adding system user `qmaild'...
Adding new user `qmaild' (64011) with group `nogroup'.
Not creating home directory.
adduser: Warning: The home dir you specified does not exist.
Adding system user `qmails'...
Adding new user `qmails' (64012) with group `qmail'.
Not creating home directory.
adduser: Warning: The home dir you specified does not exist.
Adding system user `qmailr'...
Adding new user `qmailr' (64013) with group `qmail'.
Not creating home directory.
adduser: Warning: The home dir you specified does not exist.
Adding system user `qmailq'...
Adding new user `qmailq' (64014) with group `qmail'.
Not creating home directory.
adduser: Warning: The home dir you specified does not exist.
Adding system user `qmaill'...
Adding new user `qmaill' (64015) with group `nogroup'.
Not creating home directory.
adduser: Warning: The home dir you specified does not exist.
Adding system user `qmailp'...
Adding new user `qmailp' (64016) with group `nogroup'.
Not creating home directory.
...何か最初に自動でqmailユーザの有無チェックをしてるみたいだな. まぁ,ユーザアカウントの処理だけに,無言で全自動実行も問題なので,先のダイアログは妥当だろう
qmailのビルド
続いて,インストール時の案内どおり,
# build-qmail
してみる.
# build-qmail
This script unpacks the qmail source into a directory, and
compiles it to produce a binary qmail*.deb file.
The directory where this is done will end up containing the source
and package files for the qmail binary package, along with a
directory containing the unpacked source.
!* WARNING *!
There have been reports of undesired behavior when attempting to
build qmail in a directory on a tmpfs based filesystem. Please do
not try to build on an tmpfs filesystem.
Enter a directory where you would like to do this [/tmp/qmail]
build-qmailはスクリプトで,qmailのソースをアンパックして,コンパイルして,バイナリのqmail*.debを作成してくれるらしい. そして,その作業ディレクトリの入力を求められる. このディレクトリにtmpfsを指定するとまずいらしい... デフォルトで続ける. するとソースをアンパックしたので,パッチをあてるなら今だ,と言って,すでに当たっているパッチの一覧も出て来る. パッチをあてるには別コンソールで作業してから,このコンソールの作業に戻るらしい. パッチは当てないのでこのまま続ける. ビルドがうまく行くと,以下のようなメッセージが出る.
It seems that all went ok
Do you want to remove all files in /tmp/qmail,
except qmail_1.03-38_i386.deb now? [Yn]
Yを入力すると,/tmp/qmail以下でdebファイル以外の全ファイルが削除される. 続いてすぐにdebパッケージをいれるか聞かれる.
Do you want to install qmail_1.03-38_i386.deb now? [Yn]
Yでインストールする. すると,qlistは分割されたとか言われる... よく分からないが,必要なら
http://pobox.com/~djb/qlist.html
から取得可能らしい. 次にqmailを今起動するかを聞かれる. 勢いでYesとした. そしてuscpi-tcp-srcパッケージを消すか聞かれるので,Nと答える.
Do you want to purge qmail-src now? [yN]
Remember that you can install qmail_1.03-38_i386.deb
on other computers so you don't need to compile it again.
Don't forget to setup a /etc/qmail/rcpthosts file to prevent open relaying!
Good luck!
作成したdebファイルは別マシンでもインストール可能らしい. とにかく不正中継を防止するために
/etc/qmail/rcpthosts
を設定せよとのこと. 最後に祝福されて終る.
競合するパッケージに連座したパッケージをインストール
インストール作業の後始末として,eximをアンインストールした際に連座したパッケージを元通りインストールしなおしておく. 私の環境では同時に
at mailx postgresql
が消されたので,
# apt-get install at mailx postgresql
とした.
qmailの起動確認
以下で起動する.
# /etc/init.d/qmail start
するとsyslogに
warning: dropping connection, unable to read /etc/tcp.smtp.cdb: file does not exist
とか出た. そこで,
# /etc/init.d/qmail cdb
Rebuilding tcp.smtp.cdb.
# ls /etc/tcp.smtp.cdb
/etc/tcp.smtp.cdb
再起動すると直った.