FX said the following on 19/12/2005 06:26:
> Hi,
> 
> I noticed that for vpopmail, qpsmtpd requires MySQL.
> 
> Are there any plans to support non-MySQL vpopmail?

I've written a plugin that authenticates against vpopmaild (available
from CVS, planned for release in the next version of vpopmail).

It could do with being seen by a few more discerning eyes - it works for
me but I've not exactly gone overboard on checking for errors!

You need to run vpopmaild somehow. I use a service like this:

#!/bin/sh
#
# vpopmaild - used by qpsmtpd auth_vpopmaild plugin for authentication
#             with vpopmail.
HOST=127.0.0.1
PORT=89
VPOPMAILD=/var/vpopmail/bin/vpopmaild

exec /usr/local/bin/tcpserver -vHRD \
        $HOST $PORT $VPOPMAILD 2>&1


Anyway, here's the plugin:

#!/usr/bin/perl -w

use IO::Socket;

sub register {
    my ( $self, $qp ) = @_;

    $self->register_hook( "auth-plain", "auth_vpopmaild" );
    $self->register_hook( "auth-login", "auth_vpopmaild" );

}

sub auth_vpopmaild {
    my ( $self, $transaction, $method, $user, $passClear, $passHash,
$ticket )
        = @_;

    # Read these from a config file
    my $vpopmaild_host = 'localhost';
    my $vpopmaild_port = 89;

    # create socket
    my $vpopmaild_socket = IO::Socket::INET->new(
                PeerAddr => $vpopmaild_host,
                PeerPort => $vpopmaild_port,
                Proto    => "tcp",
                Type     => SOCK_STREAM)
        or return (DECLINED);

    # send login details
    print $vpopmaild_socket "login $user $passClear\n\r";

    # get response from server
    my $login_response = <$vpopmaild_socket>;

    close ($vpopmaild_socket);

    # check for successful login
    if ($login_response =~ /\+OK.*/) {
        return ( OK, "authcheckpassword" );
    } else {
        return (DECLINED);
    }
}


It works well for me.

Any thoughts?

R.

Reply via email to