При настройка указанной связки возникла проблема с тем, что не могу авторизоваться на POP3/IMAP, хотя в debian при похожих конфигах работало на ура. В чем косяк - ума не приложу. Отключение SELinux не помогает. Вот что происходит:
telnet 1.2.3.4 110
Trying 1.2.3.4...
Connected to 1.2.3.4.
Escape character is '^]'.
+OK Dovecot ready.
user admin@xxx.ru
+OK
pass asdasd
-ERR Authentication failed.в логах dovecot:
auth: Info: mysql: Connected to 127.0.0.1 (mail)
pop3-login: Info: Aborted login (auth failed, 1 attempts): user=<admin@xxx.ru>, method=PLAIN, rip=1.2.3.4, lip=1.2.3.4, securedДоступ к БД есть. Пользователя создавал вот таким запросом:
INSERT INTO `users` (`email`, `password`, `quota`) VALUES ('admin@xxx.ru', MD5('asdasd'), '100M')В dovecot.conf (вырезка):
protocol imap {
mail_plugins = quota imap_quota
}
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
mail_plugins = quota
}
auth_mechanisms = plain
passdb {
driver = pam
}
userdb {
driver = static
args = uid=500 gid=500 home=/home/vmail/%d/%n allow_all_users=yes
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
unix_listener auth-master {
group = vmail
mode = 0660
user = vmail
}
user = $default_internal_user
}
содержание dovecot-sql.conf:
driver = mysql
connect = host=127.0.0.1 user=mail_admin password=password dbname=mail
default_pass_scheme = MD5
user_query = SELECT email AS user, CONCAT('/home/vmail/',CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1))) AS home, concat('*:storage=', quota) as quota_rule FROM users WHERE email='%u'
Смотри какой запрос идет в MySQL, в логе queries , при попытке авторизоваться.
auth_debug=yes
auth_debug_passwords=yes
> auth_debug=yes
> auth_debug_passwords=yesСпасибо за наводку. заработало.
В dovecot.conf закомментировал
passdb {
driver = pam
}и прописал
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}в dovecot-sql.conf добавил строчку
password_query = SELECT email AS user,password AS password FROM users WHERE email='%u'
На VDS стоит Ubuntu 12.10+Postfix+Dovecot 2.1.7+Postfixadmin.Dovecot не может авторизоваться в mysql
Я человек неопытный, английского не знаю, манов по второму Dovecotу практически нет. Вобщем кое-как методом тыка настроил. Thunderbird настройки сервера получает, однако войти никак не может.
Вот мой dovecot -n
# 2.1.7: /etc/dovecot/dovecot.conf
# OS: Linux 3.5.0-25-generic i686 Ubuntu 12.10 ext3
auth_debug = yes
auth_debug_passwords = yes
auth_mechanisms = plain login
auth_socket_path = /var/run/dovecot/auth-master
auth_verbose = yes
base_dir = /var/run/dovecot/
debug_log_path = /var/log/degug_dovecotlog
disable_plaintext_auth = no
lda_mailbox_autocreate = yes
log_path = /var/log/dovecotlog
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_debug = yes
mail_location = maildir:/home/vmail/%d/%n
mail_privileged_group = vmail
namespace {
inbox = yes
location =
prefix = INBOX.
separator = .
type = private
}
passdb {
driver = pam
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
postmaster_address = postmaster@da.rs
protocols = imap pop3
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
unix_listener auth-master {
mode = 0600
user = vmail
}
user = root
}
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem
userdb {
driver = passwd
}
userdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
verbose_ssl = yes
protocol lda {
log_path = /home/vmail/dovecot-deliver.log
}
protocol pop3 {
pop3_uidl_format = XuXv
}Вот dovecot-sql.conf.ext
driver = mysql
connect = host=127.0.0.1 dbname=mailserver user=mailuser password=пароль
default_pass_scheme = PLAIN-MD5
password_query = SELECT email as user, password FROM view_users WHERE email='%u';Вот degug_dovecotlog
2013-03-19 00:00:42 auth-worker(3783): Debug: sql(postmaster,109.93.97.123): query: SELECT email as user, password FROM view_users WHERE email='postmaster';
2013-03-19 00:00:44 auth: Debug: client out: FAIL 7 user=postmaster
2013-03-19 00:00:44 auth: Debug: client in: AUTH 8 LOGIN service=imap secured session=KUow8zrYJgBtXWF7 lip=78.47.11.221 rip=109.93.97.123 lport=143 rport=57126
2013-03-19 00:00:44 auth: Debug: client out: CONT 8 VXNlcm5hbWU6
2013-03-19 00:00:44 auth: Debug: client in: CONT 8 cG9zdG1hc3Rlcg==
2013-03-19 00:00:44 auth: Debug: client out: CONT 8 UGFzc3dvcmQ6
2013-03-19 00:00:44 auth: Debug: client in: CONT 8 S2lMX1MtMTUubWFzdGVy
2013-03-19 00:00:44 auth-worker(3783): Debug: pam(postmaster,109.93.97.123): lookup service=dovecot
2013-03-19 00:00:44 auth-worker(3783): Debug: pam(postmaster,109.93.97.123): #1/1 style=1 msg=Password:
2013-03-19 00:00:47 auth-worker(3783): Debug: sql(postmaster,109.93.97.123): query: SELECT email as user, password FROM view_users WHERE email='postmaster';
2013-03-19 00:00:49 auth: Debug: client out: FAIL 8 user=postmaster
2013-03-19 00:00:49 auth: Debug: client in: AUTH 9 PLAIN service=imap secured session=KUow8zrYJgBtXWF7 lip=78.47.11.221 rip=109.93.97.123 lport=143 rport=57126 resp=AHBvc3RtYXN0ZXIAS2lMX1MtMTUubWFzdGVy
2013-03-19 00:00:49 auth-worker(3783): Debug: pam(postmaster,109.93.97.123): lookup service=dovecot
2013-03-19 00:00:49 auth-worker(3783): Debug: pam(postmaster,109.93.97.123): #1/1 style=1 msg=Password:
2013-03-19 00:00:51 auth-worker(3783): Debug: sql(postmaster,109.93.97.123): query: SELECT email as user, password FROM view_users WHERE email='postmaster';
2013-03-19 00:00:53 auth: Debug: client out: FAIL 9 user=postmasterВот dovecotlog
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x2001, ret=1: SSLv3 read client key exchange A [109.93.97.123]
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x2001, ret=1: SSLv3 read finished A [109.93.97.123]
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x2001, ret=1: SSLv3 write session ticket A [109.93.97.123]
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x2001, ret=1: SSLv3 write change cipher spec A [109.93.97.123]
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x2001, ret=1: SSLv3 write finished A [109.93.97.123]
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x2001, ret=1: SSLv3 flush data [109.93.97.123]
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x20, ret=1: SSL negotiation finished successfully [109.93.97.123]
2013-03-19 00:00:06 imap-login: Warning: SSL: where=0x2002, ret=1: SSL negotiation finished successfully [109.93.97.123]
2013-03-19 00:00:06 auth-worker(3783): Info: mysql(127.0.0.1): Connected to database mailserver
2013-03-19 00:00:08 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:08 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:16 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:16 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:24 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:24 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:30 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:30 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:34 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:34 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:37 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:37 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:42 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:42 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:47 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:47 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:00:51 auth-worker(3783): Info: pam(postmaster,109.93.97.123): pam_authenticate() failed: Authentication failure (password mismatch?) (given password: правильный пароль)
2013-03-19 00:00:51 auth-worker(3783): Info: sql(postmaster,109.93.97.123): unknown user
2013-03-19 00:02:33 imap-login: Warning: SSL alert: where=0x4004, ret=256: warning close notify [109.93.97.123]
2013-03-19 00:02:33 imap-login: Warning: SSL alert: where=0x4008, ret=256: warning close notify [109.93.97.123]
2013-03-19 00:02:33 imap-login: Info: Disconnected (auth failed, 9 attempts in 147 secs): user=<postmaster>, method=PLAIN, rip=109.93.97.123, lip=78.47.11.221, TLS, session=<KUow8zrYJgBtXWF7>Прошу помощи уважаемого сообщества.
>[оверквотинг удален]
> 2013-03-19 00:02:33 imap-login: Warning: SSL alert: where=0x4004, ret=256:
> warning close notify [109.93.97.123]
> 2013-03-19 00:02:33 imap-login: Warning: SSL alert: where=0x4008, ret=256:
> warning close notify [109.93.97.123]
> 2013-03-19 00:02:33 imap-login: Info: Disconnected (auth failed, 9
> attempts in 147 secs): user=<postmaster>, method=PLAIN, rip=109.93.97.123, lip=78.47.11.221,
> TLS, session=<KUow8zrYJgBtXWF7>
> Сделал auth_debug=yes и auth_debug_passwords=yes. В dovecotlog, degug_dovecotlog и syslog
> ничего не записалось.
> Прошу помощи уважаемого сообщества.запись
Info: sql(postmaster,109.93.97.123): unknown user
не настораживает?
dovecot не может подключиться к mysql.
и вообще не совсем понятно, каким макаром при конфиге dovecot-sql.conf.ext
connect = host=127.0.0.1 dbname=mailserver user=mailuser password=пароль
в логах появляются записи
Info: sql(postmaster,109.93.97.123)
> запись
> Info: sql(postmaster,109.93.97.123): unknown user
> не настораживает?
> dovecot не может подключиться к mysql.Так я об этом и написал. А почему? Где копать?
> и вообще не совсем понятно, каким макаром при конфиге dovecot-sql.conf.ext
> connect = host=127.0.0.1 dbname=mailserver user=mailuser password=пароль
> в логах появляются записи
> Info: sql(postmaster,109.93.97.123)Не знаю. 109.93.97.123 - это мой ip, с которого tunderbirdом пытаюсь подключиться.
Вобщем, получается полная фигня. Базу мускул я уже переустановил. Результата ноль.Дебаг говорит тоже самое query: SELECT email as user, password FROM view_users WHERE email='info@da.rs';
mysql> show tables;
+----------------------+
| Tables_in_mailserver |
+----------------------+
| view_aliases |
| view_users |
| virtual_aliases |
| virtual_domains |
| virtual_users |
+----------------------+
5 rows in set (0.00 sec)если так - mysql> select * from view_users;
+------------------+----------------------------------+
| email | password |
+------------------+----------------------------------+
| postmaster@da.rs | cbbf5567f695d9e8e3c2a8af6ec98ba5 |
| info@da.rs | 8d07927bf341290b5589321883bc2545 |
+------------------+----------------------------------+а вот так mysql> SELECT email as user, password FROM view_users WHERE email='info';
Empty set (0.00 sec)Почему так?
>view_users WHERE email='info';Может быть, должно быть email=info@da.rs ?
>>view_users WHERE email='info';
> Может быть, должно быть email=info@da.rs ?Да, но degug_dovecotlog показывает через раз то 'info' то 'info@da.rs'
2013-03-23 06:24:59 auth: Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth
2013-03-23 06:24:59 auth: Debug: Module loaded: /usr/lib/dovecot/modules/auth/libdriver_mysql.so
2013-03-23 06:24:59 auth: Debug: auth client connected (pid=1466)
2013-03-23 06:24:59 auth: Debug: client in: AUTH 1 PLAIN service=imap secured session=5W4Hy5DYiwBtXTEY lip=78.47.11.221 rip=109.93.49.24 lport=143 rport=60299
2013-03-23 06:24:59 auth: Debug: client out: CONT 1
2013-03-23 06:25:00 auth: Debug: client in: CONT 1 AGluZm8AS2lMX1MtMTUuaW5mbw==
2013-03-23 06:25:00 auth-worker(1471): Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth
2013-03-23 06:25:00 auth-worker(1471): Debug: Module loaded: /usr/lib/dovecot/modules/auth/libdriver_mysql.so
2013-03-23 06:25:00 auth-worker(1471): Debug: sql(info,109.93.49.24): query: SELECT email as user, password FROM view_users WHERE email='info';
2013-03-23 06:25:02 auth: Debug: client out: FAIL 1 user=info
2013-03-23 06:25:02 auth: Debug: client in: AUTH 2 LOGIN service=imap secured session=5W4Hy5DYiwBtXTEY lip=78.47.11.221 rip=109.93.49.24 lport=143 rport=60299
2013-03-23 06:25:06 auth: Debug: client out: CONT 2 VXNlcm5hbWU6
2013-03-23 06:25:06 auth: Debug: client in: CONT 2 aW5mbw==
2013-03-23 06:25:06 auth: Debug: client out: CONT 2 UGFzc3dvcmQ6
2013-03-23 06:25:06 auth: Debug: client in: CONT 2 S2lMX1MtMTUuaW5mbw==
2013-03-23 06:25:06 auth-worker(1471): Debug: sql(info,109.93.49.24): query: SELECT email as user, password FROM view_users WHERE email='info';
2013-03-23 06:25:08 auth: Debug: client out: FAIL 2 user=info
2013-03-23 06:25:08 auth: Debug: client in: AUTH 3 PLAIN service=imap secured session=5W4Hy5DYiwBtXTEY lip=78.47.11.221 rip=109.93.49.24 lport=143 rport=60299 resp=AGluZm8AS2lMX1MtMTUuaW5mbw==
2013-03-23 06:25:12 auth-worker(1471): Debug: sql(info,109.93.49.24): query: SELECT email as user, password FROM view_users WHERE email='info';
2013-03-23 06:25:14 auth: Debug: client out: FAIL 3 user=info
2013-03-23 06:25:14 auth: Debug: auth client connected (pid=1631)
2013-03-23 06:25:14 auth: Debug: client in: AUTH 1 PLAIN service=imap secured session=X2Lmy5DYjABtXTEY lip=78.47.11.221 rip=109.93.49.24 lport=143 rport=60300
2013-03-23 06:25:18 auth: Debug: client out: CONT 1
2013-03-23 06:25:18 auth: Debug: client in: CONT 1 AGluZm9AZGEucnMAS2lMX1MtMTUuaW5mbw==
2013-03-23 06:25:18 auth-worker(1471): Debug: sql(info@da.rs,109.93.49.24): query: SELECT email as user, password FROM view_users WHERE email='info@da.rs';
2013-03-23 06:25:18 auth: Debug: client out: OK 1 user=info@da.rs
2013-03-23 06:25:18 auth: Debug: master in: REQUEST 4237557761 1631 1 18669b765f8acadee4e70db960d79651
2013-03-23 06:25:18 auth-worker(1471): Debug: sql(info@da.rs,109.93.49.24): SELECT home, uid, gid FROM users WHERE username = 'info' AND domain = 'da.rs'
2013-03-23 06:25:18 auth: Debug: master out: FAIL 4237557761
2013-03-23 06:25:18 auth: Debug: auth client connected (pid=1700)
2013-03-23 06:25:18 auth: Debug: client in: AUTH 1 PLAIN service=imap secured session=I04pzJDYjgBtXTEY lip=78.47.11.221 rip=109.93.49.24 lport=143 rport=60302
2013-03-23 06:25:18 auth: Debug: client out: CONT 1
2013-03-23 06:25:19 auth: Debug: client in: CONT 1 AGluZm9AZGEucnMAS2lMX1MtMTUuaW5mbw==
2013-03-23 06:25:19 auth-worker(1471): Debug: sql(info@da.rs,109.93.49.24): query: SELECT email as user, password FROM view_users WHERE email='info@da.rs';
2013-03-23 06:25:19 auth: Debug: client out: OK 1 user=info@da.rs
2013-03-23 06:25:19 auth: Debug: master in: REQUEST 659161089 1700 1 9347ef320b66d5e90f4b861a69c65dba
2013-03-23 06:25:19 auth-worker(1471): Debug: sql(info@da.rs,109.93.49.24): SELECT home, uid, gid FROM users WHERE username = 'info' AND domain = 'da.rs'
2013-03-23 06:25:19 auth: Debug: master out: FAIL 659161089вот что получается:
mysql> SELECT email as user, password FROM view_users WHERE email='info';
Empty set (0.00 sec)mysql> SELECT email as user, password FROM view_users WHERE email='info@da.rs';
+------------+----------------------------------+
| user | password |
+------------+----------------------------------+
| info@da.rs | 8d07927bf341290b5589321883bc2545 |
+------------+----------------------------------+
1 row in set (0.00 sec)mysql> SELECT home, uid, gid FROM users WHERE username = 'info' AND domain = 'da.rs';
ERROR 1146 (42S02): Table 'mailserver.users' doesn't existОткуда он взял table 'mailserver.users'?
>[оверквотинг удален]
>
> |
> +------------+----------------------------------+
> | info@da.rs | 8d07927bf341290b5589321883bc2545 |
> +------------+----------------------------------+
> 1 row in set (0.00 sec)
> mysql> SELECT home, uid, gid FROM users WHERE username = 'info' AND
> domain = 'da.rs';
> ERROR 1146 (42S02): Table 'mailserver.users' doesn't exist
> Откуда он взял table 'mailserver.users'?Оттуда, откуда и вы. У вас есть таблица users??
в листинге в постах выше я видел такой вывод:
mysql> show tables;
+----------------------+
| Tables_in_mailserver |
+----------------------+
| view_aliases |
| view_users |
| virtual_aliases |
| virtual_domains |
| virtual_users |
+----------------------+
5 rows in set (0.00 sec)Т.е. в вместо FROM users должно быть FROM virtual_users, вместо WHERE username = 'info' должно быть WHERE username LIKE 'info%' при условии, что таблица virtual_users существует в базе и в ней есть поля home, uid, gid, domain, причем поле domain по крайней мере в одной строке таблицы должно содержжать значение 'da.rs'
>[оверквотинг удален]
>
> |
> +------------------+----------------------------------+
> | postmaster@da.rs | cbbf5567f695d9e8e3c2a8af6ec98ba5 |
> | info@da.rs | 8d07927bf341290b5589321883bc2545 |
> +------------------+----------------------------------+
> а вот так mysql> SELECT email as user, password FROM view_users WHERE
> email='info';
> Empty set (0.00 sec)
> Почему так?потому что должно быть WHERE email LIKE 'info%'
> потому что должно быть WHERE email LIKE 'info%'mysql> select * from virtual_users;
+----+-----------+------------+----------------------------------+
| id | domain_id | user | password |
+----+-----------+------------+----------------------------------+
| 1 | 1 | postmaster | cbbf5567f695d9e8e3c2a8af6ec98ba5 |
| 2 | 1 | info | 8d07927bf341290b5589321883bc2545 |
+----+-----------+------------+----------------------------------+
2 rows in set (0.00 sec)mysql> SELECT email as user, password FROM view_users WHERE email LIKE 'info';
Empty set (0.00 sec)Потом, я же не сам рисовал таблицы в базах и конфиги. Всё в строгом соответствии с манами.
>[оверквотинг удален]
> 1 | postmaster | cbbf5567f695d9e8e3c2a8af6ec98ba5 |
> | 2 |
> 1 | info | 8d07927bf341290b5589321883bc2545
> |
> +----+-----------+------------+----------------------------------+
> 2 rows in set (0.00 sec)
> mysql> SELECT email as user, password FROM view_users WHERE email LIKE 'info';
> Empty set (0.00 sec)
> Потом, я же не сам рисовал таблицы в базах и конфиги. Всё
> в строгом соответствии с манами.;D - под столом)))
mysql> select * from virtual_users;
mysql> SELECT email as user, password FROM view_users WHERE email LIKE 'info';найди одно отличие))
> найди одно отличие))Перепутал, когда копировал.
mysql> select * from view_users;
+------------------+----------------------------------+
| email | password |
+------------------+----------------------------------+
| postmaster@da.rs | cbbf5567f695d9e8e3c2a8af6ec98ba5 |
| info@da.rs | 8d07927bf341290b5589321883bc2545 |
+------------------+----------------------------------+
2 rows in set (0.00 sec)mysql> SELECT email as user, password FROM view_users WHERE email LIKE 'info';
Empty set (0.00 sec)
>[оверквотинг удален]
> | password
>
> |
> +------------------+----------------------------------+
> | postmaster@da.rs | cbbf5567f695d9e8e3c2a8af6ec98ba5 |
> | info@da.rs | 8d07927bf341290b5589321883bc2545 |
> +------------------+----------------------------------+
> 2 rows in set (0.00 sec)
> mysql> SELECT email as user, password FROM view_users WHERE email LIKE 'info';
> Empty set (0.00 sec))))
WHERE email LIKE 'info%';
или
WHERE email='info@da.rs';