Merge branch 'gr/cvsimport-alternative-cvspass-location' into maint

* gr/cvsimport-alternative-cvspass-location:
  Look for password in both CVS and CVSNT password files.
This commit is contained in:
Junio C Hamano 2011-05-13 10:44:54 -07:00
Родитель e82c74618b 58fdef0cff
Коммит 978471dcce
1 изменённых файлов: 41 добавлений и 12 удалений

Просмотреть файл

@ -227,6 +227,31 @@ sub new {
return $self;
}
sub find_password_entry {
my ($cvspass, @cvsroot) = @_;
my ($file, $delim) = @$cvspass;
my $pass;
local ($_);
if (open(my $fh, $file)) {
# :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
CVSPASSFILE:
while (<$fh>) {
chomp;
s/^\/\d+\s+//;
my ($w, $p) = split($delim,$_,2);
for my $cvsroot (@cvsroot) {
if ($w eq $cvsroot) {
$pass = $p;
last CVSPASSFILE;
}
}
}
close($fh);
}
return $pass;
}
sub conn {
my $self = shift;
my $repo = $self->{'fullrep'};
@ -259,19 +284,23 @@ sub conn {
if ($pass) {
$pass = $self->_scramble($pass);
} else {
open(H,$ENV{'HOME'}."/.cvspass") and do {
# :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
while (<H>) {
chomp;
s/^\/\d+\s+//;
my ($w,$p) = split(/\s/,$_,2);
if ($w eq $rr or $w eq $rr2) {
$pass = $p;
last;
}
my @cvspass = ([$ENV{'HOME'}."/.cvspass", qr/\s/],
[$ENV{'HOME'}."/.cvs/cvspass", qr/=/]);
my @loc = ();
foreach my $cvspass (@cvspass) {
my $p = find_password_entry($cvspass, $rr, $rr2);
if ($p) {
push @loc, $cvspass->[0];
$pass = $p;
}
};
$pass = "A" unless $pass;
}
if (1 < @loc) {
die("Multiple cvs password files have ".
"entries for CVSROOT $opt_d: @loc");
} elsif (!$pass) {
$pass = "A";
}
}
my ($s, $rep);