Subject: Re: [X2Go-Dev] Multiple X2goclient instances fail (patch)

From: Mike Gabriel <[email-masked]>
Date: Thu, 06 Jun 2013 01:01:05 +0200

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: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb
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