# cvsimport does not work with passwords ?

8 messages from 2011-04-28 to 2011-04-29. Participants: Marcin Wiśnicki, Jeff King, Andreas Schwab, Junio C Hamano.
Thread: https://gitlist.dev/t/27212

## Marcin Wiśnicki, 2011-04-28 20:59

Subject: cvsimport does not work with passwords ?
Message-ID: <ipckgd$krd$2@dough.gmane.org>
URL: https://gitlist.dev/e/ipckgd%24krd%242%40dough.gmane.org

```
I have to import part of public cvs repository that is protected by 
password (which is "anoncvs"):

> export CVSROOT=:pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs
> cvs login

And now I can use cvs and cvsps, when I try git however:

> git cvsimport -vk projects/pkgtools
AuthReply: I HATE YOU

It seems that it does not send the password. From captured network 
conversation:

-> BEGIN AUTH REQUEST
-> /home/ncvs
-> anoncvs
-> A
-> END AUTH REQUEST
<- I HATE YOU

But `cat ~/.cvspass`:
/1 :pserver:anoncvs@anoncvs.fr.freebsd.org:2401/home/ncvs Ay=0=h<Z


So why is git not sending the password ?

```

## Marcin Wiśnicki, 2011-04-28 21:03

Subject: Re: cvsimport does not work with passwords ?
Message-ID: <ipcknp$krd$3@dough.gmane.org>
URL: https://gitlist.dev/e/ipcknp%24krd%243%40dough.gmane.org
In-Reply-To: <ipckgd$krd$2@dough.gmane.org>

```
On Thu, 28 Apr 2011 20:59:57 +0000, Marcin Wiśnicki wrote:

>> git cvsimport -vk projects/pkgtools
> AuthReply: I HATE YOU
> 

Forgot to mention:

> git --version
git version 1.7.4.4

```

## Marcin Wiśnicki, 2011-04-28 21:35

Subject: Re: cvsimport does not work with passwords ?
Message-ID: <ipcmjp$krd$4@dough.gmane.org>
URL: https://gitlist.dev/e/ipcmjp%24krd%244%40dough.gmane.org
In-Reply-To: <ipckgd$krd$2@dough.gmane.org>

```
On Thu, 28 Apr 2011 20:59:57 +0000, Marcin Wiśnicki wrote:

> I have to import part of public cvs repository that is protected by
> password (which is "anoncvs"):
> 
>> export CVSROOT=:pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs cvs
>> login
> 

I have tried another mirror that uses ssh:

> export CVSROOT=:ext:anoncvs@anoncvs1.FreeBSD.org:/home/ncvs
> export SSH_RSH=ssh

And this also does not work because git tries to use rsh.
According to google this should work.

Any ideas why cvsimport is so broken for me ?

```

## Jeff King, 2011-04-28 22:45

Subject: Re: cvsimport does not work with passwords ?
Message-ID: <20110428224510.GA16065@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20110428224510.GA16065%40sigill.intra.peff.net
In-Reply-To: <ipcmjp$krd$4@dough.gmane.org>

```
On Thu, Apr 28, 2011 at 09:35:53PM +0000, Marcin Wiśnicki wrote:

> I have tried another mirror that uses ssh:
> 
> > export CVSROOT=:ext:anoncvs@anoncvs1.FreeBSD.org:/home/ncvs
> > export SSH_RSH=ssh
> 
> And this also does not work because git tries to use rsh.
> According to google this should work.
> 
> Any ideas why cvsimport is so broken for me ?

It has (thankfully) been a long time since I've had to touch CVS, but
shouldn't that be CVS_RSH on the second line?

-Peff

```

## Marcin Wiśnicki, 2011-04-28 22:50

Subject: Re: cvsimport does not work with passwords ?
Message-ID: <ipcr0c$jc3$1@dough.gmane.org>
URL: https://gitlist.dev/e/ipcr0c%24jc3%241%40dough.gmane.org
In-Reply-To: <20110428224510.GA16065@sigill.intra.peff.net>

```
On Thu, 28 Apr 2011 18:45:10 -0400, Jeff King wrote:

> On Thu, Apr 28, 2011 at 09:35:53PM +0000, Marcin Wiśnicki wrote:
> 
>> I have tried another mirror that uses ssh:
>> 
>> > export CVSROOT=:ext:anoncvs@anoncvs1.FreeBSD.org:/home/ncvs export
>> > SSH_RSH=ssh
>> 
>> And this also does not work because git tries to use rsh. According to
>> google this should work.
>> 
>> Any ideas why cvsimport is so broken for me ?
> 
> It has (thankfully) been a long time since I've had to touch CVS, but
> shouldn't that be CVS_RSH on the second line?
> 
> -Peff

Ahh yes indeed. I made a silly typo, now it works.

```

