From b59b72cc3028cc0514e951f135d8bfe7efcaaa6f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 26 Feb 2015 18:04:03 +0100 Subject: Fix "Non-static method PEAR::isError() should not be called statically" errors (#1490281) --- plugins/password/drivers/ldap.php | 6 +++--- plugins/password/drivers/poppassd.php | 2 +- plugins/password/drivers/vpopmaild.php | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'plugins/password') diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index c18ff0f06..a11c38d17 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -75,7 +75,7 @@ class rcube_ldap_password $ldap = Net_LDAP2::connect($ldapConfig); // Checking for connection error - if (PEAR::isError($ldap)) { + if (is_a($ldap, 'PEAR_Error')) { return PASSWORD_CONNECT_ERROR; } @@ -176,7 +176,7 @@ class rcube_ldap_password $ldap = Net_LDAP2::connect($ldapConfig); - if (PEAR::isError($ldap)) { + if (is_a($ldap, 'PEAR_Error')) { return ''; } @@ -189,7 +189,7 @@ class rcube_ldap_password $result = $ldap->search($base, $filter, $options); $ldap->done(); - if (PEAR::isError($result) || ($result->count() != 1)) { + if (is_a($result, 'PEAR_Error') || ($result->count() != 1)) { return ''; } diff --git a/plugins/password/drivers/poppassd.php b/plugins/password/drivers/poppassd.php index 8ddbef5d3..7a2821083 100644 --- a/plugins/password/drivers/poppassd.php +++ b/plugins/password/drivers/poppassd.php @@ -42,7 +42,7 @@ class rcube_poppassd_password $poppassd = new Net_Socket(); $result = $poppassd->connect($rcmail->config->get('password_pop_host'), $rcmail->config->get('password_pop_port'), null); - if (PEAR::isError($result)) { + if (is_a($result, 'PEAR_Error')) { return $this->format_error_result(PASSWORD_CONNECT_ERROR, $result->getMessage()); } else { diff --git a/plugins/password/drivers/vpopmaild.php b/plugins/password/drivers/vpopmaild.php index a7644fc21..90fce02c5 100644 --- a/plugins/password/drivers/vpopmaild.php +++ b/plugins/password/drivers/vpopmaild.php @@ -28,12 +28,13 @@ class rcube_vpopmaild_password { function save($curpass, $passwd) { - $rcmail = rcmail::get_instance(); - // include('Net/Socket.php'); + $rcmail = rcmail::get_instance(); $vpopmaild = new Net_Socket(); + $host = $rcmail->config->get('password_vpopmaild_host'); + $port = $rcmail->config->get('password_vpopmaild_port'); - if (PEAR::isError($vpopmaild->connect($rcmail->config->get('password_vpopmaild_host'), - $rcmail->config->get('password_vpopmaild_port'), null))) { + $result = $vpopmaild->connect($hostname, $port, null); + if (is_a($result, 'PEAR_Error')) { return PASSWORD_CONNECT_ERROR; } -- cgit v1.2.3 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 --- CHANGELOG | 1 + plugins/password/README | 9 ++++++++ plugins/password/config.inc.php.dist | 6 +++++ plugins/password/drivers/kpasswd.php | 45 ++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 plugins/password/drivers/kpasswd.php (limited to 'plugins/password') diff --git a/CHANGELOG b/CHANGELOG index 4855f2c31..3bc673d51 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ CHANGELOG Roundcube Webmail =========================== - 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 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 From e2fb34028980910e006f09b4fd93c4172f79b306 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 12 Mar 2015 09:59:47 +0100 Subject: Remove obsolete mt_srand() calls --- plugins/password/drivers/ldap.php | 3 --- program/lib/Roundcube/rcube_user.php | 1 - 2 files changed, 4 deletions(-) (limited to 'plugins/password') diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index a11c38d17..6ed5ada04 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -289,7 +289,6 @@ class rcube_ldap_password break; case 'ssha': - mt_srand((double) microtime() * 1000000); $salt = substr(pack('h*', md5(mt_rand())), 0, 8); if (function_exists('mhash') && function_exists('mhash_keygen_s2k')) { @@ -316,7 +315,6 @@ class rcube_ldap_password case 'smd5': - mt_srand((double) microtime() * 1000000); $salt = substr(pack('h*', md5(mt_rand())), 0, 8); if (function_exists('mhash') && function_exists('mhash_keygen_s2k')) { @@ -373,7 +371,6 @@ class rcube_ldap_password { $possible = '0123456789' . 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . './'; $str = ''; - // mt_srand((double)microtime() * 1000000); while (strlen($str) < $length) { $str .= substr($possible, (rand() % strlen($possible)), 1); diff --git a/program/lib/Roundcube/rcube_user.php b/program/lib/Roundcube/rcube_user.php index 1a61efd5e..8ed34fc28 100644 --- a/program/lib/Roundcube/rcube_user.php +++ b/program/lib/Roundcube/rcube_user.php @@ -242,7 +242,6 @@ class rcube_user // generate a random hash and store it in user prefs if (empty($prefs['client_hash'])) { - mt_srand((double)microtime() * 1000000); $prefs['client_hash'] = md5($this->data['username'] . mt_rand() . $this->data['mail_host']); $this->save_prefs(array('client_hash' => $prefs['client_hash'])); } -- cgit v1.2.3 From e6c1e0c6383ae4b138080bcfa033e13f9576ecad Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 31 Mar 2015 16:05:27 +0200 Subject: Fix vpopmaild driver of password plugin --- CHANGELOG | 1 + plugins/password/drivers/vpopmaild.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins/password') diff --git a/CHANGELOG b/CHANGELOG index 84be2134a..d14566ddf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ CHANGELOG Roundcube Webmail - Plugin API: Add special onload() method to execute plugin actions before startup (session and GUI initialization) - Fix handling of %-encoded entities in mailto: URLs (#1490346) - Fix zipped messages downloads after selecting all messages in a folder (#1490339) +- Fix vpopmaild driver of password plugin RELEASE 1.1.1 ------------- diff --git a/plugins/password/drivers/vpopmaild.php b/plugins/password/drivers/vpopmaild.php index 90fce02c5..bc0c8f9da 100644 --- a/plugins/password/drivers/vpopmaild.php +++ b/plugins/password/drivers/vpopmaild.php @@ -33,7 +33,7 @@ class rcube_vpopmaild_password $host = $rcmail->config->get('password_vpopmaild_host'); $port = $rcmail->config->get('password_vpopmaild_port'); - $result = $vpopmaild->connect($hostname, $port, null); + $result = $vpopmaild->connect($host, $port, null); if (is_a($result, 'PEAR_Error')) { return PASSWORD_CONNECT_ERROR; } -- cgit v1.2.3