Your comments

My solution was to create a change password command in the IPCHandler of the vh-mail plugin (ajenti-v-mail):


--- ipc.py    2016-10-08 20:58:57.258906986 +0200
+++ ipc_new.py    2016-10-08 20:58:57.258906986 +0200
@@ -15,6 +15,18 @@
     def handle(self, args):
         command = args[0]
+        if command == 'password':
+            if len(args) != 3:
+                raise Exception('Usage: vmail password <user name> <new password>')
+            for mb in self.manager.config.mailboxes:
+                if mb.local == args[1]:
+                    mb.password = args[2]
+                    break
+            else:
+                raise Exception('Username not found')
+            self.manager.save()
+            return 'OK'
+
         if command == 'apply':
             self.manager.init()
             self.manager.save()

In this way I'm able to change an e-mail account password with following command:

$ ajenti-ipc vmail password <user name> <new password>
Then I slightly modified the kpasswd driver of the password plugin of roundcube (roundcube/plugins/password/drivers/) and created following driver: ajenti.php

<?php

/**
 * ajenti Driver
 *
 * Driver that adds functionality to change the ajenti user password via
 * the 'ajenti-ipc' command.
 *
 * For installation instructions please read the README file.
 *
 * @version 1.0
 * @author Daniele Noviello <daniele.noviello@abstract.it>
 *
 * Based on kpasswd roundcubemail password driver by
 * @author Peter Allgeyer <peter.allgeyer@salzburgresearch.at>
 */


class rcube_ajenti_password
{
    public function save($currpass, $newpass)
    {
        $bin      = rcmail::get_instance()->config->get('password_ajenti_cmd', 'sudo /usr/bin/ajenti-ipc vmail password');
        $username = strstr($_SESSION['username'],'@', $before_needle = true);
        $cmd      = $bin . ' ' . $username . ' ' . $newpass;


        $handle = popen($cmd, "w");


        if (pclose($handle) == 0) {
            return PASSWORD_SUCCESS;
        }
        else {
            rcube::raise_error(array(
                'code' => 600,
                'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Password plugin: Unable to execute $cmd"
                ), true, false);
        }


        return PASSWORD_ERROR;
    }
}

At least you need to enable roundcube to run the command with the right sudoers configuration, e.g.:


www-data ALL=(root) NOPASSWD: /usr/bin/ajenti-ipc
Now I'm able to change the password of an e-mail account in ajenti through the roundcube interface.


Ubuntu: 14.04.5 LTS

ajenti: 1.2.23.8

ajenti-v: 0.2.57

ajenti-v-mail: 0.1.36

Roudcube: 1.2.2