Roundcube and Poppassd hang solution with centos 6

Posted on September 15, 2013
Filed Under Uncategorized | Leave a Comment

Just a quick post so the search engines may find it…to solve this problem for others.

Using the Passwd plugin with Roundcube open source webmail, and using the poppassd service to allow users to change their email password, if there is a problem with the password i.e violates the system limits for passwords such as too short or contains a dictionary word etc, roundcube appears to just hang. Actually the passwd utility changed with centos 6 I think and the output format changed slightly. It outputs 2 lines instead of one with a successful update. So the line that was looking the success code 200 was never found, although it appears in the second line of output. At any rate the code is changed to skip a line before the check and appears to work well now.

The file I modified the poppassd.php driver file,  thats included in   the roundcube plugins directory “roundcube/plugins/password/drivers”.

here is the code:

You can download this file ,zipped here.

<?php

/**
* Poppassd Password Driver
*
* Driver to change passwords via Poppassd/Courierpassd
*
* @version 2.0
* @author Philip Weir
* Modified by Lloyd Kirk, Gulf Coast Information Systems to fix “hang” with centos 6+
*
*/

class rcube_poppassd_password
{
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 save($curpass, $passwd)
{
$rcmail = rcmail::get_instance();
//    include(‘Net/Socket.php’);
$poppassd = new Net_Socket();

$result = $poppassd->connect($rcmail->config->get(‘password_pop_host’), $rcmail->config->get(‘password_pop_port’), null);
if (PEAR::isError($result)) {
return $this->format_error_result(PASSWORD_CONNECT_ERROR, $result->getMessage());
}
else {
$result = $poppassd->readLine();
if(!preg_match(‘/^2\d\d/’, $result)) {
$poppassd->disconnect();
return $this->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 $this->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 $this->format_error_result(PASSWORD_ERROR, $result);
}
else {
$poppassd->writeLine(“newpass “. $passwd);
$result = $poppassd->readLine();
if (preg_match(‘/^5\d\d/’, $result)){
$poppassd->disconnect();
return $this->format_error_result(PASSWORD_ERROR, $result);
}
$poppassd->writeLine(“quit”);
$result = $poppassd->readLine();
$result = $poppassd->readLine();
$poppassd->disconnect();
if (!preg_match(‘/^2\d\d/’, $result))
return $this->format_error_result(PASSWORD_ERROR, $result);
else
return PASSWORD_SUCCESS;
}
}
}
}
}
}

 

Print Friendly, PDF & Email
Share on Facebook

Comments

Leave a Reply




  • Older Stuff