## Andreas Schwab, 2011-04-29 11:33

Subject: Re: cvsimport does not work with passwords ?
Message-ID: <m2sjt1xpfj.fsf@igel.home>
URL: https://gitlist.dev/e/m2sjt1xpfj.fsf%40igel.home
In-Reply-To: <ipckgd$krd$2@dough.gmane.org>

```
Marcin Wiśnicki <mwisnicki@gmail.com> writes:

>> export CVSROOT=:pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs
> /1 :pserver:anoncvs@anoncvs.fr.freebsd.org:2401/home/ncvs Ay=0=h<Z

Note the different case.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Andreas Schwab, 2011-04-29 13:09

Subject: [PATCH] git-cvsimport: normalize hostname for password lookup
Message-ID: <m2oc3pxkyo.fsf_-_@igel.home>
URL: https://gitlist.dev/e/m2oc3pxkyo.fsf_-_%40igel.home
In-Reply-To: <m2sjt1xpfj.fsf@igel.home>

```
When looking up the pserver password in .cvspass normalize the hostname
part of the address by converting it to lowercase.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 git-cvsimport.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index bbf327f..046fe32 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -249,6 +249,8 @@ sub conn {
 
 		# if username is not explicit in CVSROOT, then use current user, as cvs would
 		$user=(getlogin() || $ENV{'LOGNAME'} || $ENV{'USER'} || "anonymous") unless $user;
+		# Normalize hostname for lookup in .cvspass
+		$serv = lc $serv;
 		my $rr2 = "-";
 		unless ($port) {
 			$rr2 = ":pserver:$user\@$serv:$repo";
@@ -263,6 +265,8 @@ sub conn {
 				# :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
 				while (<H>) {
 					chomp;
+					# FIXME: entries without version prefix
+					# may need to be normalized
 					s/^\/\d+\s+//;
 					my ($w,$p) = split(/\s/,$_,2);
 					if ($w eq $rr or $w eq $rr2) {
-- 
1.7.5


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Junio C Hamano, 2011-04-29 16:33

Subject: Re: [PATCH] git-cvsimport: normalize hostname for password lookup
Message-ID: <7v4o5hxbj1.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4o5hxbj1.fsf%40alter.siamese.dyndns.org
In-Reply-To: <m2oc3pxkyo.fsf_-_@igel.home>

```
Andreas Schwab <schwab@linux-m68k.org> writes:

> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
> index bbf327f..046fe32 100755
> --- a/git-cvsimport.perl
> +++ b/git-cvsimport.perl
> @@ -249,6 +249,8 @@ sub conn {
>  
>  		# if username is not explicit in CVSROOT, then use current user, as cvs would
>  		$user=(getlogin() || $ENV{'LOGNAME'} || $ENV{'USER'} || "anonymous") unless $user;
> +		# Normalize hostname for lookup in .cvspass
> +		$serv = lc $serv;
>  		my $rr2 = "-";
>  		unless ($port) {
>  			$rr2 = ":pserver:$user\@$serv:$repo";
> @@ -263,6 +265,8 @@ sub conn {
>  				# :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
>  				while (<H>) {
>  					chomp;
> +					# FIXME: entries without version prefix
> +					# may need to be normalized
>  					s/^\/\d+\s+//;
>  					my ($w,$p) = split(/\s/,$_,2);
>  					if ($w eq $rr or $w eq $rr2) {

If I correctly recall what I found out from cvs's changelog while looking at
http://thread.gmane.org/gmane.comp.version-control.git/163979/focus=167178 
I think the versioned entries are already downcased, so the above,
including the "FIXME", looks correct.

As I wrote in another message in that thread, I think this codepath should
be refactored a bit better so that it can handle subtle differences
between versions and implementations of cvs itself, and also these
versioned entries.  A good first step might be to separate out the body of
the innermost loop we see here that process one entry from the cvspass
file into a helper function.

Can you give an eyeball on the update of 077aac1 (Look for password in
both CVS and CVSNT password files., 2011-02-18) posted by Guy Rouillier
today and help testing it, and put this fix on top that?

Thanks.

```
