I already sent this some time ago, but it seems it remained unnoticed. This
is an auth module which can use a traditional checkpassword binary. Great
for people who have customized checkpassword-programs which can still be
used with qpsmtpd.

There are quite some people who use this approach, in fact there are patches
for qmail available, which makes qmail-smtpd a checkpassword binary. This
module provides the same functionality for qpsmtpd.

I would suggest adding this to the CVS. I'm unsure about the policies for
CVS inclusion and access, is this documented?

-kju

-- 
      It's an insane world, but i'm proud to be a part of it. -- Bill Hicks
#!/usr/bin/perl -w

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

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

}

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

    my $binary = $self->qp->config("smtpauth-checkpassword")
      or return (DECLINED);
    return(DECLINED) if ( ! -x $binary );

    my ($untainted) = $binary =~ /^(.*)$/;

    open(CPW,"|$untainted 3<&0");
    printf(CPW "%s\0%s\0Y123456\0",$user,$passClear);
    close(CPW);

    my $status = $?;

    return(DECLINED) if ( $status != 0 );
    return ( OK, "authcheckpassword" );
}

Reply via email to