@matheusbsbs / matheus-bagliano / commits / 91a6bf4682
Fork 0

cvsserver: anonymous cvs via pserver support

git-cvsserver now knows how to do the pserver auth chat when the user is anonymous. To get it to work, add a line to your inetd.conf like cvspserver stream tcp nowait nobody git-cvsserver pserver (On some inetd implementations you may have to put the pserver parameter twice.) Commits are blocked. Naively, git-cvsserver assumes non-malicious users. Please review the code before setting this up on an internet-accessible server. NOTE: the <nobody> user above will need write access to the .git directory to maintain the sqlite database. Updating of the sqlite database should be put in an update hook to avoid this problem, so that it is maintained by users with write access.

Martin Langhoff committed Mar 4, 2006 at 20:30 UTC 91a6bf468230d63c414a21adeef94f1242eaaaab
1 file changed +34
git-cvsserver.perl
+34
@@ -87,6 +87,31 @@ $log->info("--------------- STARTING -----------------");
87 my $TEMP_DIR = tempdir( CLEANUP => 1 );
88 $log->debug("Temporary directory is '$TEMP_DIR'");
89
90 +# if we are called with a pserver argument,
91 +# deal with the authentication cat before entereing the
92 +# main loop
93 +if (@ARGV && $ARGV[0] eq 'pserver') {
94 + my $line = <STDIN>; chomp $line;
95 + unless( $line eq 'BEGIN AUTH REQUEST') {
96 + die "E Do not understand $line - expecting BEGIN AUTH REQUEST\n";
97 + }
98 + $line = <STDIN>; chomp $line;
99 + req_Root('root', $line) # reuse Root
100 + or die "E Invalid root $line \n";
101 + $line = <STDIN>; chomp $line;
102 + unless ($line eq 'anonymous') {
103 + print "E Only anonymous user allowed via pserver\n";
104 + print "I HATE YOU\n";
105 + }
106 + $line = <STDIN>; chomp $line; # validate the password?
107 + $line = <STDIN>; chomp $line;
108 + unless ($line eq 'END AUTH REQUEST') {
109 + die "E Do not understand $line -- expecting END AUTH REQUEST\n";
110 + }
111 + print "I LOVE YOU\n";
112 + # and now back to our regular programme...
113 +}
114 +
115 # Keep going until the client closes the connection
116 while (<STDIN>)
117 {
@@ -165,6 +190,7 @@ sub req_Root
190 print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n";
191 print "E \n";
192 print "error 1 GITCVS emulation disabled\n";
193 + return 0;
194 }
195
196 if ( defined ( $cfg->{gitcvs}{logfile} ) )
@@ -173,6 +199,8 @@ sub req_Root
199 } else {
200 $log->nofile();
201 }
202 +
203 + return 1;
204 }
205
206 # Global_option option \n
@@ -914,6 +942,12 @@ sub req_ci
942
943 $log->info("req_ci : " . ( defined($data) ? $data : "[NULL]" ));
944
945 + if ( @ARGV && $ARGV[0] eq 'pserver')
946 + {
947 + print "error 1 pserver access cannot commit\n";
948 + exit;
949 + }
950 +
951 if ( -e $state->{CVSROOT} . "/index" )
952 {
953 print "error 1 Index already exists in git repo\n";