Hi,

I need to provide smtp auth with qpsmtpd and vpopmail.

I tried modifying the auth_checkpassword plugin to use vchkpw but I
couldn't get it to work. I did notice an anomally with the printf call.
The following illustrates what might be the problem:

$ perl -e 'printf "%s\0%s\0Y123456\0","[EMAIL PROTECTED]","password"'
robin.compasswordY123456

i.e. the @ sign causes something funny to happen and truncate the email
address. Note that the full email address is required for vpopmail.

Anyway, I gave up on that and remembered vpopmaild [1] . This is a
daemon designed to give access to the various vpopmail functions with
the right privilege levels. Most importantly, it allows authentication
against the vpopmail passwd files.

[1] http://www.qmailwiki.org/Vpopmaild

I've written a simple plugin that authenticates against vpopmaild:

#!/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 = 42; # std port is 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's pretty basic, and needs polishing but it works!

I'd appreciate any comments, etc. before I finish it off and post the
completed version.
-- 
http://robinbowes.com

If a man speaks in a forest,
and his wife's not there,
is he still wrong?

Reply via email to