Skip to content
Snippets Groups Projects
Commit ad03bfa5 authored by Emil Breiner's avatar Emil Breiner
Browse files

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
parent a10d30cf
No related branches found
No related tags found
1 merge request!36WIP: Borg helper sftp support
...@@ -233,7 +233,7 @@ do_borg_ssh_con() { ...@@ -233,7 +233,7 @@ do_borg_ssh_con() {
if [ "$borg_protocol" = "sftp" ]; then if [ "$borg_protocol" = "sftp" ]; then
# initial creation of a temporary directory and variables for the authorized_keys and the # 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) SCRATCH_DIR=$(mktemp --dry-run borg-helper-temp.XXXXXXXXXX)
if test $? -ne 0 || test "x$SCRATCH_DIR" = "x" ; then if test $? -ne 0 || test "x$SCRATCH_DIR" = "x" ; then
printf "%s ERROR: mktemp failed\n" >&2 printf "%s ERROR: mktemp failed\n" >&2
...@@ -262,8 +262,8 @@ do_borg_ssh_con() { ...@@ -262,8 +262,8 @@ do_borg_ssh_con() {
else else
# open a ssh tunnel to pipe sftp traffic through and prepare cleaning up # 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} ssh -p ${borg_port} -f -N -M -o ControlMaster=auto -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host}
CLEANUP="ssh -S ${SHARED_CONN} -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1 ; $SCRATCH_CLEANUP" CLEANUP="ssh -o "ControlPath=${SHARED_CONN}" -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1 ; $SCRATCH_CLEANUP"
trap "$CLEANUP" EXIT TERM INT QUIT trap "$CLEANUP" EXIT TERM INT QUIT
# use sftp with -b - to get the cmd's to execute on the remote machine via stdin # use sftp with -b - to get the cmd's to execute on the remote machine via stdin
...@@ -307,14 +307,14 @@ EOF ...@@ -307,14 +307,14 @@ EOF
# test the read/write access on the remote repository for sftp # test the read/write access on the remote repository for sftp
if [ "$borg_protocol" == "sftp" ]; then if [ "$borg_protocol" == "sftp" ]; then
if [ ! -e "$SHARED_CONN" ]; then if [ ! -e "$SHARED_CONN" ]; then
ssh -p ${borg_port} -f -N -M -o ControlMaster=auto -S ${SHARED_CONN} ${borg_user}@${borg_host} ssh -p ${borg_port} -f -N -M -o ControlMaster=auto -o "ControlPath=${SHARED_CONN}" ${borg_user}@${borg_host}
SSH_CLEANUP="ssh -S ${SHARED_CONN} -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1" SSH_CLEANUP="ssh -o "ControlPath=${SHARED_CONN}" -o ControlMaster=auto -O exit 'ignored' >/dev/null 2>&1"
trap "$SSH_CLEANUP" EXIT TERM INT QUIT trap "$SSH_CLEANUP" EXIT TERM INT QUIT
fi fi
echo "ls $borg_directory" | sftp -b - -o "ControlMaster=auto" -o -S $SHARED_CONN ${borg_user}@${borg_host} echo "ls $borg_directory" | sftp -b - -o "ControlMaster=auto" -o -S $SHARED_CONN ${borg_user}@${borg_host}
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
touch /tmp/foo.bar 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 if [ $? -eq 0 ]; then
echo "${output}" | grep -E "remote open.+Permission denied" echo "${output}" | grep -E "remote open.+Permission denied"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
...@@ -327,19 +327,19 @@ EOF ...@@ -327,19 +327,19 @@ EOF
msgBox "The sftp connection couldn't be established." msgBox "The sftp connection couldn't be established."
result=255 result=255
fi 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 else
booleanBox "Remote directory does not exist" "The destination backup directory does not exist, do you want me to create it for you?" 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 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 if [ $? -eq 255 ]; then
result=255 result=255
else 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 if [ $? -eq 0 ]; then
result=0 result=0
else 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 if echo "$output" | grep "remote open.+Permission denied" ; then
result=1 result=1
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment