[X2Go-Commits] x2goserver.git - master (branch) updated: 3.1.1.3-164-g34e0dfb

X2Go dev team git-admin at x2go.org
Tue Jun 4 23:24:55 CEST 2013


The branch, master has been updated
       via  34e0dfba2da093cf5dffc501666cd6c35b859cc9 (commit)
      from  0e218dfba1d0d8b5a4df7bed58720d63259328d1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 34e0dfba2da093cf5dffc501666cd6c35b859cc9
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Tue Jun 4 23:21:12 2013 +0200

    Add support to x2gocleansessions to suspend session via state changes in the session DB.
    
    Conflicts (resolved by Mike Gabriel):
    	debian/changelog

-----------------------------------------------------------------------

Summary of changes:
 debian/changelog                  |    2 ++
 x2goserver/sbin/x2gocleansessions |   44 +++++++++++++++++++++++++++++++++----
 2 files changed, 42 insertions(+), 4 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 43bf919..cc9fbbe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -56,6 +56,8 @@ x2goserver (4.0.0.3-0~x2go1) UNRELEASED; urgency=low
     - Make pre-set DESTDIR and PREFIX traverse through all Makefiles.
       Do not include DESTDIR in Makefile-hard-coded path in x2gosqlitewrapper.
     - Make x2gomountdirs / x2goumount-session UNC path aware.
+    - Add support to x2gocleansessions to suspend session via state changes
+      in the session DB.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Sun, 19 May 2013 15:02:53 +0200
 
diff --git a/x2goserver/sbin/x2gocleansessions b/x2goserver/sbin/x2gocleansessions
index 1988c09..76ab52b 100755
--- a/x2goserver/sbin/x2gocleansessions
+++ b/x2goserver/sbin/x2gocleansessions
@@ -49,7 +49,20 @@ sub check_pid
 	return 0;
 }
 
-sub check_stat
+sub has_terminated
+{
+	my $sess=shift;
+	my $user=shift;
+	my $log="/tmp/.x2go-${user}/session-C-${sess}.log";
+	my $text=`tail -1 $log 2>/dev/null`;
+	if ($text =~ m/Session terminated/)
+	{
+		return 1;
+	}
+	return 0;
+}
+
+sub is_suspended
 {
 	my $sess=shift;
 	my $user=shift;
@@ -57,9 +70,22 @@ sub check_stat
 	my $text=`tail -1 $log 2>/dev/null`;
 	if ($text =~ m/Session suspended/)
 	{
-		return 0;
+		return 1;
+	}
+	return 0;
+}
+
+sub is_running
+{
+	my $sess=shift;
+	my $user=shift;
+	my $log="/tmp/.x2go-${user}/session-C-${sess}.log";
+	my $text=`tail -1 $log 2>/dev/null`;
+	if (!is_suspended($sess, $user) && !has_terminated($sess, $user))
+	{
+		return 1;
 	}
-	return 1;
+	return 0;
 }
 
 sub catch_term
@@ -114,7 +140,7 @@ elsif ($pid == 0 )
 			{ 
 				if (@sinfo[4]eq 'R')
 				{
-					if (!check_stat(@sinfo[1], at sinfo[11]))
+					if (is_suspended(@sinfo[1], at sinfo[11]))
 					{
 						system("su @sinfo[11] -c  \"$x2go_lib_path/x2gochangestatus 'S' @sinfo[1] \" > /dev/null");
 						syslog('debug', "@sinfo[1] is suspended, changing status from @sinfo[4] to S");
@@ -122,6 +148,16 @@ elsif ($pid == 0 )
 						system( "su @sinfo[11] -c \"export HOSTNAME && x2goumount-session @sinfo[1]\" 2> /dev/null");
 					}
 				}
+				if (@sinfo[4]eq 'S')
+				{
+					if (is_running(@sinfo[1], at sinfo[11]))
+					{
+						syslog('debug', "@sinfo[1]: unmounting all shares");
+						system( "su @sinfo[11] -c \"export HOSTNAME && x2goumount-session @sinfo[1]\" 2> /dev/null");
+						system("su @sinfo[11] -c  \"x2gosuspend-session @sinfo[1] \" > /dev/null");
+						syslog('debug', "@sinfo[1] was found running and has now been suspended");
+					}
+				}
 			}
 		}
 	}


hooks/post-receive
-- 
x2goserver.git (X2Go Server)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2goserver.git" (X2Go Server).




More information about the x2go-commits mailing list