Author Topic: Password plugin configuration issues  (Read 1092 times)

Offline maigonis

  • Newbie
  • *
  • Posts: 5
Password plugin configuration issues
« on: April 01, 2019, 05:36:44 AM »
Hi.

I have setup Roundcube as My mail web client. So far so good, works great, but I have issues whit password plugin. I have setup My mail server according to this tutorial ( https://thomas-leister.de/en/mailserver-debian-stretch/ ) I have Debian server whit Postfix and Dovecot in short whit mysql db for users and aliases. Passwords are crypted on db whit SHA512-CRYPT and prefix {SHA512-CRYPT}.

I'm new to servers and my skills are not that great, but I'm learning. Now My config file is configured like this:

Code: [Select]
// Configure password plugin
$config['password_driver'] = 'sql';
$config['password_db_dsn'] = 'mysql://vmail:maypassword@localhost/vmail';
$config['password_algorithm'] = 'sha512-crypt';
$config['password_algorithm_prefix'] = '{SHA512-CRYPT}';
$config['password_query'] = 'UPDATE accounts SET password=%c WHERE username=%u';

Rouncube logs show Me error when I try to change password:

Quote
DB Error: [1142] UPDATE command denied to user 'vmail'@'localhost' for table 'accounts' (SQL Query: UPDATE accounts SET password='blāblā' WHERE username='a@b.net') in /var/www/mail.host/public/program/lib/Roundcube/rcube_db.php on line 543 (POST /?_task=settings&_action=plugin.password-save)

On phpmyadmin when I change password query is:

Code: [Select]
UPDATE `accounts` SET `password` = '{SHA512-CRYPT}$6$blā//' WHERE `accounts`.`id` = 8;

What I'm doing wrong?
« Last Edit: April 01, 2019, 08:03:29 AM by maigonis »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,309
Re: Password plugin configuration issues
« Reply #1 on: April 01, 2019, 07:45:13 AM »
The %c macro you are using in your query was deprecated in version 4.0 of the password plugin and does not support prefixes. You should use the %P macro instead.

The second part with the username and the account id I have no idea about.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline maigonis

  • Newbie
  • *
  • Posts: 5
Re: Password plugin configuration issues
« Reply #2 on: April 01, 2019, 09:01:00 AM »
The %c macro you are using in your query was deprecated in version 4.0 of the password plugin and does not support prefixes. You should use the %P macro instead.

The second part with the username and the account id I have no idea about.

Tnx for replay, but no luck. I had incorrect permissions setup for db user, but after fixing those I still cant change password. Now I have no error messages in Roundecube logs.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,309
Re: Password plugin configuration issues
« Reply #3 on: April 01, 2019, 10:45:12 AM »
I think if you turn on sql_debug in your main rc config it will log the queries its running so you can check what the plugin is doing.

does roundcube report the password was changed successfully in the UI and does the contents of the row in the database look correct?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline maigonis

  • Newbie
  • *
  • Posts: 5
Re: Password plugin configuration issues
« Reply #4 on: April 02, 2019, 05:19:39 AM »
I think if you turn on sql_debug in your main rc config it will log the queries its running so you can check what the plugin is doing.

does roundcube report the password was changed successfully in the UI and does the contents of the row in the database look correct?

I got back this:

Quote
UPDATE accounts SET password='$6$ypjitjexadagMZ41$0WJe3ZnxLAns1yZJ0c22MDAyTP/GFNkWDxvH74rxc.x.TnFurG0q5RJFilMbVVwXUGu9S6WHTo46pUxNyna/d/' WHERE username='a@b.net';

Rc reports that change was unsuccessful. It seems to not change db to right one and there is no prefix as you sad.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,309
Re: Password plugin configuration issues
« Reply #5 on: April 02, 2019, 05:44:11 AM »
So 2 seperate problems.

1) no prefix. did you change the config of your password query in the plugin to use the %P macro rather than %c?

2) "It seems to not change db to right one" what happens if you run the query manually?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline maigonis

  • Newbie
  • *
  • Posts: 5
Re: Password plugin configuration issues
« Reply #6 on: April 02, 2019, 06:51:46 AM »
So 2 seperate problems.

1) no prefix. did you change the config of your password query in the plugin to use the %P macro rather than %c?

2) "It seems to not change db to right one" what happens if you run the query manually?



1) I was using %p not %P, changed and now prefix is there.

2) It shows that query is competed successfully, but no changed are made. I use phpmyadmin. I have modified query so it looks more similar to phpmyadmin created.

Original string looks like this after I manually change something:

Quote
UPDATE `accounts` SET `password` = '{SHA512-CRYPT}$6$blā' WHERE `accounts`.`id` = 8;

RC log query:

Quote
UPDATE `accounts` SET `password` = '{SHA512-CRYPT}$6$blā' WHERE `accounts`.`username` = 'a@b.net';


Seems like query is the issue as it is not working in phpmyadmin also.


EDIT: I know what the issue is - username. RC tries to insert password in username a@b.net but db table is a part only, whit out @b.net. I don't know how to solve this.

EDIT2: I checked readme and config files and found that there is a macro %l that inserts username in form that i need.  Now issue is that plugin changes password in db, but returns error that is was unsuccessful.
« Last Edit: April 02, 2019, 07:08:57 AM by maigonis »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,309
Re: Password plugin configuration issues
« Reply #7 on: April 02, 2019, 07:07:30 AM »
It sounds like you want %l (small L) - https://github.com/roundcube/roundcubemail/blob/master/plugins/password/config.inc.php.dist#L118. All the available macros are described in the config file.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline maigonis

  • Newbie
  • *
  • Posts: 5
Re: Password plugin configuration issues
« Reply #8 on: April 02, 2019, 07:10:44 AM »
It sounds like you want %l (small L) - https://github.com/roundcube/roundcubemail/blob/master/plugins/password/config.inc.php.dist#L118. All the available macros are described in the config file.

Yes, I found that. I updated previous post about status whit that.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,309
Re: Password plugin configuration issues
« Reply #9 on: April 03, 2019, 07:54:56 AM »
Quote
Now issue is that plugin changes password in db, but returns error that is was unsuccessful.

This is more tricky to answer, I think it could be a few different things. What version of the password plugin are you running? When you change your password you are changing it to a different password than the one you had before, right? because unless MySQL returns `affected rows 1` roundcube will treat it as an error.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…