LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   posftix, dovecot and mysql - auth failed after updating MySql (https://www.linuxquestions.org/questions/linux-server-73/posftix-dovecot-and-mysql-auth-failed-after-updating-mysql-4175685072/)

ddaas 11-11-2020 03:25 PM

posftix, dovecot and mysql - auth failed after updating MySql
 
Hello,
I'm running Ubuntu 20.04 with Posftix, Dovecot and Mysql (latest versions).
The config worked, but with the latest version of MySQL the ENCRYPT function was deprecated.

Now I have in /etc/dovecot/dovecot-sql.conf:

Code:

driver = mysql
connect = host=127.0.0.1 dbname=mail user=mail_admin password=mail_admin_password
default_pass_scheme = SHA512-CRYPT
password_query = SELECT email as user, password FROM users WHERE email='%u';

I'm inserting domains and users like this:
Code:

msyql> USE mail;
msyql>INSERT INTO domains (domain) VALUES ('mydomain.com');
mysql>INSERT INTO users (email,password) values('u1@mydomain.com',sha2('mypassword', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))));
mysql>quit;

The user table was created like this:
Code:

mysql> CREATE TABLE users (email varchar(80) NOT NULL, password varchar(256) NOT NULL, PRIMARY KEY (email) );
msyql> CREATE TABLE domains (domain varchar(50) NOT NULL, PRIMARY KEY (domain) );

The only error I'm getting in the logs is:
dovecot: imap-login: Disconnected (auth failed, 2 attempts in 8 secs): user=<u1@mydomain.com>, method=PLAIN, rip=5.12.x.y, lip=206.81.x.y, TLS, session=<uBerVtuzNOkFDENS>

Any idea? What could I do?
I'm sure there is something related to the way I'm inserting the password in the db and how dovecot is reading it.
I've spent the entire day with this :((

ddaas 11-11-2020 03:42 PM

I've got a workaround running doveadm pw -s SHA512-CRYPT and inserting the string including what's inside the curly braces in the password field.
But I don't think this is the best solution.
Maybe someone has a better solution.


All times are GMT -5. The time now is 05:53 PM.