3 # Copyright (c) 2009, 2010, 2012 Peter Palfrader
4 # Copyright (c) 2015 Aurelien Jarno
6 # Permission is hereby granted, free of charge, to any person obtaining
7 # a copy of this software and associated documentation files (the
8 # "Software"), to deal in the Software without restriction, including
9 # without limitation the rights to use, copy, modify, merge, publish,
10 # distribute, sublicense, and/or sell copies of the Software, and to
11 # permit persons to whom the Software is furnished to do so, subject to
12 # the following conditions:
14 # The above copyright notice and this permission notice shall be
15 # included in all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 MYLOGNAME="`basename "$0"`[$$]"
29 RSYNCDIR="/srv/upload.debian.org/UploadQueue/"
32 echo "local Usage: $0 <host>"
33 echo "via ssh orig command: rsync <stuff>"
37 if [ "$#" -lt 1 ]; then
44 logger -p daemon.info -t "$MYLOGNAME" "$1"
48 logger -s -p daemon.warn -t "$MYLOGNAME" "$1"
53 local remote_host="$1"
59 if [ -d "$RSYNCDIR" ]; then
60 allowed_rsyncs+=("--server -vlogDtprxze.iLsf --partial . $RSYNCDIR") # wheezy
61 allowed_rsyncs+=("--server -vlogDtprxze.iLsfx --partial . $RSYNCDIR") # jessie
62 allowed_rsyncs+=("--server -vlogDtprxze.iLsfxC --partial . $RSYNCDIR") # stretch
64 for cmd_idx in ${!allowed_rsyncs[*]}; do
65 allowed="${allowed_rsyncs[$cmd_idx]}"
66 if [ "$*" = "$allowed" ]; then
67 info "Running for host $remote_host: rsync $*"
73 info "NOT allowed for $remote_host: rsync $*"
74 echo >&2 "This rsync command ($@) not allowed."
78 if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
88 # check/parse remote command line
89 if [ -z "${SSH_ORIGINAL_COMMAND:-}" ] ; then
90 croak "Did not find SSH_ORIGINAL_COMMAND"
92 set "dummy" ${SSH_ORIGINAL_COMMAND}
95 info "host $remote_host called with $*"
102 # rsync command to upload packages
104 do_rsync "$remote_host" "$@"
106 # just ignore any other commands (e.g. chmod)
108 info "Ignored operation '$action'"