Markus Ullmann wrote:
[EMAIL PROTECTED] schrieb:

Hi Lucas,

that's what I meant.. the one you refer to is for smtp auth. The one I posted verifies whether the RCPT TO: is a valid account and errors out if not. So slightly different ;)

I would suggest that *any* plugin that needs to interface with vpopmail should use vpopmaild. I've include my auth/vpopmaild plugin at the end of this msg.

Also, for something that checks whether RCPT TO: is valid, you need something lightweight, esp. on high-volume sites. Doing a DBI connect and executing an SQL query is not ideal.

I direct you towards John Simpson's validrcptto.cdp page [1] and my own check_validrcptto_cdb page [2]

R.

1. http://qmail.jms1.net/patches/validrcptto.cdb.shtml
2. http://projects.robinbowes.com/trac/check_validrcptto_cdb


#!/usr/bin/perl -w
#
# auth/vpopmaild
#
# qpsmtpd plugin to authenticate against vpopmaild

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 ) =
      @_;

    ### FIXME - read these values 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);

    # Get server greeting (+OK)
    my $connect_response = <$vpopmaild_socket>;
    if ( !$connect_response =~ /\+OK.*/ ) {
        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);
    }
}

Reply via email to