Subject: | Problem with authmechanism=PLAIN [Fwd: root <root@hermes.ulaval.ca>] |
From: | Carl Provencher <Carl.Provencher [...] sit.ulaval.ca> |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
Date: | Wed, 17 Mar 2004 17:04:05 -0500 |
Sorry, I click send so fast ;-)
I explain my problem with authmechanism in IMAPClient.
I use IMAPClient to access our cyrus-imapd server with PLAIN SASL
mechanism (see chapter 6. in
ftp://ftp.rfc-editor.org/in-notes/rfc2595.txt)
part of my code:
$imap = Mail::IMAPClient->new(Server => 'localhost',
User => $user,
Proxy => $self->{'mailadmin'},
Password => $self->{'mailadmin_password'},
Port => 143,
Authmechanism => "PLAIN",
Authcallback => sub {
use MIME::Base64;
shift;
my $self = shift;
return encode_base64($self->{'User'} . chr(0) . $self->{'Proxy'} . chr(0) . $self->{'Password'});
} );
We add Proxy to implemented this auth mechanisme.
When I execute my program, I had this error:
Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/site_perl/5.6.1/Mail/IMAPClient.pm line 3479.
It's normal because with this code in IMAPClient.pm 3465-3479:
my ($code, $output);
until ($code or $scheme eq "PLAIN") {
$output = $self->_read_line or return undef;
foreach my $o (@$output) {
$self->_record($count,$o); # $o is a ref
($code) = $o->[DATA] =~ /^\+(.*)$/ ;
if ($o->[DATA] =~ /^\*\s+BYE/) {
$self->State(Unconnected);
return undef ;
}
}
}
return undef if $code =~ /^BAD|^NO/ ;
Because $code is defined empty in line 3465 and $scheme is eq "PLAIN" it
goes directly to the line 3479 and $code is always "uninitialized".
I suggested this patch to solve this little issue. If I made a use error, don't hesitate to correct me.
Have a nice day.
The patch:
*** /usr/lib/perl5/site_perl/5.6.1/Mail/IMAPClient.pm Wed Mar 17 16:03:53 2004
--- /usr/lib/perl5/site_perl/5.6.1/Mail/IMAPClient.pm.arch1.old Mon Oct 27 14:50:25 2003
***************
*** 113,119 ****
EnableServerResponseInLiteral
Authmechanism Authcallback Ranges
Readmethod Showcredentials
! Prewritemethod Proxy
)
) {
no strict 'refs';
--- 113,119 ----
EnableServerResponseInLiteral
Authmechanism Authcallback Ranges
Readmethod Showcredentials
! Prewritemethod
)
) {
no strict 'refs';
***************
*** 3463,3471 ****
}
my ($code, $output);
- $code = "";
! until ($code or $scheme eq "PLAIN") {
$output = $self->_read_line or return undef;
foreach my $o (@$output) {
$self->_record($count,$o); # $o is a ref
--- 3463,3470 ----
}
my ($code, $output);
! until ($code) {
$output = $self->_read_line or return undef;
foreach my $o (@$output) {
$self->_record($count,$o); # $o is a ref
--
Show quoted text
____________________________________________________________________
Carl Provencher
S.I.T., Université Laval
Tél.: (418) 656-2131 poste 8719