From 1d09ee0ce6d50d122352bfde66828d70cd7ed57b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 26 Feb 2015 18:19:44 +0100 Subject: Added 'kpasswd' driver by Peter Allgeyer --- plugins/password/README | 9 ++++++++ plugins/password/config.inc.php.dist | 6 +++++ plugins/password/drivers/kpasswd.php | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 plugins/password/drivers/kpasswd.php (limited to 'plugins') diff --git a/plugins/password/README b/plugins/password/README index 8c3a2afbd..b883211bb 100644 --- a/plugins/password/README +++ b/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 ------------- diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist index cf021020f..18144996f 100644 --- a/plugins/password/config.inc.php.dist +++ b/plugins/password/config.inc.php.dist @@ -399,3 +399,9 @@ $config['password_plesk_rpc_port'] = '8443'; // 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'; diff --git a/plugins/password/drivers/kpasswd.php b/plugins/password/drivers/kpasswd.php new file mode 100644 index 000000000..ce245b315 --- /dev/null +++ b/plugins/password/drivers/kpasswd.php @@ -0,0 +1,45 @@ + + * + * Based on chpasswd roundcubemail password driver by + * @author Alex Cartwright + */ + +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; + } +} -- cgit v1.2.3