From unknown Thu Apr 09 09:47:02 2026
X-Loop: owner@bugs.x2go.org
Subject: Bug#155: [X2Go-Dev] Multiple X2goclient instances fail (patch)
Reply-To: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>, 155-quiet@bugs.x2go.org
Resent-To: Thomas Hanschke <th.han@arcor.de>
X-Loop: owner@bugs.x2go.org
Resent-Date: Wed, 05 Jun 2013 23:03:02 +0000
Resent-Message-ID: <handler.155.U155.137047327517407@bugs.x2go.org>
Resent-Sender: owner@bugs.x2go.org
X-X2Go-PR-Message: report 155
X-X2Go-PR-Package: x2goserver
X-X2Go-PR-Keywords: moreinfo patch
Received: via spool by 155-submitter@bugs.x2go.org id=U155.137047327517407
          (code U ref 155); Wed, 05 Jun 2013 23:03:02 +0000
Received: (at 155-submitter) by bugs.x2go.org; 5 Jun 2013 23:01:15 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=URIBL_BLOCKED
	autolearn=unavailable version=3.3.2
Received: from freya.das-netzwerkteam.de (freya.das-netzwerkteam.de [88.198.48.199])
	by ymir (Postfix) with ESMTPS id D2F305DB20;
	Thu,  6 Jun 2013 01:01:06 +0200 (CEST)
Received: from grimnir.das-netzwerkteam.de (grimnir.das-netzwerkteam.de [78.46.204.98])
	by freya.das-netzwerkteam.de (Postfix) with ESMTPS id A0FE51B4;
	Thu,  6 Jun 2013 01:01:07 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by grimnir.das-netzwerkteam.de (Postfix) with ESMTP id 064E83BBC7;
	Thu,  6 Jun 2013 01:01:06 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at grimnir.das-netzwerkteam.de
