From 043b159256a721853b50631827690eeb842c844a Mon Sep 17 00:00:00 2001 From: alec Date: Wed, 29 Sep 2010 17:23:26 +0000 Subject: - Added possibility to display extended error messages (#1486704) - Added extended error messages in Poppassd driver (#1486704) git-svn-id: https://svn.roundcube.net/trunk@4016 208e9e7b-5314-0410-a742-e7e81cd9613c --- plugins/password/drivers/poppassd.php | 26 +++++++++++++++++--------- plugins/password/package.xml | 33 +++++++++++++++++++++++++-------- plugins/password/password.php | 23 ++++++++++++++++------- 3 files changed, 58 insertions(+), 24 deletions(-) (limited to 'plugins') diff --git a/plugins/password/drivers/poppassd.php b/plugins/password/drivers/poppassd.php index 8a54fb7d9..fc105de47 100644 --- a/plugins/password/drivers/poppassd.php +++ b/plugins/password/drivers/poppassd.php @@ -5,46 +5,56 @@ * * Driver to change passwords via Poppassd/Courierpassd * - * @version 1.0 + * @version 1.1 * @author Philip Weir * */ +function format_error_result($code, $line) +{ + if (preg_match('/^\d\d\d\s+(\S.*)\s*$/', $line, $matches)) { + return array('code' => $code, 'message' => $matches[1]); + } else { + return $code; + } +} + function password_save($curpass, $passwd) { $rcmail = rcmail::get_instance(); // include('Net/Socket.php'); $poppassd = new Net_Socket(); - if (PEAR::isError($poppassd->connect($rcmail->config->get('password_pop_host'), $rcmail->config->get('password_pop_port'), null))) { - return PASSWORD_CONNECT_ERROR; + $result = $poppassd->connect($rcmail->config->get('password_pop_host'), $rcmail->config->get('password_pop_port'), null); + if (PEAR::isError($result)) { + return format_error_result(PASSWORD_CONNECT_ERROR, $result->getMessage()); } else { $result = $poppassd->readLine(); if(!preg_match('/^2\d\d/', $result)) { $poppassd->disconnect(); - return PASSWORD_ERROR; + return format_error_result(PASSWORD_ERROR, $result); } else { $poppassd->writeLine("user ". $_SESSION['username']); $result = $poppassd->readLine(); if(!preg_match('/^[23]\d\d/', $result) ) { $poppassd->disconnect(); - return PASSWORD_CONNECT_ERROR; + return format_error_result(PASSWORD_CONNECT_ERROR, $result); } else { $poppassd->writeLine("pass ". $curpass); $result = $poppassd->readLine(); if(!preg_match('/^[23]\d\d/', $result) ) { $poppassd->disconnect(); - return PASSWORD_ERROR; + return format_error_result(PASSWORD_ERROR, $result); } else { $poppassd->writeLine("newpass ". $passwd); $result = $poppassd->readLine(); $poppassd->disconnect(); if (!preg_match('/^2\d\d/', $result)) - return PASSWORD_ERROR; + return format_error_result(PASSWORD_ERROR, $result); else return PASSWORD_SUCCESS; } @@ -52,5 +62,3 @@ function password_save($curpass, $passwd) } } } - -?> diff --git a/plugins/password/package.xml b/plugins/password/package.xml index 433280980..26ce9a991 100644 --- a/plugins/password/package.xml +++ b/plugins/password/package.xml @@ -15,11 +15,11 @@ alec@alec.pl yes - 2010-09-10 - + 2010-09-29 + - 1.7 - 1.5 + 1.8 + 1.6 stable @@ -27,9 +27,8 @@ GNU GPLv2 -- Added XMail driver -- Improve security of chpasswd driver using popen instead of exec+echo (#1486987) -- Added chpass-wrapper.py script to improve security (#1486987) +- Added possibility to display extended error messages (#1486704) +- Added extended error messages in Poppassd driver (#1486704) @@ -153,5 +152,23 @@ - Added ldap_simple driver - + + 2010-09-10 + + + 1.7 + 1.5 + + + stable + stable + + GNU GPLv2 + +- Added XMail driver +- Improve security of chpasswd driver using popen instead of exec+echo (#1486987) +- Added chpass-wrapper.py script to improve security (#1486987) + + + diff --git a/plugins/password/password.php b/plugins/password/password.php index 14a3632c3..a31e8946d 100644 --- a/plugins/password/password.php +++ b/plugins/password/password.php @@ -5,7 +5,7 @@ | Password Plugin for Roundcube | | @version @package_version@ | | | - | Copyright (C) 2009, Roundcube Dev. | + | Copyright (C) 2009-2010, Roundcube Dev. | | | | This program is free software; you can redistribute it and/or modify | | it under the terms of the GNU General Public License version 2 | @@ -124,7 +124,7 @@ class password extends rcube_plugin $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error'); } // try to save the password - else if (!($res = $this->_save($curpwd,$newpwd))) { + else if (!($res = $this->_save($curpwd, $newpwd))) { $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation'); $_SESSION['password'] = $rcmail->encrypt($newpwd); } @@ -229,18 +229,27 @@ class password extends rcube_plugin $result = password_save($curpass, $passwd); + if (is_array($result)) { + $result = $result['code']; + $message = $result['message']; + } + switch ($result) { case PASSWORD_SUCCESS: return; case PASSWORD_CRYPT_ERROR; - return $this->gettext('crypterror'); + $reason = $this->gettext('crypterror'); case PASSWORD_CONNECT_ERROR; - return $this->gettext('connecterror'); + $reason = $this->gettext('connecterror'); case PASSWORD_ERROR: default: - return $this->gettext('internalerror'); + $reason = $this->gettext('internalerror'); + } + + if ($message) { + $reason .= ' ' . $message; } + + return $reason; } } - -?> -- cgit v1.2.3