Skip to content

Commit

Permalink
cvsserver: Handle 'cvs login'
Browse files Browse the repository at this point in the history
Since this is a trivial variation of the general pserver
authentication, there is really no reason not to support
it.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Frank Lichtenheld authored and Junio C Hamano committed May 29, 2007
1 parent b3c81cf commit 24a97d8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
8 changes: 5 additions & 3 deletions git-cvsserver.perl
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@
if (@ARGV && $ARGV[0] eq 'pserver') {
$state->{method} = 'pserver';
my $line = <STDIN>; chomp $line;
unless( $line eq 'BEGIN AUTH REQUEST') {
unless( $line =~ /^BEGIN (AUTH|VERIFICATION) REQUEST$/) {
die "E Do not understand $line - expecting BEGIN AUTH REQUEST\n";
}
my $request = $1;
$line = <STDIN>; chomp $line;
req_Root('root', $line) # reuse Root
or die "E Invalid root $line \n";
Expand All @@ -109,10 +110,11 @@
}
$line = <STDIN>; chomp $line; # validate the password?
$line = <STDIN>; chomp $line;
unless ($line eq 'END AUTH REQUEST') {
die "E Do not understand $line -- expecting END AUTH REQUEST\n";
unless ($line eq "END $request REQUEST") {
die "E Do not understand $line -- expecting END $request REQUEST\n";
}
print "I LOVE YOU\n";
exit if $request eq 'VERIFICATION'; # cvs login
# and now back to our regular programme...
}

Expand Down
29 changes: 29 additions & 0 deletions t/t9400-git-cvsserver-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ git
END AUTH REQUEST
EOF

cat >login-anonymous <<EOF
BEGIN VERIFICATION REQUEST
$SERVERDIR
anonymous
END VERIFICATION REQUEST
EOF

cat >login-git <<EOF
BEGIN VERIFICATION REQUEST
$SERVERDIR
git
END VERIFICATION REQUEST
EOF

test_expect_success 'pserver authentication' \
'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
tail -n1 log | grep -q "^I LOVE YOU$"'
Expand All @@ -80,6 +96,19 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \
fi &&
tail -n1 log | grep -q "^I HATE YOU$"'

test_expect_success 'pserver authentication (login)' \
'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
tail -n1 log | grep -q "^I LOVE YOU$"'

test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
'if cat login-git | git-cvsserver pserver >log 2>&1
then
false
else
true
fi &&
tail -n1 log | grep -q "^I HATE YOU$"'


#--------------
# CONFIG TESTS
Expand Down

0 comments on commit 24a97d8

Please sign in to comment.