From 08e30b5e72511f4d6b026b40ab3125ae05c81868 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Tue, 30 Mar 2010 17:45:36 +0000 Subject: [PATCH] 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. --- git-daemon/git-daemon-urlmap.pl | 10 +++++----- git-daemon/git-daemon.pl | 16 ++++++++++------ 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, ); -- 2.30.2