FreeBSD 14.3 RELEASE - postfix - Dovecot


クラウディア 


1. 概要
2. インストール
3. インストール時のメッセージ
4. 設定
5. 起動設定
6. トラブルシュート

1. 概要

 「pop」や「imap」には、「Dovecot」というプログラムを使用します。  すべて、「root」ユーザ権限で。

2. インストール


cd /usr/ports/mail/dovecot

make config
 下記が、デフォルトのオプションになります。

 ようわからんのですが、これまた、もしかしたら使うかもしれないので、「MYSQL」「PGSQL」のチェックだけいれておきます。
 後で、変えるかもしれません。


make NO_DIALOG=yes

make install
 インストール時点で、下記のフォルダ、ファイルが作成されています。

/usr/local/etc/dovecot/
|-- example-config
|   |-- conf.d
|   |   |-- 10-auth.conf
|   |   |-- 10-director.conf
|   |   |-- 10-logging.conf
|   |   |-- 10-mail.conf
|   |   |-- 10-master.conf
|   |   |-- 10-metrics.conf
|   |   |-- 10-ssl.conf
|   |   |-- 15-lda.conf
|   |   |-- 15-mailboxes.conf
|   |   |-- 20-imap.conf
|   |   |-- 20-lmtp.conf
|   |   |-- 20-pop3.conf
|   |   |-- 20-submission.conf
|   |   |-- 90-acl.conf
|   |   |-- 90-plugin.conf
|   |   |-- 90-quota.conf
|   |   |-- auth-checkpassword.conf.ext
|   |   |-- auth-deny.conf.ext
|   |   |-- auth-dict.conf.ext
|   |   |-- auth-ldap.conf.ext
|   |   |-- auth-master.conf.ext
|   |   |-- auth-passwdfile.conf.ext
|   |   |-- auth-sql.conf.ext
|   |   |-- auth-static.conf.ext
|   |   `-- auth-system.conf.ext
|   |-- dovecot-dict-auth.conf.ext
|   |-- dovecot-dict-sql.conf.ext
|   |-- dovecot-ldap.conf.ext
|   |-- dovecot-oauth2.conf.ext
|   |-- dovecot-sql.conf.ext
|   `-- dovecot.conf
`-- README

3. インストール時のメッセージ

 インストール時に下記のメッセージが表示されました。

===>  Installing for dovecot-2.3.21.1_3
===>  Checking if dovecot is already installed
===>   Registering installation for dovecot-2.3.21.1_3
Installing dovecot-2.3.21.1_3...
===> Creating groups
Creating group 'dovecot' with gid '143'
Creating group 'dovenull' with gid '144'
===> Creating users
Creating user 'dovecot' with uid '143'
Creating user 'dovenull' with uid '144'
 You must create the configuration files yourself. Copy them over
 to /usr/local/etc/dovecot and edit them as desired:

        cp -R /usr/local/etc/dovecot/example-config/* \
                /usr/local/etc/dovecot

 The default configuration includes IMAP and POP3 services, will
 authenticate users agains the system's passwd file, and will use
 the default /var/mail/$USER mbox files.

 Next, enable dovecot in /etc/rc.conf:

        dovecot_enable="YES"


 To avoid a risk of mailbox corruption, do not set the
 security.bsd.see_other_uids or .see_other_gids sysctls to 0
 if Dovecot is storing mail for multiple concurrent users (PR 218392).

 Similarly, setting sysctls security.bsd.hardlink_check_uid or
 security.bsd.hardlink_check_gid to 1 might result in non-working
 mailboxes, depending on what mailbox locking mechanism is used
 (PR 242223).

 If you want to be able to search within attachments using the
 decode2text plugin, you'll need to install textproc/catdoc, and
 one of graphics/xpdf or graphics/poppler-utils.


 There are some potentially breaking changes in Dovecot 2.3. If you
 are upgrading from Dovecot 2.2:

   * https://doc.dovecot.org/2.3/installation_guide/upgrading/from-2.2-to-2.3/
   * Merge the configuration file changes from
     /usr/local/etc/dovecot/examples-config/

===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/lib/dovecot/libdovecot.so.0.0.0
/usr/local/lib/dovecot/libdovecot.a(net.o)

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
https://www.dovecot.org/

4. 設定


mkdir -pv /usr/local/etc/dovecot/conf.d

cp -p /usr/local/etc/dovecot/example-config/dovecot.conf /usr/local/etc/dovecot/.

vi /usr/local/etc/dovecot/dovecot.conf
 25行目を。

#protocols = imap pop3 lmtp submission
 下記のように書き換えます。  (「submission」は、設定により残すこともあります)

protocols = imap pop3
 下記の「#」をはずして、コメント解除します。  (「IPv4」のみの場合は、「,」カンマ以降を削除)

#listen = *, ::

cp -p /usr/local/etc/dovecot/example-config/conf.d/10-auth.conf /usr/local/etc/dovecot/conf.d/.

vi /usr/local/etc/dovecot/conf.d/10-auth.conf
 下記の「#」をはずして、「yes」を「no」に変更。  (プレーンテキストでも認証する場合)

#disable_plaintext_auth = yes
 「plain」の後ろに、半角スペースを空けて「login」を追記。  (プレーンテキストでも認証する場合)

auth_mechanisms = plain

cp -p /usr/local/etc/dovecot/example-config/conf.d/10-mail.conf /usr/local/etc/dovecot/conf.d/.

vi /usr/local/etc/dovecot/conf.d/10-mail.conf
 下記の「#」をはずして、下記のように記述。

mail_location = maildir:~/Maildir

cp -p /usr/local/etc/dovecot/example-config/conf.d/10-master.conf /usr/local/etc/dovecot/conf.d/.

vi /usr/local/etc/dovecot/conf.d/10-master.conf
 110~112行を。

  # Postfix smtp-auth
  #unix_listener /var/spool/postfix/private/auth {
  #  mode = 0666
  #}
 下記のように記述。

  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }

cp -p /usr/local/etc/dovecot/example-config/conf.d/10-ssl.conf /usr/local/etc/dovecot/conf.d/.

vi /usr/local/etc/dovecot/conf.d/10-ssl.conf
 12、13行目は、とりあえず、先頭に「#」をつけてコメント化します。  (「SSL/TLS」設定時に変更します)

ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem

cp -p /usr/local/etc/dovecot/example-config/conf.d/auth-system.conf.ext /usr/local/etc/dovecot/conf.d/.
 上記は、そのままにしておくらしい。

vi /etc/pam.d/dovecot
 これは、ログイン用の設定になります。  下記を記述します。

#
#
# PAM configuration for the "dovecot" service
#

# auth
auth            required        pam_unix.so             no_warn try_first_pass

# account
account         required        pam_unix.so
 「dovecot」の設定ファイルを編集したら、下記のコマンドで確認します。

doveconf -n
 エラーがあれば。

# 2.3.21.1 (d492236fa0): /usr/local/etc/dovecot/dovecot.conf
doveconf: Fatal: Error in configuration file /usr/local/etc/dovecot/dovecot.conf line 103: Expecting '{'
 てな、エラーになるはずです。  これは、「/usr/local/etc/dovecot/dovecot.conf」の103行にエラーがあるということですな。  エラーがなければ、デフォルトと違う設定のみ出力されます。  ここまでの設定だと、ほぼ・・・。

# 2.3.21.1 (d492236fa0): /usr/local/etc/dovecot/dovecot.conf
# OS: FreeBSD 14.3-RELEASE amd64
# Hostname: hostname
auth_mechanisms = plain login
mail_location = maildir:~/Maildir
namespace inbox {
  inbox = yes
  location =
  prefix =
}
passdb {
  driver = pam
}
protocols = imap pop3
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
}
ssl_cert = </path/fullchain.pem
ssl_key = # hidden, use -P to show it
userdb {
  driver = passwd
}
 てな表示になるはずです。

5. 起動設定

 「dovecot」の起動を有効化して、起動。

service dovecot enable

service dovecot start

6. トラブルシュート

 当初、「dovecot」を起動したら。

Jul  1 16:51:42 nu dovecot[68051]: master: Error: service(imap-login): listen(*, 143) failed: Address already in use
Jul  1 16:51:42 nu dovecot[68051]: master: Fatal: Failed to start listeners
 てなエラーになりまして。  なんかいな?と調べましたら。

sockstat -4 -l | grep :143

root     portsentry  1631 6   tcp4   *:143                 *:*
 とまぁ。  「portsentry」が、ポートスキャンする悪者を相手しておったですな。

service portsentry stop
 で、いったん、「portsentry」を止めまして。

service dovecot start
 で、無事「dovecot」を起動後。

service portsentry start
 で、収まりがつきました。  一応、これで、送受信は可能です。

AbemaTV 無料体験
健康サポート特集
葬送のフリーレン Prime Video
Amazonギフトカード
それがだいじWi-Fi
ハイスピードプラン