Man page: Move the description of --info=progress2 to a better place.
[rsync/rsync.git] / support / deny-rsync
CommitLineData
5e7f63f0 1#!/bin/bash
33cc92a6
WD
2# Send an error message via the rsync-protocol to a non-daemon client rsync.
3#
4# Usage: deny-rsync "message"
5e7f63f0
MM
5
6protocol_version=29
7exit_code=4 # same as a daemon that refuses an option
8
33cc92a6 9# e.g. byte_escape 29 => \035
5e7f63f0 10function byte_escape {
33cc92a6 11 echo -ne "\\0$(printf "%o" $1)"
5e7f63f0
MM
12}
13
14msg="$1"
33cc92a6
WD
15if [ "${#msg}" -gt 254 ]; then
16 # truncate a message that is too long for this naive script to handle
17 msg="${msg:0:251}..."
5e7f63f0 18fi
33cc92a6 19msglen=$(( ${#msg} + 1 )) # add 1 for the newline we append below
5e7f63f0 20
85fd80ce 21# Send protocol version. All numbers are LSB-first 4-byte ints.
5e7f63f0
MM
22echo -ne "$(byte_escape $protocol_version)\\000\\000\\000"
23
85fd80ce 24# Send a zero checksum seed.
5e7f63f0
MM
25echo -ne "\\000\\000\\000\\000"
26
85fd80ce
WD
27# The following is equivalent to rprintf(FERROR_XFER, "%s\n", $msg).
28# 1. Message header: ((MPLEX_BASE + FERROR_XFER) << 24) + $msglen.
33cc92a6 29echo -ne "$(byte_escape $msglen)\\000\\000\\010"
85fd80ce 30# 2. The actual data.
33cc92a6
WD
31echo -E "$msg"
32
85fd80ce 33# Make sure the client gets our message, not a write failure.
33cc92a6 34sleep 1
5e7f63f0
MM
35
36exit $exit_code