From ad03bfa5c304fdc1d206c7da059e52ddef0cb639 Mon Sep 17 00:00:00 2001 From: Emil Breiner Date: Wed, 25 Nov 2020 10:19:06 +0100 Subject: [PATCH] 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 --- handlers/borg.helper.in | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/handlers/borg.helper.in b/handlers/borg.helper.in index 98a8cbd..d8d01b8 100644 --- a/handlers/borg.helper.in +++ b/handlers/borg.helper.in @@ -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