- blogs:
- cles::blog
2014/05/28

CentOS 6 + Postfix + MySQL + postfixadmin + Dovecot をインストール(その3)



今日は IMAP/POP3 サーバである Dovecot 側の設定に入ります。
Dovecot は設定が簡単なサーバですが、今回は MySQL と接続するための設定をしなければならないので多少手順が煩雑です。
今回のキモは通常平文で保存されているパスワードを前回 AES で暗号化してしまったので、取り出すときに復号化するようなクエリを書く必要があることでしょうか。
具体的にには下記のような定義ファイルを用意しました。
/etc/dovecot/dovecot-sql.conf.ext
driver = mysql
default_pass_scheme = PLAIN
connect = dbname=postfix user=postfix host=/var/lib/mysql/mysql.sock password=#####MYSQL_PASS#####
password_query = SELECT AES_DECRYPT(FROM_BASE64(password),'####AES_PASS####') as password FROM mailbox WHERE username = '%u' AND active = '1'
user_query = SELECT concat('/var/vmail/', maildir) as home, 1000 as uid, 1000 as gid FROM mailbox WHERE username = '%u' AND active = '1'
以下、設定メモ。
† Dovecot の設定変更
Dovecot の設定ファイルはすべて /etc/dovecot 以下にあるので、これらを順に変更していきます。
終了したら dovecot のデーモンを再起動しておきます。
/etc/dovecot/dovecot.conf
--- dovecot.conf.org 2010-12-30 18:42:54.000000000 +0900
+++ dovecot.conf 2014-05-26 17:42:06.575259629 +0900
@@ -18,6 +18,7 @@
# Protocols we want to be serving.
#protocols = imap pop3 lmtp
+protocols = imap pop3
# A comma separated list of IPs or hosts where to listen in for connections.
/etc/dovecot/conf.d/10-auth.conf
--- conf.d/10-auth.conf.org 2010-06-26 10:11:29.000000000 +0900
+++ conf.d/10-auth.conf 2014-05-26 17:30:41.273262273 +0900
@@ -94,7 +94,7 @@
# plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey
# gss-spnego
# NOTE: See also disable_plaintext_auth setting.
-auth_mechanisms = plain
+auth_mechanisms = plain login digest-md5 cram-md5
##
## Password and user databases
@@ -116,8 +116,8 @@
#!include auth-deny.conf.ext
#!include auth-master.conf.ext
-!include auth-system.conf.ext
-#!include auth-sql.conf.ext
+#!include auth-system.conf.ext
+!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
/etc/dovecot/conf.d/10-mail.conf
--- conf.d/10-mail.conf.org 2013-11-23 00:09:03.000000000 +0900
+++ conf.d/10-mail.conf 2014-05-31 17:05:13.889024508 +0900
@@ -27,7 +27,7 @@
#
# <doc/wiki/MailLocation.txt>
#
-#mail_location =
+mail_location = maildir:/var/vmail/%d/%n
# If you need to set multiple mailbox locations or want to change default
# namespace settings, you can do it by defining namespace sections.
@@ -164,14 +164,14 @@
# to make sure that users can't log in as daemons or other system users.
# Note that denying root logins is hardcoded to dovecot binary and can't
# be done even if first_valid_uid is set to 0.
-#first_valid_uid = 500
+first_valid_uid = 1000
#last_valid_uid = 0
# Valid GID range for users, defaults to non-root/wheel. Users having
# non-valid GID as primary group ID aren't allowed to log in. If user
# belongs to supplementary groups with non-valid GIDs, those groups are
# not set.
-#first_valid_gid = 1
+first_valid_gid = 1000
#last_valid_gid = 0
# Maximum allowed length for mail keyword name. It's only forced when trying
/etc/dovecot/conf.d/10-master.conf
--- conf.d/10-master.conf.org 2010-12-30 18:42:54.000000000 +0900
+++ conf.d/10-master.conf 2014-05-26 17:40:31.742260974 +0900
@@ -85,9 +85,12 @@
}
# Postfix smtp-auth
- #unix_listener /var/spool/postfix/private/auth {
- # mode = 0666
- #}
+ unix_listener /var/spool/postfix/private/auth {
+ mode = 0660
+ # Assuming the default Postfix user and group
+ user = postfix
+ group = postfix
+ }
# Auth process is run as this user.
#user = $default_internal_user
/etc/dovecot/conf.d/20-pop3.conf
--- conf.d/20-pop3.conf.org 2010-12-30 18:42:54.000000000 +0900
+++ conf.d/20-pop3.conf 2014-05-26 17:33:47.098259514 +0900
@@ -48,7 +48,7 @@
# Dovecot's default, so if you're building a new server it would be a good
# idea to change this. %08Xu%08Xv should be pretty fail-safe.
#
- #pop3_uidl_format = %08Xu%08Xv
+ pop3_uidl_format = %08Xu%08Xv
# Permanently save UIDLs sent to POP3 clients, so pop3_uidl_format changes
# won't change those UIDLs. Currently this works only with Maildir.
次回で Postfix の設定を済ませれば構築は完了です。
トラックバックについて
Trackback URL:
お気軽にどうぞ。トラックバック前にポリシーをお読みください。[policy]
このエントリへのTrackbackにはこのURLが必要です→https://blog.cles.jp/item/6752
Trackbacks
このエントリにトラックバックはありません
Comments
愛のあるツッコミをお気軽にどうぞ。[policy]
古いエントリについてはコメント制御しているため、即時に反映されないことがあります。
古いエントリについてはコメント制御しているため、即時に反映されないことがあります。
コメントはありません
Comments Form
コメントは承認後の表示となります。
OpenIDでログインすると、即時に公開されます。
OpenID を使ってログインすることができます。
サイト内検索
検索ワードランキング
へぇが多いエントリ
閲覧数が多いエントリ
1 . アーロンチェアのポスチャーフィットを修理(112160)
2 . 福岡銀がデマの投稿者への刑事告訴を検討中(110795)
3 . 年次の人間ドックへ(110386)
4 . 2023 年分の確定申告完了!(1つめ)(109934)
5 . 三菱鉛筆がラミーを買収(109834)
2 . 福岡銀がデマの投稿者への刑事告訴を検討中(110795)
3 . 年次の人間ドックへ(110386)
4 . 2023 年分の確定申告完了!(1つめ)(109934)
5 . 三菱鉛筆がラミーを買収(109834)
cles::blogについて
Referrers