LoginSignup
1
0

More than 5 years have passed since last update.

FreeBSD + OpenSMTPD 6.0.2

Last updated at Posted at 2016-12-25

FreeBSD に OpenSMTPD 6.0.2 をインストールしてみたのでメモ。

環境

  1. FreeBSD 11.0 (VirtualBox)

方針

  1. OpenSMTPD 6.0.2 が出てから 2 ヶ月以上経ってるのに、
  2. FreeBSD ports の mail/opensmtpd は 5.9.2p1 のまま。
  3. 仕方がないので Portable version を自分でビルドする。
  4. ports/mail/opensmtpd を参考に。

OpenSMTPD インストール

  1. libevent 2.0.22_1, libressl 2.4.3, libasr 1.0.2 をインストール

    % sudo pkg install libevent2 libressl libasr
    
    1. libasr は OpenSMTPD の asynchronous resolver library
  2. opensmtpd 6.0.2 をインストール

    % fetch --no-verify-peer https://www.opensmtpd.org/archives/opensmtpd-6.0.2p1.tar.gz
    % tar xzf opensmtpd-6.0.2p1.tar.gz
    % cd opensmtpd-6.0.2p1
    % ./configure --with-libasr=/usr/local --with-libssl=/usr/local --sysconfdir=/usr/local/etc/mail --mandir=/usr/local/man | & tee configure.log
    % make |& tee make.log
    % sudo make install |& tee make-install.log
    
    1. ports/mail/opensmtpd と同じディレクトリ構造にするために --sysconfdir--mandir を指定
    2. configure 出力の末尾

      OpenSMTPD has been configured with the following options:
                   User binaries: /usr/local/bin
                 System binaries: /usr/local/sbin
             Configuration files: /usr/local/etc/mail
              mail.local program: /usr/local/libexec/opensmtpd/mail.local
                 encrypt program: /usr/local/libexec/opensmtpd/encrypt
                    Manual pages: /usr/local/man/manX
                  smtpd.sock dir: /var/run
      Privilege separation chroot path: /var/empty
                  Manpage format: doc
              Package libexecdir: ${exec_prefix}/libexec/opensmtpd
                     PAM support: no
                BSD Auth support: no
      
  1. ユーザーを追加

    % sudo pw useradd _smtpd -c "SMTP Daemon" -d /var/empty -s /sbin/nologin
    % sudo pw useradd _smtpq -c "SMTPD Queue" -d /var/empty -s /sbin/nologin
    
  2. mailwrapper 設定を変更

    1. mail/opensmtpd/files/pkg-install.in と同様に /etc/mail/mailer.conf の内容を以下で上書き
    sendmail        /usr/local/sbin/smtpctl
    send-mail       /usr/local/sbin/smtpctl
    mailq           /usr/local/sbin/smtpctl
    makemap         /usr/local/libexec/opensmtpd/makemap
    newaliases      /usr/local/libexec/opensmtpd/makemap
    
  3. sendmail を無効に

    1. 停止

      % sudo service sendmail stop
      
    2. man rc.sendmail に従って /etc/rc.conf に以下を追加

    sendmail_enable="NO"
    sendmail_submit_enable="NO"
    sendmail_outbound_enable="NO"
    sendmail_msp_queue_enable="NO"
    
  1. 起動

    1. ports の rc スクリプトを利用

      % sudo mkdir /usr/local/etc/rc.d
      % sudo sh -c "sed 's/%%PREFIX%%/\/usr\/local/g' /usr/ports/mail/opensmtpd/files/smtpd.in > /usr/local/etc/rc.d/smtpd"
      % sudo chmod +x /usr/local/etc/rc.d/smtpd
      
      1. %%PREFIX%%/usr/local に置換
    2. 起動

      % sudo service smtpd start
      
    3. FreeBSD 起動時に自動起動

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

        smtpd_enable="YES"
        
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0