All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Lichtenheld <frank@lichtenheld.de>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <junkio@cox.net>,
	Frank Lichtenheld <frank@lichtenheld.de>
Subject: [PATCH] cvsserver: Handle 'cvs login'
Date: Sun, 27 May 2007 14:33:10 +0200	[thread overview]
Message-ID: <11802692303581-git-send-email-frank@lichtenheld.de> (raw)
In-Reply-To: <1180269190126-git-send-email-frank@lichtenheld.de>

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>
---
 git-cvsserver.perl              |    8 +++++---
 t/t9400-git-cvsserver-server.sh |   29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 1de5177..2b4825a 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -95,9 +95,10 @@ $state->{method} = 'ext';
 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";
@@ -109,10 +110,11 @@ if (@ARGV && $ARGV[0] eq 'pserver') {
     }
     $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...
 }
 
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 76a9b1a..e9ef315 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -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$"'
@@ -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
-- 
1.5.2-rc3.GIT

      parent reply	other threads:[~2007-05-27 12:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-27 12:33 Various git-cvsserver patches Frank Lichtenheld
2007-05-27 12:33 ` [PATCH] cvsserver: Correct inetd.conf example in asciidoc documentation Frank Lichtenheld
2007-05-27 12:33 ` [PATCH] cvsserver: Note that CVS_SERVER can also be specified as method variable Frank Lichtenheld
2007-05-27 12:33 ` [PATCH] cvsserver: Fix some typos in asciidoc documentation Frank Lichtenheld
2007-05-27 12:33 ` [PATCH] t9400: Work around CVS' deficiencies Frank Lichtenheld
2007-05-27 12:33 ` Frank Lichtenheld [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11802692303581-git-send-email-frank@lichtenheld.de \
    --to=frank@lichtenheld.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.