diff --git a/src/gitolite.pm b/src/gitolite.pm index 8120526..fbae91d 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -132,6 +132,19 @@ sub wrap_print { chmod $oldmode, $file if $oldmode; } +sub wrap_system { + system(@_); + + # straight from 'perldoc -f system' (sans the coredump part) + if ( $? == -1 ) { + print STDERR "failed to execute: $!\n"; + } elsif ( $? & 127 ) { + printf STDERR "child died with signal %d\n", ( $? & 127 ); + } else { + printf STDERR "child exited with value %d\n", $? >> 8; + } +} + sub slurp { local $/ = undef; my $fh = wrap_open("<", $_[0]); diff --git a/src/gl-mirror-push b/src/gl-mirror-push index 70514cb..e7054e2 100755 --- a/src/gl-mirror-push +++ b/src/gl-mirror-push @@ -25,6 +25,7 @@ hn=`get_rc_val GL_HOSTNAME` # get repo name then check if it's a local or slave (ie we're not the master) [ -z "$1" ] && die fatal: missing reponame argument repo=$1; shift +repo=${repo%.git} REPO_BASE=`get_rc_val REPO_BASE` cd $REPO_BASE/$repo.git 2>/dev/null || die fatal: could not change directory to "$repo" diff --git a/src/gl-mirror-shell b/src/gl-mirror-shell index e6b25c6..80534dc 100755 --- a/src/gl-mirror-shell +++ b/src/gl-mirror-shell @@ -52,6 +52,7 @@ critical for you to just run it based on a 'usage' message.\n" if not @ARGV or $ if ( ($ARGV[0] || '') eq 'request-push' and not $ENV{SSH_ORIGINAL_COMMAND} ) { shift; my $repo = shift or die "fatal: missing reponame\n"; + $repo =~ s/\.git$//; -d "$REPO_BASE/$repo.git" or die "fatal: no such repo?\n"; # this is the default argument if no slave list or key is supplied @@ -110,6 +111,7 @@ if ($soc eq 'info') { if ($soc =~ /^git-receive-pack '(\S+)'$/) { my $repo = $1; + $repo =~ s/\.git$//; die "fatal: invalid characters in $repo\n" unless $repo =~ $REPONAME_PATT; my $mm = mirror_mode($repo); @@ -137,11 +139,12 @@ if ($soc =~ /^git-receive-pack '(\S+)'$/) { if ($soc =~ /^request-push (\S+)$/) { my $repo = $1; + $repo =~ s/\.git$//; die "fatal: invalid characters in $repo\n" unless $repo =~ $REPONAME_PATT; die "$ABRT fatal: $GL_HOSTNAME ==//==> $sender refused: not in slave list\n" unless mirror_listslaves($repo) =~ /(^|\s)$sender(\s|$)/; print STDERR "$GL_HOSTNAME ==== ($repo) ===> $sender\n"; # just one sender, and we've checked that he is "on the list". Foreground... - system("$ENV{GL_BINDIR}/gl-mirror-push", $repo, "-fg", $sender); + wrap_system("$ENV{GL_BINDIR}/gl-mirror-push", $repo, "-fg", $sender); exit; } @@ -159,6 +162,8 @@ if ($soc =~ /^USER=(\S+) SOC=(git-receive-pack '(\S+)')$/) { my $user = $1; $ENV{SSH_ORIGINAL_COMMAND} = $2; my $repo = $3; + $repo =~ s/\.git$//; + $repo =~ s(^/)(); die "fatal: invalid characters in $user\n" unless $user =~ $USERNAME_PATT; die "fatal: invalid characters in $repo\n" unless $repo =~ $REPONAME_PATT; die "$ABRT fatal: $GL_HOSTNAME <==//== $sender redirected push rejected\n" unless mirror_redirectOK($repo, $sender);