Roundcube: Change Virtualmin Password Plugin

I can never get the Virtualmin binary file compilation to work properly, so here’s my workaround to enable changing a user’s Virtualmin password in Roundcube Webmail.

Firstly, let’s go to the plugins/password directory (your path will be different):

cd ~username/public_html/webmail/plugins/password
cp config.inc.php.dist config.inc.php
vi config.inc.php

We need to change the password driver to virtualmin (hit i for insert mode), so it reads:

$rcmail_config['password_driver'] = 'virtualmin';

(Hit Esc to exist insert mode and then ZZ to save. You’ll need these commands throughout this tutorial.)
Now we’ll use sudo instead of the binary compilation:

cd drivers
yum -y install sudo
visudo

Comment out the line: Defaults requiretty
At the end, add the following line (change the username to whatever user your webmail directory runs as): username ALL=NOPASSWD: /usr/sbin/virtualmin

If you can’t work out which user it is, create and execute a PHP script in the webmail directory with the following contents: <?php exec('whoami',$output,$return_code); print_r($output); ?>

Now we need to change the exec line in the virtualmin script:

vi virtualmin.php

Change the line that starts with exec to:
exec("sudo /usr/sbin/virtualmin modify-user --domain $domain --user $username --pass $newpass", $output, $returnvalue);

Finally, add password to the plugins array to activate it:

cd ../../../config
vi main.inc.php

Change plugins array to: $rcmail_config['plugins'] = array('password');

Tagged , , , , . Bookmark the permalink.

6 Responses to Roundcube: Change Virtualmin Password Plugin

  1. Ronnie says:

    I am getting this error from roundcube’s logs. It looks like a permission issue in one of the files. Anything I should be aware of?

    PHP Error: Password plugin: Unable to execute /home/domain/public_html/roundcube/plugins/password/drivers/chgvirtualminpasswd in /home/domain/public_html/roundcube/plugins/password/drivers/virtualmin.php on line 0 (POST /roundcube/?_task=settings&_action=plugin.password-save?_task=&_action=)

    • admin says:

      My method doesn’t use that binary so you shouldn’t be trying to execute the file. Make sure you change the exec() line in virtualmin.php or if you are adding a new line, comment out the old one.

  2. 3k says:

    When the post server uses usernames like joe.domain-com (default in Postfix) instead of joe@domain.com, this causes an incorrectly parsed $domain variable, which also leads to Ronnies error…

  3. Tidus says:

    I tried this for myself, I get the exec error

  4. specktator says:

    Hi guys,
    I was searching to fix this and after all these years some things have changed. Here is a working workaround I’ve written. http://totallynoob.com/roundcube-password-plugin-for-virtualmin/

Leave a Reply

Your email address will not be published. Required fields are marked *