chiark / gitweb /
git-daemon: config improvements
authorTony Finch <dot@dotat.at>
Tue, 30 Mar 2010 17:45:36 +0000 (17:45 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 22 May 2010 14:54:41 +0000 (15:54 +0100)
Get configuration file(s) from the command line. Reverse order of
return values so user configs can just return the repo pathname.

git-daemon/git-daemon-urlmap.pl
git-daemon/git-daemon.pl

index 18bf722f8b0e1f36bc2a5d2516234e2529f6caf1..5f587be08647bf1a034f94eb9f645dcfb152330d 100644 (file)
@@ -10,11 +10,11 @@ use strict;
 my $g = qr{[0-9a-z_-]+[.]git};
 my $u = qr{[0-9a-z]+};
 
-return "fanf"      => "~fanf/public-git/$1" if m{^git://dotat[.]at/($g)$};
-return "webmaster" => "/u2/git-repos$1"     if m{^git://git[.]chiark[.]greenend[.]org[.]uk/($g)$};
-return "$1"        => "~$1/public-git/$2"   if m{^git://git[.]chiark[.]greenend[.]org[.]uk/~($u)/($g)$};
-return "$1"        => "~$1/cabal-git/$2"           if m{^git://cabal[.]greenend[.]org[.]uk/~($u)/($g)$};
+return "~fanf/public-git/$1", "fanf"      if m{^git://dotat[.]at/($g)$};
+return "/u2/git-repos$1",     "webmaster" if m{^git://git[.]chiark[.]greenend[.]org[.]uk/($g)$};
+return "~$1/public-git/$2",   "$1"        if m{^git://git[.]chiark[.]greenend[.]org[.]uk/~($u)/($g)$};
+return "~$1/cabal-git/$2",    "$1"               if m{^git://cabal[.]greenend[.]org[.]uk/~($u)/($g)$};
 
-return undef;
+return;
 
 # end
index 9404ccaf88c888df7a051c2887b015a87f878ebb..efb45b121491ea810a8321e65b680aed358d212d 100755 (executable)
@@ -13,8 +13,6 @@ use POSIX;
 use Socket;
 use Sys::Syslog;
 
-use lib '/etc/userv'; # for git-daemon-urlmap.pl
-
 sub ntoa {
     my $sockaddr = shift;
     if (defined $sockaddr) {
@@ -60,20 +58,26 @@ unless ($line =~ m{^(git-[a-z-]+) ([!-~]+)\0host=([!-~]+)\0$}) {
     fail "could not parse \"$line\""
 }
 my ($service,$path,$host) = ($1,$2,3);
-$path =~ s|^/||;
-$_ = my $uri = "git://$host/$path";
+$path =~ s|^/*||;
+my $uri = $_ = "git://$host/$path";
 
-my ($user,$repo) = do "git-daemon-urlmap.pl";
+my $user;
+for my $cf (@ARGV) {
+    my ($r,$u) = do $cf;
+    $user = $u if defined $u;
+}
 fail "no user configured for $uri" unless defined $user;
-syslog 'info', "$client userv $user git-upload-pack $uri";
+syslog 'info', "$client userv $user $service $uri";
 
 my %vars = (
     REQUEST_SERVICE => $service,
     REQUEST_HOST => $host,
     REQUEST_PATH => $path,
     REQUEST_URI => $uri,
+    CLIENT => $client,
     CLIENT_ADDR => $client_addr,
     CLIENT_PORT => $client_port,
+    SERVER => $server,
     SERVER_ADDR => $server_addr,
     SERVER_PORT => $server_port,
 );