Hi there,
i had setup a qpsmtpd with vpopmail, but i ran into some problems. I
fixed these and i want to contribute it, i think it can be useful to
others. I primary had two problems with auth_vpopmail_sql

1) We had some customers that uses the old email scheme
"account%example.org" instead of "acco...@example.org". I modified the
split. Now auth_vpopmail_sql works with these old schemas.

2) vpopmail knews Domain aliases. That means "example.de" can be an
alias for "example.com". The original only accepted authorisation if the
sender uses "example.com". With the modification it also will accept
mails for domain aliases. By the way only checking of the domain part is
integrated. If someone has a alias of the local address part, then no
checking is made.

That means if someone has "f...@example.org" as an alias for
"b...@example.org" he can only authenticate with "b...@example.org".
Fixing these is a little bit harder (but possible). Problem is that the
vpopmail database is total crap and it is hard to distinguish between an
alias, forward or something else (forwarding to maildir). But i think
even these would help a lot for some user.

I really like when this patch gets into official qpsmtpd release. The
patch was made against a qpsmtpd 0.83. "auth_vpopmail_sql_orig" in this
diff is the qpsmtpd 0.83 version.

Oh and sure finally the patch:


--- auth_vpopmail_sql_orig    2010-03-29 15:02:17.000000000 +0200
+++ auth_vpopmail_sql    2010-03-29 15:49:31.000000000 +0200
@@ -69,20 +69,28 @@
 
     my $dbh = DBI->connect( $connect, $dbuser, $dbpasswd );
     $dbh->{ShowErrorStatement} = 1;
 
     my ( $self, $transaction, $method, $user, $passClear, $passHash,
$ticket ) =
       @_;
-    my ( $pw_name, $pw_domain ) = split "@", lc($user);
+    my ( $pw_name, $pw_domain ) = split m/[...@%]/, lc($user);
 
     unless ( defined $pw_domain ) {
         return DECLINED;
     }
 
     $self->log(LOGINFO,
     "Authentication to vpopmail via mysql: $pw_na...@$pw_domain");
+   
+    my $alias_sth = $dbh->prepare('SELECT alias,domain FROM
vdomainalias WHERE alias = ?');
+       $alias_sth->execute($pw_domain);
+    my $alias_data = $alias_sth->fetchrow_hashref;
+    if ( defined $alias_data ) {
+        $pw_domain = $alias_data->{domain};
+        $alias_sth->finish;
+    }
 
     my $sth = $dbh->prepare(<<SQL);
 select *
 from vpopmail
 where pw_name = ? and pw_domain = ?
 SQL

Reply via email to