mkdumprd: use array to store ssh arguments in mkdir_save_path_ssh
upstream: fedora
resolves: bz2003832
conflict: none
commit 3a4b0351d0
Author: Kairui Song <kasong@redhat.com>
Date: Wed Aug 18 15:45:20 2021 +0800
mkdumprd: use array to store ssh arguments in mkdir_save_path_ssh
For storing arguments, plain string is not a good choice. Array is
preferred:
See: https://github.com/koalaman/shellcheck/wiki/SC2089
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
parent
9658700a8b
commit
1539061bbe
8
mkdumprd
8
mkdumprd
@ -111,20 +111,20 @@ get_ssh_size() {
|
||||
mkdir_save_path_ssh()
|
||||
{
|
||||
local _opt _dir
|
||||
_opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
|
||||
ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
|
||||
_opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes)
|
||||
ssh -qn "${_opt[@]}" $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
perror_exit "mkdir failed on $1:$SAVE_PATH"
|
||||
fi
|
||||
|
||||
#check whether user has write permission on $1:$SAVE_PATH
|
||||
_dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
|
||||
_dir=$(ssh -qn "${_opt[@]}" $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination"
|
||||
fi
|
||||
ssh -qn $_opt $1 rmdir $_dir
|
||||
ssh -qn "${_opt[@]}" $1 rmdir $_dir
|
||||
|
||||
return 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user