Git-Server
view release on metacpan or search on metacpan
}
die localtime().": [$who] git-server: You don't have shell access!\n";
}
my $dir = undef;
if ($cmd =~ /^(git-[\w\-]+) (.+)$/) {
my $op = $1;
my $repo = $2;
$repo = $1, $repo =~ s/'\\''/'/g if $repo =~ /^'(.+)'$/;
$repo =~ s%(\.git|/)+$%%;
my $home = $ENV{HOME} ||= (getpwuid $<)[7];
foreach my $try ("$repo.git/.git", "$repo.git", "$repo/.git", $repo) {
if (-d $try or $try =~ s{^/+}{} && -d $try or $try =~ s{^~/}{$home/} && -d $try) {
$dir = $try;
$ENV{GIT_DIR} = abs_path $dir;
last;
}
}
# Repository sanity check:
die localtime().": [$who] git-server: You can't access '$repo' git repository\n" unless $dir && -f "$dir/config" && -d "$dir/refs" && -d "$dir/objects";
else {
if (my $count = @repo_dirs) {
print "Commandline filtering $count specified repos: OK\n";
}
else {
print "Commandline scanning $ENV{HOME} for repos: OK\n";
}
}
#3. Scan repos
-d ($ENV{HOME} ||= [getpwuid $<]->[7]) or die "HOME broken";
if (!@repo_dirs and opendir my $fh, $ENV{HOME}) {
my @nodes = readdir $fh;
closedir $fh;
foreach my $node (sort @nodes) {
push @repo_dirs, "$ENV{HOME}/$node" if -f "$ENV{HOME}/$node/config" && -d "$ENV{HOME}/$node/refs" && -d "$ENV{HOME}/$node/objects" or -f "$ENV{HOME}/$node/.git/config";
}
}
my @repo_info;
if (@repo_dirs) {
my %seen;
hooks/proxy view on Meta::CPAN
my %proxy = do { my $i=0; map { ("there".($i++?"-$i":"") => $_) } split /\n/, scalar `git config --get-all proxy.url` } or exit 0;
my $working = "$base.workingdir";
$ENV{GIT_SSH_COMMAND} = (`git config core.sshCommand 2>/dev/null` =~ /^(.+)/ ? $1 : "ssh")." -A -o SendEnv=XMODIFIERS";
$ENV{XMODIFIERS} ||= "";
($ENV{DEBUG} and !warn localtime().": [$who] git-server: DEBUG: [$base] Skipping proxy checks during $how\n") or exit 0 if $ENV{XMODIFIERS} =~ /^skip_proxy=(.*)/m and $1;
$ENV{XMODIFIERS} =~ s/^skip_proxy=.*//gm; # Clear any (false) setting
$ENV{XMODIFIERS} = "skip_proxy=1\n$ENV{XMODIFIERS}";
while ($ENV{XMODIFIERS} =~ s/\n\n/\n/g) {}
$ENV{XMODIFIERS} =~ s/\n+$//;
$ENV{USER} ||= [getpwuid $<]->[0];
$ENV{HOME} ||= [getpwuid $<]->[7];
while (my ($remote,$proxy) = each %proxy) {
# Ensure no cheater local repo urls.
# XXX: Should HTTP URLs be converted to SSH URLs on the fly to be "helpful" for known URLs, such as github.com?
next if $proxy =~ m{^(\w+://|[-.@\w]+:)}; # If it has a colon, it's probably a safe enough "remote" git URL
my $server = $ENV{SERVER_ADDR} or die "Auth required for proxy.url $proxy\n";
$proxy =~ s{^~(/?)}{$ENV{HOME}$1};
$proxy =~ s{^\Q$ENV{HOME}\E(/?)}{};
$proxy ||= "/";
$proxy = "$ENV{USER}\@$server:$proxy";
$proxy{$remote} = $proxy;
( run in 0.565 second using v1.01-cache-2.11-cpan-5735350b133 )