roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.79k stars 1.62k forks source link

Change password issue in Virtualmin - Error: Could not save new password. #6092

Closed pankajpragma closed 6 years ago

pankajpragma commented 6 years ago

Hi,

I have installed Roundcube v1.3.3 in Virtualmin version 5.05 and activated "password" plugin by editing "/config/config.inc.php"

# /config/config.inc.php
// List of active plugins (in plugins/ directory)
$config['plugins'] = array(
   'virtuser_file',
    'archive',
    'zipdownload',
    'password',
);

Then rename "/plugins/password/config.inc.php.dist" to "/plugins/password/config.inc.php" and I can see Password reset field in "Roundcube > Settings > Password".

But when I am trying to change password then it shows error: "Error: Could not save new password." It does check the current password so it means that it is able to connect to the database.

I also tried to run following commands from "/plugins/password/helpers" directory:

gcc -o chgvirtualminpasswd chgvirtualminpasswd.c
chown root:<FCGId domain owner user> chgvirtualminpasswd
strip chgvirtualminpasswd
chmod 4550 chgvirtualminpasswd 
# /plugins/password/config.inc.php
$config['password_driver'] = 'virtualmin';

But it is still showing the same error. Can anyone please help?

alecpl commented 6 years ago

Any errors in log? See plugins/password/drivers/virtualmin.php file for example commands and execute them by hand.

pankajpragma commented 6 years ago

After further investigation, I found that "chgvirtualminpasswd" is not executing:

Log: Password plugin: Unable to execute plugins/password/helpers/chgvirtualminpasswd

I tried all possibilities to fix it permission but it is still not working:

chown root.<domain owner user> plugins/password/helpers/chgvirtualminpasswd
chown root:<domain owner user> plugins/password/helpers/chgvirtualminpasswd
chown <domain owner user>:<domain owner user> plugins/password/helpers/chgvirtualminpasswd

chmod 0755 plugins/password/helpers/chgvirtualminpasswd
chmod 0777 plugins/password/helpers/chgvirtualminpasswd

I tried to execute the file using php exec() and it shows error "/usr/sbin/virtualmin must be run as root"

echo exec('plugins/password/helpers/chgvirtualminpasswd');

I am using Ubuntu 16.04.

pankajpragma commented 6 years ago

SOLVED:

After banging my head against the wall, finally, I could FIX it

Output of this line was:

# /plugins/password/drivers/virtualmin.php
exec("$curdir/chgvirtualminpasswd modify-user --domain $domain --user $username --pass $newpass", $output, $returnvalue);

plugins/password/helpers/chgvirtualminpasswd modify-user --domain 'localhost' --user 'testmail-example.com' --pass 'testmail123'

Where User format is wrong. So I have manually added a lines bellow it "$username = $_SESSION['username']" to replace "-" with "@":

$username = $_SESSION['username'];
$username = str_replace("-", "@", $username);

And it's been FIXED....

Notes: I also had to adjust the chown & chmod as per suggested in README:

gcc -o plugins/password/helpers/chgvirtualminpasswd plugins/password/helpers/chgvirtualminpasswd.c
chown root:doman_user plugins/password/helpers/chgvirtualminpasswd
chmod 4550 plugins/password/helpers/chgvirtualminpasswd

General Query Why didn't it manage to change the user email format even if I had specified it in config file:

# /plugins/password/config.inc.php 
$rcmail_config['password_virtualmin_format'] = 0;

Is this a bug Or did I add it in wrong place?

@alecpl Thanks for your help.

alecpl commented 6 years ago

Where did you find password_virtualmin_format option? It does not exist.

pankajpragma commented 6 years ago

I could found it while Googling and also it was written at the top of the /plugins/password/drivers/virtualmin.php file so I thought I should try to set it in the config file but unfortunately it didn't work and I had to overwrite $username = $_SESSION['username']; $username = str_replace("-", "@", $username);

class rcube_virtualmin_password
{
    function save($currpass, $newpass)
    {
        $rcmail   = rcmail::get_instance();
        $format   = $rcmail->config->get('password_virtualmin_format', 0);
        $username = $_SESSION['username'];
alecpl commented 6 years ago

Ah, the option has been removed here https://github.com/roundcube/roundcubemail/pull/5759. I'm closing this ticket.