mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-08 11:52:32 +01:00
Replace -S in ssh/sftp cmd's with ssh options
The sftp commands broke if the flag -S was used to specify the path to the master-socket. For consistency reasons the occurrences in the creation of the sockets were replaced too. Change-Id: I412b6343c6ffd74208f18517a28dcba7cd2a58bb
This commit is contained in:
parent
a10d30cf1b
commit
ad03bfa5c3
@ -233,7 +233,7 @@ do_borg_ssh_con() {
|
||||
if [ "$borg_protocol" = "sftp" ]; then
|
||||
|
||||
# initial creation of a temporary directory and variables for the authorized_keys and the
|
||||
# master ssh conection
|
||||
# master ssh connection
|
||||
SCRATCH_DIR=$(mktemp --dry-run borg-helper-temp.XXXXXXXXXX)
|
||||
if test $? -ne 0 || test "x$SCRATCH_DIR" = "x" ; then
|
||||
printf "%s ERROR: mktemp failed\n" >&2
|
||||
@ -262,8 +262,8 @@ do_borg_ssh_con() {
|
||||
else
|
||||
|
||||
# open a ssh tunnel to pipe sftp traffic through and prepare cleaning up
|
||||
ssh -p ${borg_port} -f -N -M -o ControlMaster=auto -S ${SHARED_CONN} ${borg_user}@${borg_host}
|
||||
CLEANUP="ssh -S ${SHARED_CONN} -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1 ; $SCRATCH_CLEANUP"
|
||||
ssh -p ${borg_port} -f -N -M -o ControlMaster=auto -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host}
|
||||
CLEANUP="ssh -o "ControlPath=${SHARED_CONN}" -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1 ; $SCRATCH_CLEANUP"
|
||||
trap "$CLEANUP" EXIT TERM INT QUIT
|
||||
|
||||
# use sftp with -b - to get the cmd's to execute on the remote machine via stdin
|
||||
@ -307,14 +307,14 @@ EOF
|
||||
# test the read/write access on the remote repository for sftp
|
||||
if [ "$borg_protocol" == "sftp" ]; then
|
||||
if [ ! -e "$SHARED_CONN" ]; then
|
||||
ssh -p ${borg_port} -f -N -M -o ControlMaster=auto -S ${SHARED_CONN} ${borg_user}@${borg_host}
|
||||
SSH_CLEANUP="ssh -S ${SHARED_CONN} -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1"
|
||||
ssh -p ${borg_port} -f -N -M -o ControlMaster=auto -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host}
|
||||
SSH_CLEANUP="ssh -o "ControlPath=${SHARED_CONN}" -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1"
|
||||
trap "$SSH_CLEANUP" EXIT TERM INT QUIT
|
||||
fi
|
||||
echo "ls $borg_directory" | sftp -b - -o "ControlMaster=auto" -o -S $SHARED_CONN ${borg_user}@${borg_host}
|
||||
if [ $? -eq 0 ]; then
|
||||
touch /tmp/foo.bar
|
||||
output=$(echo "put /tmp/foo.bar ${borg_directory}" | sftp -o "ControlMaster=auto" -S $SHARED_CONN ${borg_user}@${borg_host})
|
||||
output=$(echo "put /tmp/foo.bar ${borg_directory}" | sftp -o "ControlMaster=auto" -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host})
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "${output}" | grep -E "remote open.+Permission denied"
|
||||
if [ $? -eq 0 ]; then
|
||||
@ -327,19 +327,19 @@ EOF
|
||||
msgBox "The sftp connection couldn't be established."
|
||||
result=255
|
||||
fi
|
||||
echo "rm ${borg_directory}/foo.bar" | sftp -o "ControlMaster=auto" -S $SHARED_CONN ${borg_user}@${borg_host}
|
||||
echo "rm ${borg_directory}/foo.bar" | sftp -o "ControlMaster=auto" -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host}
|
||||
else
|
||||
booleanBox "Remote directory does not exist" "The destination backup directory does not exist, do you want me to create it for you?"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "exit" | sftp -b - -o "ControlMaster=auto" -S $SHARED_CONN ${borg_user}@${borg_host}
|
||||
echo "exit" | sftp -b - -o "ControlMaster=auto" -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host}
|
||||
if [ $? -eq 255 ]; then
|
||||
result=255
|
||||
else
|
||||
echo "mkdir ${borg_directory}" | sftp -b - -o "ControlMaster=auto" -S $SHARED_CONN ${borg_user}@${borg_host}
|
||||
echo "mkdir ${borg_directory}" | sftp -b - -o "ControlMaster=auto" -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host}
|
||||
if [ $? -eq 0 ]; then
|
||||
result=0
|
||||
else
|
||||
output=$(echo "mkdir ${borg_directory}" | sftp -b - -o "ControlMaster=auto" -S $SHARED_CONN ${borg_user}@${borg_host})
|
||||
output=$(echo "mkdir ${borg_directory}" | sftp -b - -o "ControlMaster=auto" -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host})
|
||||
if echo "$output" | grep "remote open.+Permission denied" ; then
|
||||
result=1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user