[X2Go-Commits] [x2goserver] 03/03: x2golistsessions(_root): Only update session state in session DB if x2goagent's state file really exists. This addresses a problem that occurs when x2golistsessions gets called via an x2gobroker-agent. The x2golistsessions script may show session states (--all-servers) of sessions on other servers that have session states files on their remote /tmp dirs. These files are not accessible for that x2golistsessions script and should simply be ignored.

git-admin at x2go.org git-admin at x2go.org
Fri Oct 17 11:33:46 CEST 2014


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 fcbd37ba54b1f3bc983f90c1e974e1c9fc5d8bbf
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Fri Oct 17 11:17:42 2014 +0200

    x2golistsessions(_root): Only update session state in session DB if x2goagent's state file really exists. This addresses a problem that occurs when x2golistsessions gets called via an x2gobroker-agent. The x2golistsessions script may show session states (--all-servers) of sessions on other servers that have session states files on their remote /tmp dirs. These files are not accessible for that x2golistsessions script and should simply be ignored.
---
 debian/changelog                      |    7 +++++++
 x2goserver/bin/x2golistsessions       |   15 +++++++++++++--
 x2goserver/sbin/x2golistsessions_root |   14 +++++++++++++-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9632df3..90e409f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,13 @@ x2goserver (4.0.1.19-0x2go1) UNRELEASED; urgency=medium
     - x2gocleansessions: Call x2gormforward also on terminated sessions. This
       will make sure that re-assigned ports are really available on new session
       startup.
+    - x2golistsessions(_root): Only update session state in session DB if
+      x2goagent's state file really exists. This addresses a problem that occurs
+      when x2golistsessions gets called via an x2gobroker-agent. The
+      x2golistsessions script may show session states (--all-servers) of
+      sessions on other servers that have session states files on their remote
+      /tmp dirs. These files are not accessible for that x2golistsessions script
+      and should simply be ignored. (Fixes: #638).
   * debian/control:
     + Add D (x2goserver): libfile-which-perl.
   * x2goserver.spec:
diff --git a/x2goserver/bin/x2golistsessions b/x2goserver/bin/x2golistsessions
index dc78ec3..af26e99 100755
--- a/x2goserver/bin/x2golistsessions
+++ b/x2goserver/bin/x2golistsessions
@@ -66,10 +66,21 @@ sub is_running
 	return 0;
 }
 
-sub get_agent_state
+
+sub has_agent_state_file
 {
 	my $sess=@_[0];
 	my $user=@_[1];
+	my $stateFile = "/tmp/.x2go-".$user."/C-".$sess."/state";
+	if ( -e $stateFile )
+	{
+		return 1;
+	}
+	return 0;
+}
+
+sub get_agent_state
+{
 	my $state;
 	my $stateFile = "/tmp/.x2go-".$user."/C-".$sess."/state";
 	if (! -e $stateFile )
@@ -113,7 +124,7 @@ for (my $i=0;$i<@outp;$i++)
 	{
 		print "@outp[$i]\n";
 	}
-	else
+	else if (has_agent_state_file(@sinfo[1], @sinfo[11]))
 	{ 
 		if (@sinfo[4]eq 'R')
 		{
diff --git a/x2goserver/sbin/x2golistsessions_root b/x2goserver/sbin/x2golistsessions_root
index d562fa3..7e10872 100755
--- a/x2goserver/sbin/x2golistsessions_root
+++ b/x2goserver/sbin/x2golistsessions_root
@@ -41,6 +41,18 @@ sub is_suspended
 	return 0;
 }
 
+sub has_agent_state_file
+{
+	my $sess=@_[0];
+	my $user=@_[1];
+	my $stateFile = "/tmp/.x2go-".$user."/C-".$sess."/state";
+	if ( -e $stateFile )
+	{
+		return 1;
+	}
+	return 0;
+}
+
 sub get_agent_state
 {
 	my $sess=@_[0];
@@ -83,7 +95,7 @@ for (my $i=0;$i<@outp;$i++)
 	{
 		print "@outp[$i]\n";
 	}
-	else
+	else if (has_agent_state_file(@sinfo[1], at sinfo[11]))
 	{ 
 		if (@sinfo[4]eq 'R')
 		{

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git


More information about the x2go-commits mailing list