summaryrefslogtreecommitdiff
path: root/git-daemon
diff options
context:
space:
mode:
authorTony Finch <dot@dotat.at>2010-03-30 17:45:36 +0000
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>2010-05-22 15:54:41 +0100
commit08e30b5e72511f4d6b026b40ab3125ae05c81868 (patch)
tree85b53d57e11adae6fc89ba3cd7c51fc7f0de2883 /git-daemon
parent71d8614b3653ee42effbe98e1a6edf816c4cc0b3 (diff)
downloaduserv-utils-08e30b5e72511f4d6b026b40ab3125ae05c81868.tar.gz
git-daemon: config improvements
Get configuration file(s) from the command line. Reverse order of return values so user configs can just return the repo pathname.
Diffstat (limited to 'git-daemon')
-rw-r--r--git-daemon/git-daemon-urlmap.pl10
-rwxr-xr-xgit-daemon/git-daemon.pl16
2 files changed, 15 insertions, 11 deletions
diff --git a/git-daemon/git-daemon-urlmap.pl b/git-daemon/git-daemon-urlmap.pl
index 18bf722..5f587be 100644
--- a/git-daemon/git-daemon-urlmap.pl
+++ b/git-daemon/git-daemon-urlmap.pl
@@ -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
diff --git a/git-daemon/git-daemon.pl b/git-daemon/git-daemon.pl
index 9404cca..efb45b1 100755
--- a/git-daemon/git-daemon.pl
+++ b/git-daemon/git-daemon.pl
@@ -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,
);