Cyrus APIs ?

Bron Gondwana brong at
Thu May 28 20:58:55 EDT 2009

On Fri, May 29, 2009 at 12:27:27AM +0200, Thomas Cataldo wrote:
> Hi,
> We are building webmail & groupware software using cyrus for the mail
> storage part. I'm wondering if any programming interface existed to
> extend cyrus parts ?

Yeah, it's called the C language.  Compile your own.

Personally I use git these days.  Used to keep all the
patches with quilt, and before that we just fiddled around
in a CVS checkout and hoped nobody messed up.  That's not
so clever.  Version control good.

> Interesting things for us would be :
>   - extending sieve (for exemple to implement "in my organisation" /
> "out of my organisation" vacation messages)

That's just a matter of writing the correct sieve script.  No
extention needed.

>   - IMAP protocol extensions (most needed thing would be to "idle" on
> every folders, not just inbox)

Yeah, good luck with that one.  It's a pretty major "protocol extention",
and everything's very folder centric.  It would be a rather large SMOP
(small matter of programming) for this.

>   - custom authentification mechanism (for single sign-on purpose,
> because kerberos doesn't fit everywhere)

BYO saslauthd protocol daemon.  We have one written in Perl that does
all sorts of clever.  Just put this in your imapd.conf

sasl_pwcheck_method: saslauthd

And have your daemon listen on a unix socket at:


You need to speak the saslauthd protocol, which is a packed string
format.  We parse it in Perl like this:

  my $LoginName = get_counted_string($Self->{server}{client});
  my $Password = get_counted_string($Self->{server}{client});
  my $Service = lc get_counted_string($Self->{server}{client});
  my $Realm = get_counted_string($Self->{server}{client});

And return one of:

  use constant SASL_SUCC_RESP  => pack("nA3", 2, "OK\000");
  use constant SASL_FAIL_RESP  => pack("nA3", 2, "NO\000");

(with this function - slightly ugly code, but it works)

sub get_counted_string {
  my $fh = shift;

  my ($rd, $data);

  ($rd = sysread($fh, $data, 2)    ) == 2
    or die "Unable to read counted string size ($rd != 2) ($!)";

  my $size = unpack("n", $data);

  $data = ''; $rd = 0; my $this_data = ''; my $rem_size = $size;
  while (my $this_rd = sysread($fh, $this_data, $rem_size)) {
    $rd += $this_rd;
    $rem_size -= $this_rd;
    $data .= $this_data;
  die "Unable to read counted string data ($rd != $size) ($!)"
    unless ($rd  == $size);

  return unpack("A$size", $data);


More information about the Info-cyrus mailing list