summaryrefslogtreecommitdiff
path: root/infra/dgit-mirror-ssh-wrap
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-09-16 15:31:50 -0700
committerSean Whitton <spwhitton@spwhitton.name>2019-09-16 15:31:50 -0700
commitb773eefd1773bc2195f87f03721c89f7efb498f3 (patch)
treeb5e6e444b9f0786132a8f798bd6141878521cf7d /infra/dgit-mirror-ssh-wrap
parent1045e26443f21378d6fb98a46ace40c0d883cea6 (diff)
parent896c94474922bc2698474c5ba57321fa61504238 (diff)
Merge tag 'debian/9.9' into buster-bpo
dgit release 9.9 for unstable (sid) [dgit] [dgit distro=debian no-split] # gpg: Signature made Sat 14 Sep 2019 01:35:57 PM MST # gpg: using RSA key 559AE46C2D6B6D3265E7CBA1E3E3392348B50D39 # gpg: Can't check signature: No public key
Diffstat (limited to 'infra/dgit-mirror-ssh-wrap')
-rwxr-xr-xinfra/dgit-mirror-ssh-wrap37
1 files changed, 37 insertions, 0 deletions
diff --git a/infra/dgit-mirror-ssh-wrap b/infra/dgit-mirror-ssh-wrap
new file mode 100755
index 0000000..3feb6dc
--- /dev/null
+++ b/infra/dgit-mirror-ssh-wrap
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+
+# Intended to be used as a restricted command.
+# Usage:
+# command="/path/to/dgit-mirror-ssh-wrap /srv/repos/ .git --"
+# or similar. The two substantive arguments are literals.
+# The example permits writes to directories
+# /srv/repos/$PACKAGE.git
+# where $PACKAGE has the syntax of a Debian package name.
+
+use strict;
+
+die 'bad usage' unless @ARGV==3 && $ARGV[2] eq '--';
+our ($prefix, $suffix) = @ARGV;
+
+$prefix =~ s/\W/\\$&/g;
+$suffix =~ s/\W/\\$&/g;
+
+my $package = qr{[0-9a-z][-+.0-9a-z]*};
+my $d = qr{$prefix$package$suffix};
+
+my $command = $ENV{SSH_ORIGINAL_COMMAND}
+ // die "missing SSH_ORIGINAL_COMMAND";
+
+#print STDERR ">$d<\n";
+
+$command =~
+
+m{^rsync --server -lHtre\.iLsfxC --timeout=\d+ --delete --safe-links \. $d$}
+
+# To add a new command pattern, add || m{^ ... $} above.
+# The pattern should contain $d where the per-package destination
+# directory would go.
+
+or die "unexpected command $command\n";
+
+exec $& or die $!;