Aleksander Machniak
2015-02-26 1d09ee0ce6d50d122352bfde66828d70cd7ed57b
Added 'kpasswd' driver by Peter Allgeyer
1 files added
3 files modified
61 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
plugins/password/README 9 ●●●●● patch | view | raw | blame | history
plugins/password/config.inc.php.dist 6 ●●●●● patch | view | raw | blame | history
plugins/password/drivers/kpasswd.php 45 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -2,6 +2,7 @@
===========================
- Plugin API: Add special onload() method to execute plugin actions before startup (session and GUI initialization)
- Password plugin: Added 'kpasswd' driver by Peter Allgeyer
- Add possibility to print contact information (of a single contact)
- Add possibility to configure max_allowed_packet value for all database engines (#1490283)
- Improved handling of storage errors after message is sent
plugins/password/README
@@ -44,6 +44,7 @@
 2.18. Samba (smb)
 2.19. Vpopmail daemon (vpopmaild)
 2.20. Plesk (Plesk RPC-API)
 2.21. Kpasswd
 3. Driver API
@@ -301,6 +302,7 @@
 Driver to change Samba user password via the 'smbpasswd' command.
 See config.inc.php.dist file for configuration description.
 2.19. Vpopmail daemon (vpopmaild)
 -----------------------------------
@@ -330,6 +332,13 @@
 Set the RPC-Path in $config['password_plesk_rpc_path']. Normally this is: enterprise/control/agent.php.
 2.21.  Kpasswd
 -----------------------------------
 Driver to change the password in Kerberos environments via the 'kpasswd' command.
 See config.inc.php.dist file for configuration description.
 3. Driver API
 -------------
plugins/password/config.inc.php.dist
@@ -399,3 +399,9 @@
// Plesk RPC Path
$config['password_plesk_rpc_path'] = 'enterprise/control/agent.php';
// kasswd Driver options
// ---------------------
// Command to use
$config['password_kpasswd_cmd'] = '/usr/bin/kpasswd';
plugins/password/drivers/kpasswd.php
New file
@@ -0,0 +1,45 @@
<?php
/**
 * kpasswd Driver
 *
 * Driver that adds functionality to change the systems user password via
 * the 'kpasswd' command.
 *
 * For installation instructions please read the README file.
 *
 * @version 1.0
 * @author Peter Allgeyer <peter.allgeyer@salzburgresearch.at>
 *
 * Based on chpasswd roundcubemail password driver by
 * @author Alex Cartwright <acartwright@mutinydesign.co.uk>
 */
class rcube_kpasswd_password
{
    public function save($currpass, $newpass)
    {
        $bin      = rcmail::get_instance()->config->get('password_kpasswd_cmd', '/usr/bin/kpasswd');
        $username = $_SESSION['username'];
        $cmd      = $bin . ' "' . $username . '" 2>&1';
        $handle = popen($cmd, "w");
        fwrite($handle, $currpass."\n");
        fwrite($handle, $newpass."\n");
        fwrite($handle, $newpass."\n");
        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;
    }
}