Skip to content

Commit 32fbc25

Browse files
author
Serghey Rodin
committed
Additional argument check for remote hosts
1 parent defba72 commit 32fbc25

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bin/v-add-backup-host

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ EOF
3838
sftpc() {
3939
expect -f "-" <<EOF "$@"
4040
set count 0
41-
spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o \
42-
Port=$port $user@$host
41+
spawn "/usr/bin/sftp -o StrictHostKeyChecking=no -o \
42+
Port=$port '$user@$host'"
4343
expect {
4444
"password:" {
4545
send "$password\r"
@@ -94,12 +94,14 @@ EOF
9494

9595
if [ "$type" != 'local' ];then
9696
check_args '4' "$#" "TYPE HOST USERNAME PASSWORD [PATH] [PORT]"
97-
is_format_valid 'host'
97+
is_format_valid 'user' 'host'
9898
is_password_valid
9999
if [ "$type" = 'sftp' ]; then
100100
which expect >/dev/null 2>&1
101101
check_result $? "expect command not found" $E_NOTEXIST
102102
fi
103+
host "$host" >/dev/null 2>&1
104+
check_result $? "host connection failed" "$E_CONNECT"
103105
fi
104106

105107

0 commit comments

Comments
 (0)