Received: from grimnir.das-netzwerkteam.de ([127.0.0.1])
	by localhost (grimnir.das-netzwerkteam.de [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id iqLO3JRT03UV; Thu,  6 Jun 2013 01:01:05 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by grimnir.das-netzwerkteam.de (Postfix) with ESMTP id CCA6D3BBFE;
	Thu,  6 Jun 2013 01:01:05 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by grimnir.das-netzwerkteam.de (Postfix) with ESMTP id AFB3F3BBF6;
	Thu,  6 Jun 2013 01:01:05 +0200 (CEST)
Received: by grimnir.das-netzwerkteam.de (Postfix, from userid 33)
	id 593BC3BBFE; Thu,  6 Jun 2013 01:01:05 +0200 (CEST)
Received: from 46.115.45.74 ([46.115.45.74]) by mail.das-netzwerkteam.de
 (Horde Framework) with HTTP; Thu, 06 Jun 2013 01:01:05 +0200
Message-ID: <20130606010105.68542iznst745wdt@mail.das-netzwerkteam.de>
X-Priority: 3 (Normal)
Date: Thu, 06 Jun 2013 01:01:05 +0200
From: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
To: Eugene San <eugenesan@gmail.com>, 155@bugs.x2go.org
Cc: 155-submitter@bugs.x2go.org
References:  <CAAVBiEVdX4=b9dAVOk9BMSKAwa-hmxXmbsvjBpDQyefjU8+3iA@mail.gmail.com>
In-Reply-To:  <CAAVBiEVdX4=b9dAVOk9BMSKAwa-hmxXmbsvjBpDQyefjU8+3iA@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/signed;
 boundary="=_2cayrr87cz01";
 protocol="application/pgp-signature";
 micalg="pgp-sha1"
Content-Transfer-Encoding: 7bit
User-Agent: Internet Messaging Program (IMP) H3 (4.3.4)

This message is in MIME format and has been PGP signed.

--=_2cayrr87cz01
Content-Type: multipart/mixed;
 boundary="=_kuzgixawf8x"
Content-Transfer-Encoding: 7bit

This message is in MIME format.

--=_kuzgixawf8x
Content-Type: text/plain;
 charset=UTF-8;
 DelSp="Yes";
 format="flowed"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Hi Thomas, hi Eugene,
ugene
On Mi 05 Jun 2013 06:33:15 CEST Eugene San wrote:

> Hi all,
>
> This subject was already discussed here, but since no solution exists till
> now, I've hacked not ideal but practical solution.
>
> Attached patch should minimize chances of conflicting ports x2goserver is
> using.
> On the first run, x2gostartagent script randomly selects ports from
> specific range (30000-30099) and save them to config file to be used for
> the following sessions.
> Later one can tune those values in config file
> (/etc/x2go/x2goagent.options).
>
> Regards
>

Eugene: the patch your provided via x2go-dev ML won't work (as  
x2goagent.options cannot be written by the user).

However, here is another patch that you and Thomas (the submitter of  
issue #155 in X2Go BTS) may test with your class room setups.

Patch is attached. Please give feedback. The patch reverts some code  
introduced in x2goserver 3.1.1.3 (or so).

Thanks+Greets,
Mike


-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: mike.gabriel@das-netzwerkteam.de, http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

--=_kuzgixawf8x
Content-Type: text/x-diff;
 charset=UTF-8;
 name="detect-used-ports-correctly-again.patch"
Content-Disposition: attachment;
 filename="detect-used-ports-correctly-again.patch"
Content-Transfer-Encoding: 7bit

diff --git a/x2goserver/bin/x2goresume-session b/x2goserver/bin/x2goresume-session
index f4b5624..7eba167 100755
--- a/x2goserver/bin/x2goresume-session
+++ b/x2goserver/bin/x2goresume-session
@@ -68,7 +68,7 @@ $X2GO_LIB_PATH/x2gosyslog "$0" "debug" "old ports: $GR_PORT, $SOUND_PORT, $FS_PO
 ss=$(PATH="$PATH:/usr/sbin:/sbin" type -P ss);
 USED_PORTS=$(
 	"$ss" -lnt |
-	perl -lne 'print$d{$2}="|$2|"if/^(\S+\s+){2}\S+:(\d+)/&&!exists$d{$2}';
+	awk '{ n=split($0,lines,"\n"); for(i=1;i<=n;i++){split (lines[i],words," ");delim=split(words[4],ports,":"); if(delim>1)printf ("|%s|\n",ports[delim])} }';
 );
 
 #check if saved in DB ports free
diff --git a/x2goserver/bin/x2gostartagent b/x2goserver/bin/x2gostartagent
index 83e559d..f99b8d5 100755
--- a/x2goserver/bin/x2gostartagent
+++ b/x2goserver/bin/x2gostartagent
@@ -138,7 +138,7 @@ ss=$(PATH="$PATH:/usr/sbin:/sbin" type -P ss);
 USED_PORTS=$(
 	"$X2GO_LIB_PATH/x2gogetports" "$HOSTNAME";
 	"$ss" -lnt |
-	perl -lne 'print$d{$2}="|$2|"if/^(\S+\s+){2}\S+:(\d+)/&&!exists$d{$2}';
+	awk '{ n=split($0,lines,"\n"); for(i=1;i<=n;i++){split (lines[i],words," ");delim=split(words[4],ports,":"); if(delim>1)printf ("|%s|\n",ports[delim])} }';
 );
 
 while [ "$OUTPUT"  != "inserted" ]; do

--=_kuzgixawf8x--

--=_2cayrr87cz01
Content-Type: application/pgp-signature
Content-Description: Digitale PGP-Unterschrift
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAABAgAGBQJRr8MxAAoJEJr0azAldxsxyuUQALvf3kr4sWSSRU619X4gIjwN
wdNPjxDgtltEY7fDayR8kfd3b1+c/K7IorVi3yurO6XlPVWWNdSZU2GxJUlRj5os
5steObiTMjLMT6/n2ahVztd0YaXZTyxwDfGQRxqJQE4f9TooXcTq3WmvpgN3sCyT
FGdELCgeK6dD/nd0SJaTLnNRE7+gUZEkxsa6PxEvbZdCPiL3G45IAkHbmabmJ+5U
zOOfAe3xNqjocPvaKVQA/ooXx32w4rr3GlVrv5nrQQwW6VIPVTvx3I1wa7aYT3jW
mJzm/wocKrOeWQZRWw8NEr2iKmG1b//bmIg7JruRdU6/A+7GkuuZTacay99w9pde
kYVdQs2skvgHiGKKwOMcTSmm48L/BDbFxwVgJ3Mipedh4U2in9J/5SpTqt/fC3ig
iI7zCDi3jsSDJ0ZhYdie6mqzeq0fdz9yh15UG5/6vanRkGgMqHjgiVAISfzqFJ3l
8Ql3kG919xoLCf7nD/AwKPMDYKKnLmlc5DW6rz8uGvF1SCgf00QLsrK5G9TON/Fq
8T60tFelS1cQYfzqAbDKqTtBmZSs36gWzYXlR0CFGNrMnNLoYgFlpsJBWrKQwTv7
wrgR0WF4ejqgNRHmed4PXx/DPa3+aha8ITITsJ2J9nl8gvmmJ8ftapYE5YFpMGsO
imAikWsw8QS+au422ha2
=xm8d
-----END PGP SIGNATURE-----

--=_2cayrr87cz01--
