@@ -227,6 +227,31 @@ sub new {
227
227
return $self ;
228
228
}
229
229
230
+ sub find_password_entry {
231
+ my ($cvspass , @cvsroot ) = @_ ;
232
+ my ($file , $delim ) = @$cvspass ;
233
+ my $pass ;
234
+ local ($_ );
235
+
236
+ if (open (my $fh , $file )) {
237
+ # :pserver:[email protected] :/cvsroot/zmailer Ah<Z
238
+ CVSPASSFILE:
239
+ while (<$fh >) {
240
+ chomp ;
241
+ s / ^\/\d +\s +// ;
242
+ my ($w , $p ) = split ($delim ,$_ ,2);
243
+ for my $cvsroot (@cvsroot ) {
244
+ if ($w eq $cvsroot ) {
245
+ $pass = $p ;
246
+ last CVSPASSFILE;
247
+ }
248
+ }
249
+ }
250
+ close ($fh );
251
+ }
252
+ return $pass ;
253
+ }
254
+
230
255
sub conn {
231
256
my $self = shift ;
232
257
my $repo = $self -> {' fullrep' };
@@ -259,19 +284,23 @@ sub conn {
259
284
if ($pass ) {
260
285
$pass = $self -> _scramble($pass );
261
286
} else {
262
- open (H,$ENV {' HOME' }." /.cvspass" ) and do {
263
- # :pserver:[email protected] :/cvsroot/zmailer Ah<Z
264
- while (<H>) {
265
- chomp ;
266
- s / ^\/\d +\s +// ;
267
- my ($w ,$p ) = split (/ \s / ,$_ ,2);
268
- if ($w eq $rr or $w eq $rr2 ) {
269
- $pass = $p ;
270
- last ;
271
- }
287
+ my @cvspass = ([$ENV {' HOME' }." /.cvspass" , qr /\s / ],
288
+ [$ENV {' HOME' }." /.cvs/cvspass" , qr / =/ ]);
289
+ my @loc = ();
290
+ foreach my $cvspass (@cvspass ) {
291
+ my $p = find_password_entry($cvspass , $rr , $rr2 );
292
+ if ($p ) {
293
+ push @loc , $cvspass -> [0];
294
+ $pass = $p ;
272
295
}
273
- };
274
- $pass = " A" unless $pass ;
296
+ }
297
+
298
+ if (1 < @loc ) {
299
+ die (" Multiple cvs password files have " .
300
+ " entries for CVSROOT $opt_d : @loc " );
301
+ } elsif (!$pass ) {
302
+ $pass = " A" ;
303
+ }
275
304
}
276
305
277
306
my ($s , $rep );
0 commit comments