diff -Nru x2gobroker-0.0.4.4/debian/changelog x2gobroker-0.0.4.4/debian/changelog --- x2gobroker-0.0.4.4/debian/changelog 2024-03-27 16:23:48.000000000 +0000 +++ x2gobroker-0.0.4.4/debian/changelog 2024-03-28 18:46:43.000000000 +0000 @@ -1,8 +1,8 @@ -x2gobroker (0.0.4.4-0~202402291243~ubuntu24.04.1) noble; urgency=low +x2gobroker (0.0.4.4-0~202403281835~ubuntu24.04.1) noble; urgency=low * Auto build. - -- X2Go Wed, 27 Mar 2024 16:23:48 +0000 + -- X2Go Thu, 28 Mar 2024 18:46:43 +0000 x2gobroker (0.0.4.4-0x2go1) UNRELEASED; urgency=medium @@ -23,6 +23,12 @@ * debian/x2gobroker-ssh-mini.insall: + Pick files as installed by Makefile. + [ Stefan Baur ] + * New upstream version (0.0.4.4): + - mini/x2gobroker-ssh-mini: typo fix referencing PORT variable. + - mini/x2gobroker-ssh-mini: add missing hostname/IP and port + autodetection. + -- Mike Gabriel Mon, 15 Nov 2021 15:33:29 +0100 x2gobroker (0.0.4.3-0x2go1) unstable; urgency=medium diff -Nru x2gobroker-0.0.4.4/debian/git-build-recipe.manifest x2gobroker-0.0.4.4/debian/git-build-recipe.manifest --- x2gobroker-0.0.4.4/debian/git-build-recipe.manifest 2024-03-27 16:23:48.000000000 +0000 +++ x2gobroker-0.0.4.4/debian/git-build-recipe.manifest 2024-03-28 18:46:43.000000000 +0000 @@ -1,2 +1,2 @@ -# git-build-recipe format 0.4 deb-version {debupstream}-0~202402291243 -lp:~x2go/x2go/+git/x2gobroker git-commit:a3fd2e7a68f656578ef74eefd97bb19b0cca6203 +# git-build-recipe format 0.4 deb-version {debupstream}-0~202403281835 +lp:~x2go/x2go/+git/x2gobroker git-commit:85b0de53fbb0f4b4318214cff9e33c9c55c4182c diff -Nru x2gobroker-0.0.4.4/mini/x2gobroker-ssh-mini x2gobroker-0.0.4.4/mini/x2gobroker-ssh-mini --- x2gobroker-0.0.4.4/mini/x2gobroker-ssh-mini 2024-03-27 16:23:48.000000000 +0000 +++ x2gobroker-0.0.4.4/mini/x2gobroker-ssh-mini 2024-03-28 18:46:43.000000000 +0000 @@ -127,20 +127,100 @@ # check if we were asked to provide a server name/IP and port for a specific session elif (echo -e "$PARAMLIST" | grep -q -- '--task selectsession'); then SESSIONID=$(echo -e "$PARAMLIST" | awk '$1 == "--sid" { print $2 }') + # search for the line with the corresponding session file in our stored list of files SESSIONFILE=$(grep "$SESSIONID" ~/.x2go/brokersessionfile-${USER}) + # determine server name/IP and port from this file SERVER=$(awk -F '=' '$1 == "host" { print $2 }' $SESSIONFILE) PORT=$(awk -F '=' '$1 == "sshport" { print $2 }' $SESSIONFILE) - # if this failed, set default values - if [ -z "$SERVER" ] && [ -f /etc/x2go/x2gobroker-ssh-mini/defaulthost ]; then - # determine default hostname/IP - read DEFAULTHOST IPv6 detected + if [ '[' = "${DEFAULTFROMFILE:0:1}" ] && [ "${DEFAULTFROMFILE}" != "${DEFAULTFROMFILE%\]*}" ] ; then + # is likely a proper IPv6 address (starts with square bracket, has a closing bracket somewhere) + + # Determine Port - strip everything in front of "]:" + # If no port was given, the result will equal $DEFAULTFROMFILE + DEFAULTPORTFROMFILE="${DEFAULTFROMFILE#*\]:}" + if [ "${DEFAULTPORTFROMFILE}" != "${DEFAULTFROMFILE}" ]; then + # not the same, so we have a valid port and may set it + PORT="${DEFAULTPORTFROMFILE}" + fi + + # Determine IPv6 address (subtract colon and port, then remove brackets in step 2) + DEFAULTFROMFILE="${DEFAULTFROMFILE%%:$DEFAULTPORT}" + DEFAULTSERVERFROMFILE="${DEFAULTFROMFILE//[\[\]]}" + + # do one last sanity check, in case someone messed up the square brackets in the file + if [ "[${DEFAULTSERVERFROMFILE}]" = "${DEFAULTFROMFILE}" ]; then + # very likely that we have a valid IPv6 address, so let's use it + SERVER="${DEFAULTSERVERFROMFILE}" + fi + # else # TODO - add log message that file could not be parsed. + fi + else + # one or no ":" -> IPv4 address or DNS name, with optional port + + # Determine port - strip everything in front of ":" + # If no port was given, the result will equal $DEFAULTFROMFILE + DEFAULTPORTFROMFILE="${DEFAULTFROMFILE#*:}" + if [ "${DEFAULTPORTFROMFILE}" != "${DEFAULTFROMFILE}" ]; then + # not the same, so we have a valid port and may set it + PORT="${DEFAULTPORTFROMFILE}" + fi + + # not much to check for here + DEFAULTSERVERFROMFILE="${DEFAULTHOST%:*}" + if [ -n "${DEFAULTSERVERFROMFILE}" ]; then + SERVER="${DEFAULTSERVERFROMFILE}" + fi + fi + fi + + # If we have reached this point, and still lack at least one of the variables $SERVER and $PORT, + # then either there was no default set in the file, or something went wrong parsing the file. + # TODO: Add log message. + + # So if we still need a server name (or IP address), let's try what hostname -f has to say. + if [ -z "$SERVER" ] ; then + SERVERFQDNFROMHOSTNAME="$(hostname -f)" + + # let's check if the result contains at least one dot, so there's a chance it's an actual FQDN that our client knows + # (there doesn't seem to be any use for short names - if we get a short name in reply, we're on a LAN, and can use the SSH IP address instead) + if [ -z "${SERVERFQDNFROMHOSTNAME##*.*}" ]; then + # seems it is, so let's use it + SERVER="${SERVERFQDNFROMHOSTNAME}" + fi + fi + + # What, still no server name (or IP address), and/or no port? + # Let's use what our SSH connection is using. Note that this will fail when using NAT and "dialing in" from outside. + SSHSERVERANDPORT="${SSH_CONNECTION#* * }" + if [ -z "${SERVER}" ] ; then + SERVER="${SSHSERVERANDPORT% *}" + fi + if [ -z "${PORT}" ]; then + PORT="${SSHSERVERANDPORT#* }" + fi + + # Last Resort - we should never reach this point + + if [ -z "$PORT" ]; then + PORT='22' + fi fi # output all data