Skip to content

Commit 91a6bf4

Browse files
author
Martin Langhoff
committed
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.
1 parent 8bc63c9 commit 91a6bf4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

git-cvsserver.perl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,31 @@
8787
my $TEMP_DIR = tempdir( CLEANUP => 1 );
8888
$log->debug("Temporary directory is '$TEMP_DIR'");
8989

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+
90115
# Keep going until the client closes the connection
91116
while (<STDIN>)
92117
{
@@ -165,6 +190,7 @@ sub req_Root
165190
print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n";
166191
print "E \n";
167192
print "error 1 GITCVS emulation disabled\n";
193+
return 0;
168194
}
169195

170196
if ( defined ( $cfg->{gitcvs}{logfile} ) )
@@ -173,6 +199,8 @@ sub req_Root
173199
} else {
174200
$log->nofile();
175201
}
202+
203+
return 1;
176204
}
177205

178206
# Global_option option \n
@@ -914,6 +942,12 @@ sub req_ci
914942

915943
$log->info("req_ci : " . ( defined($data) ? $data : "[NULL]" ));
916944

945+
if ( @ARGV && $ARGV[0] eq 'pserver')
946+
{
947+
print "error 1 pserver access cannot commit\n";
948+
exit;
949+
}
950+
917951
if ( -e $state->{CVSROOT} . "/index" )
918952
{
919953
print "error 1 Index already exists in git repo\n";

0 commit comments

Comments
 (0)