sshtunnel: allow empty port and user
authorSergey Ponomarev <stokito@gmail.com>
Wed, 21 Jun 2023 17:01:31 +0000 (20:01 +0300)
committerNuno Goncalves <nunojpg@gmail.com>
Sun, 8 Oct 2023 09:29:37 +0000 (10:29 +0100)
A user may have some host configured in the .ssh/config with user and port.
But we anyway have to specify them in the sshtunnel.
The change fixes this

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
net/sshtunnel/files/sshtunnel.init

index bff5cfdbed30c8ac34734a0c228adfde48689701..8b8f97f933a44810aa6f0af93070a81587033308 100644 (file)
@@ -191,7 +191,10 @@ load_server() {
        # dbclient doesn't support StrictHostKeyChecking but it has the -y option that works same
        [ "$StrictHostKeyChecking" = "accept-new" ] && ARGS_options="$ARGS_options -y"
        [ "$StrictHostKeyChecking" = "no" ] && ARGS_options="$ARGS_options -yy"
-       ARGS="$ARGS_options -o ExitOnForwardFailure=yes -o BatchMode=yes -nN $ARGS_tunnels -p $port $user@$hostname"
+       ARGS="$ARGS_options -o ExitOnForwardFailure=yes -o BatchMode=yes -nN $ARGS_tunnels "
+       [ -n "$port" ] && ARGS="$ARGS -p $port "
+       [ -n "$user" ] && ARGS="$ARGS $user@"
+       ARGS="${ARGS}$hostname"
 
        procd_open_instance "$server"
        procd_set_param command "$PROG" $ARGS