mirroring: fix several minor issues related to 'reponame.git'
- git prepends a '/' when people use the full form of an ssh URL. Since I *never* use those, (I prefer setting an ssh host alias and just saying 'git95:gitolite' for example), I never caught this. - people will also append a '.git'. It's supposed to work either way, but it wasn't. I had missed a few places where the user might send in 'reponame.git' and was implicitly assuming it would be 'reponame' - finally, we slip-streamed in a wrapper for system() Big thanks and kudos to Michael Brown for catching these issues, and (hopefully, heh!) testing my fixes ;-)
This commit is contained in:
parent
a8a3792759
commit
233a33deff
|
@ -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]);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue