cvs commit: qpsmtpd/lib/Qpsmtpd Auth.pm
[email protected] (Matt Sergeant)
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 04/07/29 07:40:32 Modified: lib/Qpsmtpd Auth.pm Log: Fix for AUTH PLAIN from Michael Holzt <[email protected]> Revision Changes Path 1.3 +36 -48 qpsmtpd/lib/Qpsmtpd/Auth.pm Index: Auth.pm =================================================================== RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Auth.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- Auth.pm 5 Jul 2004 09:24:59 -0000 1.2 +++ Auth.pm 29 Jul 2004 14:40:32 -0000 1.3 @@ -214,6 +214,14 @@ use Qpsmtpd::Constants; use MIME::Base64; +sub e64 +{ + my ($arg) = @_; + my $res = encode_base64($arg); + chomp($res); + return($res); +} + sub Qpsmtpd::SMTP::auth { my ( $self, $arg, @stuff ) = @_; @@ -235,59 +243,39 @@ $mechanism = lc($mechanism); if ( $mechanism eq "plain" ) { - if ($prekey) { + if (!$prekey) { + $session->respond( 334, "Please continue" ); + $prekey= <>; + } ( $passHash, $user, $passClear ) = split /\x0/, decode_base64($prekey); + } - else { + elsif ($mechanism eq "login") { - $session->respond( 334, "Username:" ); + if ( $prekey ) { + ($passHash, $user, $passClear) = split /\x0/, decode_base64($prekey); + } + else { - # We read the username and password from STDIN - $user = <>; - chop($user); - chop($user); + $session->respond(334, e64("Username:")); + $user = decode_base64(<>); + #warn("Debug: User: '$user'"); if ( $user eq '*' ) { $session->respond( 501, "Authentification canceled" ); return DECLINED; } - $session->respond( 334, "Password:" ); + $session->respond(334, e64("Password:")); $passClear = <>; - chop($passClear); - chop($passClear); + $passClear = decode_base64($passClear); + #warn("Debug: Pass: '$pass'"); if ( $passClear eq '*' ) { $session->respond( 501, "Authentification canceled" ); return DECLINED; } } - } - - # elsif ($mechanism eq "login") { - # if ( $prekey ) { - # ($passHash, $user, $passClear) = split /\x0/, decode_base64($prekey); - # } - # else { - # - # $session->respond(334, encode_base64("User Name:")); - # $user = decode_base64(<>); - # #warn("Debug: User: '$user'"); - # if ($user eq '*') { - # $session->respond(501, "Authentification canceled"); - # return DECLINED; - # } - # - # $session->respond(334, encode_base64("Password:")); - # $passClear = <>; - # $passClear = decode_base64($passClear); - # #warn("Debug: Pass: '$pass'"); - # if ($passClear eq '*') { - # $session->respond(501, "Authentification canceled"); - # return DECLINED; - # } - # } - # } elsif ( $mechanism eq "cram-md5" ) { # rand() is not cryptographic, but we only need to generate a globally