Roundcube Community Forum

Release Support => Pending Issues => Topic started by: x8 on August 09, 2022, 02:36:11 AM

Title: Password change for users
Post by: x8 on August 09, 2022, 02:36:11 AM
Hello Guys,

I'm newbie regarding installing and configuring Roundcube and mail server.
My configured environment:
Fedora 5.3.7-301.fc31.x86_64
Roundcube Webmail 1.4.6

My problem is wtih password changing. I get the error:
DB: Error: [1305] FUNCTION roundcube.update_passwd does not exist (SQL Query: SELECT update_passwd('xxxxxxxx', 'test')) in /usr/share/roundcubemail/program/lib/Roundcube/rcube_db.php on line 543 (POST /roundcubemail/?_task=settings&_action=plugin.password-save)
I have enabled password plugin $config['plugins'] = array('password'); in /etc/roundcube/config.inc.php
The passwords of mail users are stored in /etc/passwd and I don't know how to change roundcube settings to update passwords by users in roundcubemail form to make:
1. changes in this password db files
or
2. stored users passwords in SQL and make changes by roundcube

I will be grateful for your help

Title: Re: Password change for users
Post by: JohnDoh on August 14, 2022, 03:28:10 AM
You need to pick the correct driver for the job. If you passwords are in /etc/passwd then I think you want the Chpasswd driver.
Title: Re: Password change for users
Post by: x8 on August 17, 2022, 02:21:49 AM
Thx for your hint.
I have changed in /etc/roundcubemail/password.inc.php
Quote
<?php

// Password Plugin options
// -----------------------
// A driver to use for password change. Default: "sql".
// See README file for list of supported driver names.
//$config['password_driver'] = 'sql';
$config['password_driver'] = 'chpasswd';

but the roundcubemail still uses sql driver
drivers files are stored in /usr/share/roundcubemail/plugins/password/drivers

OK I have added $config['password_driver'] = 'chpasswd'; into the etc/roundcubemail/config.inc.php and I can put the new password in roundcubemail form but the password not updated in passwd file.

Next step I have made some changes in chpasswd.php

public function save($currpass, $newpass, $username)
    {
       // $cmd = rcmail::get_instance()->config->get('password_chpasswd_cmd');
   $cmd = "echo '".$username.":".$newpass."' |". rcmail::get_instance()->config->get('password_chpasswd_cmd');

        $handle = popen($cmd, "w");
        //fwrite($handle, "$username:$newpass\n");
   fwrite($handle, "");

        if (pclose($handle) == 0) {
            return PASSWORD_SUCCESS;
        }

        rcube::raise_error(array(
                'code' => 600,
                'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Password plugin: Unable to execute $cmd"
            ), true, false);

        return PASSWORD_ERROR;
    }

And there is a error log:
PHP Error: Password plugin: Unable to execute echo 'username:password' | in /usr/share/roundcubemail/plugins/password/drivers/chpasswd.php on line 48 (POST /roundcubemail/?_task=settings&_action=plugin.password-save)

Any idea?