Wednesday, November 17, 2010

CAS-ifying Roundcube 0.4.2

I've been testing Roundcube 0.4.2 as a replacement for our now-decrepit Squirrelmail 1.4.17 Webmail. I've been extremely impressed so far. It does natively or there is a plugin for almost everything I can think of. It acts so much like an application that I found myself angry that I couldn't dynamically resize the Subject/From/Date columns in the folder view. It had tricked me so much into thinking it was a native app that when the illusion broke I was actually confused.

Only one plugin has given me trouble so far, and that's the CAS plugin. For those who aren't familiar with CAS, it is an open-source Central Authentication System that many campuses are using these days for their portals. The benefits to us for using CAS for Roundcube in addition to our portal would be that users only have to sign in once and they can access either Roundcube or the portal without needing to authn again (as long as their cookie/session on the CAS server is still good). We've been trying to convert as many open-source login pages as we can to use CAS.

The problem is perhaps best described here:

http://code.google.com/p/rc-cas-plugin/issues/detail?id=1

Basically even if you do everything right, you will get a redirect loop because somewhere between the version of Roundcube this plugin was written for and 0.4.2, the code to kill/regenerate the PHP session changed. I made some comments in that ticket that include what I was able to do in order to actually log in (comment out a call to kill_session()) but that is not a very clean solution, and it doesn't solve the problem of users logging in from a different browser or IP. Really, this plugin needs work.

Hopefully this helps someone or helps remind me what the problem was should I find the time to work on fixing this plugin.

Z-Push Woes

Z-Push (http://z-push.sourceforge.net/) is an interesting project. It is a PHP web app that lets you serve different backends for mail/contacts to clients that support ActiveSync. The most common use for it seems to be to give devices with zero or minimal IMAP support (but decent ActiveSync support) access to their mail by letting them connect to that IMAP through ActiveSync.

The first thing that bothered me was it REALLY wants to run under mod_php in Apache. People have been able to get it to run in fastCGI by adding the following to compat.php:

if (!function_exists("apache_request_headers")) {
    function apache_request_headers() {
        $headers = array();
        foreach ($_SERVER as $key => $value) {
            if (substr($key, 0, 5) != 'HTTP_') {
                continue;
            }
            $headername = strtr(ucwords(strtolower(strtr(substr($key, 5), '_', ' '))), ' ', '-');
            $headers[$headername] = $value;
        }

        return $headers;
    }
(Taken from http://z-push.sourceforge.net/phpbb/viewtopic.php?f=2&t=36#p1349)
Sadly, the z-push developers didn't accept that patch.

The second problem I ran in to was z-push was segfaulting in PHP's imap_search function. I looked at the raw logs and saw that the client was getting a good response from the search request, but PHP still segfaulted. Some investigation led me to suspect the SE_FREE flag, per this PHP bug report: http://bugs.php.net/48619

Basically I changed the following line in backend/imap.php:
$search = @imap_search($this->_mbox, "SINCE ". date("d-M-Y", $cutoffdate));
to look like:
$search = @imap_search($this->_mbox, "SINCE ". date("d-M-Y", $cutoffdate), ! SE_FREE);
and things started working. So if your PHP is newer than 5.2.10 you hopefully don't have to deal with this. But if not, hopefully this helps you.

Saturday, January 2, 2010

Update Fink For 10.6

Lots of people may have figured this out, but if you're getting the following error when trying to install a package with Fink in Mac OS 10.6:

Use of uninitialized value $darwin_osx in numeric eq (==) at /sw/lib/perl5/Fink/Services.pm line 1404, line 1.
Use of uninitialized value $darwin_osx in concatenation (.) or string at /sw/lib/perl5/Fink/Services.pm line 1404, line 1.
Argument "10.6 does not match the expected value of . Please run `..." isn't numeric in exit at /sw/lib/perl5/Fink/Services.pm line 1404, line 1.
 You can change line 1448 of /sw/lib/perl5/Fink/Services.pm look like this:

my %darwin_osx = ('1' => '10.0', '5' => '10.1', '6' => '10.2', '7' => '     10.3', '8' => '10.4', '9' => '10.5', '10' => '10.6');
Basically I added '10' => '10.6' after '9' => '10.5'. And I was able to install things again.