Subject: | login to pserver fails when password needs to be given. |
When you create a new object with a pserver cvsroot, it will fail if
there is not already an account in the users ~/.cvspass file, even if
a password is given.
What fails:
my $cvs = new Cvs ('/tmp/cvstmpdir' ,
cvsroot => ':pserver:alex@my.cvs.server:/path/to/repository',
password => 'secret' ) or die $Cvs::ERROR;
It doesn't die here, but after trying:
my $status = $cvs->checkout('myfile');
printf "Success: %s Error: %s", $status->success, $status->error;
the output is: "Success: 0 Error: pserver login failure"
What works:
If I do from the commandline:
cvs -d :pserver:alex@my.cvs.server:/path/to/repository login
(Logging in to alex@my.cvs.server)
CVS password: <I enter secret>
Then if I run the same code again, I don't get the error and the
checkout completes successfully.
I inserted two lines of debugging code into the Login.pm module, so
that the init function becomes as shown below. The DEBUG:1
does get printed (with correct password), but DEBUG:2 never
does get printed. It's almost like it's not seeing the interactive
password prompt issued by cvs?
Some versions of modules I'm using:
IPC-Run-0.75
IO-Tty-1.02
Class-Accessor-0.18
perl 5.8.0
uname -a: SunOS jordan 5.8 Generic_108528-03 sun4u sparc SUNW,Sun-Blade-1000
regards,
Alex.
---------------------------------------------------------------
sub init
{
my($self, $param) = @_;
$self->SUPER::init(@_) or return;
$self->default_params(cvsroot => undef);
$self->param($param);
$self->command('login');
my $result = new Cvs::Result::Login;
$self->result($result);
my $cvsroot;
if(defined $self->param->{cvsroot})
{
$cvsroot =
new Cvs::Cvsroot $self->param->{cvsroot}, %$param;
$self->cvsroot($cvsroot);
}
elsif(defined $self->cvs->cvsroot())
{
$cvsroot = $self->cvs->cvsroot();
}
else
{
$result->success(0);
$result->error('No cvsroot to login on, please define one.');
$self->command(undef);
}
my $main = $self->new_context();
$self->initial_context($main);
print "DEBUG:1 password |" . $cvsroot->password() . "|";
$main->push_handler
(
qr/^CVS password/, sub
{
print "DEBUG:2 password |" . $cvsroot->password() . "|";
$self->send($cvsroot->password()."\n");
}
);
$main->push_handler
(
qr/can only use .login. command with the .pserver. method/, sub
{
# do not fail if login was used with bad method, we don't care
$result->success(1);
$main->finish();
}
);
return $self;
}