[exim] embedded perl script in Exim.

Top Page
Delete this message
Reply to this message
Author: sam wun
Date:  
CC: exim-users
Old-Topics: [exim] Authenticator written in perl to deal with cyrus-sasl2 auth from Outlook
Subject: [exim] embedded perl script in Exim.
Hi,

The following embedded perl script does not work with Exim 4.43, I put
it rither after the phrase of "begin authentication":

EXIM_PERL=perl.o

begin authenticators
# AUTH stuff here

perl_at_start
perl_startup    = \
        use BerkeleyDB ; \
        my $autoTransition      = 0 ; \
        my $defaultRealm        = 
Exim::expand_string('$primary_hostname'); \
        my %sdb ; \
        my $Sdb = tie %sdb, "BerkeleyDB::Hash", \
               -Filename => "/etc/sasldb2", \
                -Flags    => DB_RDONLY \
            or die "Could not tie to /etc/sasldb2: $!\n" ; \
        sub makeKey ($$;$) { \
            my ($usr, $key, $realm) = @_ ; \
            $realm = $defaultRealm      unless $realm ; \
            return "${usr}\000${realm}\000${key}" ; \
        } \
        sub getPw   ($;$) { \
            return $sdb{makeKey(shift, 'userPassword', shift)} ; \
        } \
        sub checkPw ($$;$) { \
            use Digest::MD5 ; $m = Digest::MD5->new ; \
            my ($usr, $val, $realm) = @_ ; \
            my $u = makeKey($usr, 'userPassword', $realm) ; \
            return ($sdb{$u} eq $val) if  exists $sdb{$u} ; \
            my $p = makeKey($usr, 'cmusaslsecretPLAIN', $realm) ; \
            my $V = $sdb{$p} ; return undef unless $V ; \
            my ($s,$h)=unpack('a16 x a16', $V) ; \
            my $ret = $h eq  $m->add($s, 'sasldb', $val)->digest ; \
            return $ret ; \
        }


plain:
    driver              = plaintext
    public_name         = PLAIN
    #   We should be able to do a dbm lookup in the sasldb2 database using
    #   a key composed by concatenating the username, domain name, and
    #   'userPassword'.  BUT cyrus-sasl puts NULs between the components
    #   and exim can't handle strings with embedded NULs...  Hence the perl.
    server_condition    = ${perl {checkPw} {$2} {$3} {mail} }
    server_set_id       = $2


The error is:
]# ../rc.d/exim.sh restart
Stopping exim.
Starting exim.
2004-11-07 12:47:43 Exim configuration error in line 695 of
/usr/local/etc/exim/configure:
authenticator name missing


Any suggestion?

Thanks
Sam