This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch release/4.0.1.x in repository x2goserver. from 52c4480 debian/x2goserver.preinst: Use proper comment header explaining about preinst script argument calls (not postinst). new beb3517 x2goserver/bin/x2gostartagent: changes to Robert Nowotny's SSH_PORT patch. Fixes: #922. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: debian/changelog | 11 +++++++ x2goserver/bin/x2gostartagent | 71 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) -- Alioth's /srv/git/code.x2go.org/x2goserver.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch release/4.0.1.x in repository x2goserver. commit beb351773b40c8ecdca035f970aa17e646786ba9 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun Aug 23 23:08:45 2015 +0200 x2goserver/bin/x2gostartagent: changes to Robert Nowotny's SSH_PORT patch. Fixes: #922. Use default outgoing interface to determine IP address. Use the whole range of ${RANDOM}'s pool. Seed it for good measure. Change the default method to randomization instead of IP-based initialization. If IP-based initialization was requested but the default outgoing IP address unavailable, fall back to randomization. --- debian/changelog | 11 +++++++ x2goserver/bin/x2gostartagent | 71 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 159b682..bd416a2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -62,6 +62,12 @@ x2goserver (4.0.1.20-0x2go1) UNRELEASED; urgency=low state change when updating the cached state result. - x2goserver/sbin/x2gocleansessions: only output status refreshing debug message if the old and new states actually differ. Prevents log spam. + - x2goserver/bin/x2gostartagent: changes to Robert Nowotny's SSH_PORT + patch. Fixes: #922. Use default outgoing interface to determine IP + address. Use the whole range of ${RANDOM}'s pool. Seed it for good + measure. Change the default method to randomization instead of IP-based + initialization. If IP-based initialization was requested but the default + outgoing IP address unavailable, fall back to randomization. * x2goserver.spec: - Add sudo and logcheck as BuildRequires and Requires. Don't own directories that are owned by sudo and logcheck. Logcheck is not @@ -90,6 +96,11 @@ x2goserver (4.0.1.20-0x2go1) UNRELEASED; urgency=low + Use proper comment header explaining about preinst script argument calls (not postinst). + [ Robert Nowotny ] + * New upstream version (4.0.1.20): + - x2goserver/bin/x2gostartagent: original patch for SSH_PORT + randomization/IP-based initialization. Submitted as #922. + -- X2Go Release Manager <git-admin@x2go.org> Tue, 24 Feb 2015 22:11:49 +0100 x2goserver (4.0.1.19-0x2go2) UNRELEASED; urgency=low diff --git a/x2goserver/bin/x2gostartagent b/x2goserver/bin/x2gostartagent index 13e62f3..1b6acce 100755 --- a/x2goserver/bin/x2gostartagent +++ b/x2goserver/bin/x2gostartagent @@ -20,12 +20,81 @@ # Copyright (C) 2007-2015 Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> # Copyright (C) 2007-2015 Heinz-Markus Graesing <heinz-m.graesing@obviously-nice.de> +# rnowotny, <rnowotny@rotek.at> +# Patch for SSH_PORT, to not use the same SSH port on each server, which is a +# problem if you want to connect to different servers at the same time with +# the windows client. +# Original problem report: https://www.mail-archive.com/x2go-user@lists.berlios.de/msg00547.html +# Currently implementation is based on the submitted patch, but differs heavily. + +# Get server IP address. +get_server_ip_address() { + # The provided IP address should be outside of any local network. + # We are only interested in how the kernel would try to reach the + # non-local IP address specified here. It is not actually contacted + # in any way. + typeset ip_output="$(ip route get 8.8.8.8)" + + # Remove newlines. + ip_output="${ip_output//$'\n'}" + + # Fetch source address. + typeset src_address="$(grep -oe 'src[[:space:]]\{1,\}\(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}\)' <<< "${ip_output}" | sed -e 's/src[[:space:]]\{1,\}//')" + + if [ -n "${src_address}" ]; then + printf "${src_address}" + return "0" + fi + + return "1" +} + +# Get some random port. +get_random_port() { + typeset -i unix_timestamp="$(date "+%s")" + + # Seed ${RANDOM}. This should probably be changed some time before 2106. + # Or maybe not. + RANDOM="${unix_timestamp}" + + typeset -i random_port="$((30000 + ${RANDOM}))" + printf "${random_port}" + + exit 0 +} + X2GO_LIB_PATH="$(x2gopath libexec)"; $X2GO_LIB_PATH/x2gosyslog "$0" "info" "$(basename $0) called with options: $@" + +# FIXME: this should be configurable option in x2goserver.conf. +# If you use hosts on a /24 network, you should probably set "0" here, +# as the addresses are unique. +# Each hosts SSH_PORT will be set to 30.000 + (128 * last octet of IP address) +# This results in no collisions on a /24 network with at least 128 ports +# for each host available for different sessions. +# If you select "1" here, the SSH_PORT will be set to 30000 + random(0..32767) +typeset -i randomize_ssh_port="1" + +if [ "${randomize_ssh_port}" = "1" ]; then + ${X2GO_LIB_PATH}/x2gosyslog "$0" "debug" "SSH port randomization requested." + SSH_PORT="$(get_random_port)" +else + ${X2GO_LIB_PATH}/x2gosyslog "$0" "debug" "IP-based SSH port initialization requested." + typeset ip_address="$(get_server_ip_address)" + + if [ "$?" = "0" ]; then + typeset -i ip_address_last_octet="${ip_address##*.}" + SSH_PORT="$((30000 + (${ip_address_last_octet} * 128)))" + else + ${X2GO_LIB_PATH}/x2gosyslog "$0" "warning" "IP-based SSH port initialization requested, but failed to fetch primary address." + ${X2GO_LIB_PATH}/x2gosyslog "$0" "warning" "Falling back to randomization." + SSH_PORT="$(get_random_port)" + fi +fi + X2GO_PORT=49 #First port for X2GO=50 -SSH_PORT=30000 #First ssh port 30001 # some sanity checks before session startup... if egrep "^backend[ ]*=[ ]*postgres" /etc/x2go/x2gosql/sql 1>/dev/null 2>/dev/null && [ "x$USER" = "xroot" ]; then -- Alioth's /srv/git/code.x2go.org/x2goserver.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git