From ba4afebe09f4f289be4a0edc06441f334937761e Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Sat, 17 Jun 2023 19:38:33 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20:=20r=C3=A9=C3=A9criture=20de=20vn?= =?UTF-8?q?csconnect.=20ssh-fwd=20{=20Correction=20:=20shift=20avant=20de?= =?UTF-8?q?=20break=20dans=20l'analyse=20d'arguments=20;=20arguments=20?= =?UTF-8?q?=C3=A0=20la=20fin=20pour=20pouvoir=20ex=C3=A9cuter=20des=20comm?= =?UTF-8?q?andes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/ssh-fwd | 5 +++-- bin/vncsconnect | 60 +++++++++++++++++++++++++------------------------ 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/bin/ssh-fwd b/bin/ssh-fwd index 0f5c81b..86f5158 100755 --- a/bin/ssh-fwd +++ b/bin/ssh-fwd @@ -38,6 +38,7 @@ requested_port_bridge_pid() { while [ -n "$1" ]; do case "$1" in --) + shift break ;; *) @@ -55,11 +56,11 @@ fi pid="$(requested_port_bridge_pid "${args[1]}")" if [ -z "$pid" ]; then exec "${ssh[@]}" \ - "$@" \ -f \ -N \ -L "${args[1]}:${args[3]:-localhost}:${args[2]}" \ - "${args[0]}" + "${args[0]}" \ + "$@" else echo "Suppression de la redirection..." kill "$pid" diff --git a/bin/vncsconnect b/bin/vncsconnect index a2469e3..a7dcbe4 100755 --- a/bin/vncsconnect +++ b/bin/vncsconnect @@ -1,37 +1,39 @@ #!/bin/bash # Variables -declare -a make_ssh_bridge open_vnc_session -ssh_fwd=ssh-fwd -vncviewer=wlvncc -localhost=localhost +declare -a ssh_args + +# Sélectionner le viewer adapté à la session +if [ -n "$WAYLAND_DISPLAY" ]; then + vncviewer=wlvncc +else + vncviewer=vncviewer + separator=: +fi # Arguments -ssh_host="$1" ; shift -local_port="${1:-9900}" ; shift -distant_port="${1:-5900}"; shift -target="$1" ; shift +while [ -n "$1" ]; do + case "$1" in + --) + shift + break + ;; + *) + ssh_args+=("$1") + shift + ;; + esac +done -# Commands building -# Make SSH bridge -make_ssh_bridge+=( - "$ssh_fwd" - "$ssh_host" - "$local_port" - "$distant_port" - "$target" -) +# Initialiser les arguments du viewer +args=(localhost "${ssh_args[1]}") +if [ -n "$separator" ]; then + args=("${args[*]// /${separator}/}") +fi -# Open VNC session -open_vnc_session+=( - "$vncviewer" - "$@" - "${localhost}" - "${local_port}" -) - -# Execution -set -xe -"${make_ssh_bridge[@]}" -"${open_vnc_session[@]}" +# Exécution +set -e +ssh-fwd "${ssh_args[@]}" -- "$@" +exec "$vncviewer" \ + "${args[@]}"