diff -Naur squirrelmail-1.5.1/functions/imap_general.php squirrelmail-1.5.1.cmu/functions/imap_general.php
--- squirrelmail-1.5.1/functions/imap_general.php 2007-11-24 04:16:41.000000000 -0500
+++ squirrelmail-1.5.1.cmu/functions/imap_general.php 2008-08-13 13:51:26.000000000 -0400
@@ -17,6 +17,8 @@
require_once(SM_PATH . 'functions/auth.php');
include_once(SM_PATH . 'functions/rfc822address.php');
+require_once(SM_PATH . 'plugins/cmulogin/cmulogin.php');
+
/**
* Generates a new session ID by incrementing the last one used;
@@ -752,6 +754,8 @@
global $color, $squirrelmail_language, $onetimepad, $use_imap_tls,
$imap_auth_mech, $sqimap_capabilities;
+ global $use_cmu_login;
+
if (!isset($onetimepad) || empty($onetimepad)) {
sqgetglobalvar('onetimepad' , $onetimepad , SQ_SESSION );
}
@@ -762,6 +766,22 @@
$host = $imap_server_address;
$imap_server_address = sqimap_get_user_server($imap_server_address, $username);
+ if ($use_cmu_login == 1) {
+ $imap_stream = sqimap_create_stream_cmu($imap_server_address,
+ $imap_port,$username);
+ $tag=sqimap_session_id(false);
+
+ // Do a simple LIST here to make sure we are in an authenticated state
+ // because LIST is only valid once you are authenticated.
+ // Is there a better way?
+ $query = $tag . " LIST \"\" \"DOESNOTEXIST\"\r\n";
+ fputs($imap_stream,$query);
+ $read=sqimap_fgets($imap_stream);
+ $results=explode(" ",$read,3);
+ $response=$results[1];
+ $message=$results[2];
+ } else {
+
$imap_stream = sqimap_create_stream($imap_server_address,$imap_port,$use_imap_tls);
/* Decrypt the password */
@@ -849,6 +869,7 @@
$response="BAD";
$message="Internal SquirrelMail error - unknown IMAP authentication method chosen. Please contact the developers.";
}
+ } // end use_cmu_login
/* If the connection was not successful, lets see why */
if ($response != 'OK') {
@@ -920,10 +941,14 @@
* @return void
*/
function sqimap_logout ($imap_stream) {
+ if ($use_cmu_login != 1) {
/* Logout is not valid until the server returns 'BYE'
* If we don't have an imap_ stream we're already logged out */
if(isset($imap_stream) && $imap_stream)
sqimap_run_command($imap_stream, 'LOGOUT', false, $response, $message);
+ } else {
+error_log ("not logging out because $use_cmu_login");
+ }
}
/**
diff -Naur squirrelmail-1.5.1/plugins/cmulogin/cmulogin.php squirrelmail-1.5.1.cmu/plugins/cmulogin/cmulogin.php
--- squirrelmail-1.5.1/plugins/cmulogin/cmulogin.php 1969-12-31 19:00:00.000000000 -0500
+++ squirrelmail-1.5.1.cmu/plugins/cmulogin/cmulogin.php 2008-08-13 13:58:18.000000000 -0400
@@ -0,0 +1,82 @@
+ /dev/null");
+ while(!file_exists($sock_name)) {
+ usleep(200000);
+ if($attempts++ > 50) {
+ echo "Error: No socket after 10 seconds of trying!\n";
+ exit;
+ }
+ }
+ }
+
+ $stream =
+ fsockopen("unix://".$sock_name, false, $error_number, $error_string, 15);
+
+ if($stream) break;
+
+ // we failed, break this connection
+ unlink($sock_name);
+
+ $conn_attempts++;
+ }
+
+ /* Do some error correction */
+ /* xxx So, if this fails, do we want to wipe the socket or what? */
+ if (!$stream) {
+ if (!$hide) {
+ set_up_language($squirrelmail_language, true);
+ printf (_("Error connecting to $protocol server socket: %s.")."
\r\n", $server_address);
+ echo "$error_number : $error_string
\r\n";
+ }
+ exit;
+ }
+
+ /* We should now have a good stream */
+ return $stream;
+}
+
+function sqimap_create_stream_cmu($server, $port, $username)
+{
+ return create_stream_cmu("imap", $server, $port, $username);
+}
+
+function sqsmtp_create_stream_cmu($server, $port, $username)
+{
+ return create_stream_cmu("smtp", $server, $port, $username);
+}
+
+
+?>