+5

Allowing non-Ajenti users to change their mail password

Robbert Brandsma 3 years ago • updated by Kamil Krzemiński 9 months ago 6
I'm running Ajenti-V on my server and use it for both websites and mail. I'm providing mail for a few other users. These users should not be able to access Ajenti or the general mail configuration, but I would like to give them the option to change their own mail password.

I'm also running Roundcube for webmail, so if it is somehow possible to change the e-mail passwords there that is preferred, but not necessary. Is there a way to achieve this, without Ajenti overwriting the mail configuration every time a new mail address is added?
im looking for this capability too,
you shoud ask developers to add this capability to ajenti
there is nothing we can do, becaz ajenti will overwriting the configuration
if you r progamer,and familiar with python, get involved and do it your self

is there someone have a solution for this?
i really need this,
I used "courierpassd" to solve this problem
+1

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

@Daniele, I can't find the file ipc.py in vh-mail directory. Have you created a new one? Could you please share full file, instead of diff?