[X2Go-Commits] [x2goserver] 07/08: x2goserver/bin/x2golistshadowsessions: copy and use a few needed utility functions from x2gocleansessions.
git-admin at x2go.org
git-admin at x2go.org
Wed Oct 11 08:17:35 CEST 2017
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 0159ba1519b4f02b90668f784dc281b31e64a50b
Author: Mihai Moldovan <ionic at ionic.de>
Date: Wed Oct 11 08:11:07 2017 +0200
x2goserver/bin/x2golistshadowsessions: copy and use a few needed utility functions from x2gocleansessions.
---
debian/changelog | 2 ++
x2goserver/bin/x2golistshadowsessions | 41 ++++++++++++++++++++++++++++++++++-
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 287c85f..23a986d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -36,6 +36,8 @@ x2goserver (4.0.1.21-0x2go1) UNRELEASED; urgency=medium
- x2goserver/bin/x2golistshadowsessions: whitespace only.
- x2goserver/sbin/x2gocleansessions: close syslog at program exit.
- x2goserver/sbin/x2gocleansessions: whitespace only.
+ - x2goserver/bin/x2golistshadowsessions: copy and use a few needed utility
+ functions from x2gocleansessions.
* x2goserver.spec:
- Add mandatory perl-generators Build-Requires as per
https://fedoraproject.org/wiki/Changes/Build_Root_Without_Perl
diff --git a/x2goserver/bin/x2golistshadowsessions b/x2goserver/bin/x2golistshadowsessions
index 404dff1..8a90833 100755
--- a/x2goserver/bin/x2golistshadowsessions
+++ b/x2goserver/bin/x2golistshadowsessions
@@ -33,6 +33,45 @@ my $x2go_lib_path = `x2gopath libexec`;
openlog($0,'cons,pid','user');
setlogmask( LOG_UPTO(x2gologlevel()) );
+sub get_agent_state
+{
+ my $sess=@_[0];
+ my $user;
+
+ if ( $sess =~ m/.*-[0-9]{2,}-[0-9]{10,}_stS(0|1)XSHAD.*XSHADPP.*/ ) {
+ my $shadow_user = $sess;
+ $shadow_user =~ s/.*XSHAD(.*)XSHADPP.*/$1/;
+ $user = $shadow_user;
+ } else {
+ $user=@_[1];
+ }
+
+ my $state;
+ my $stateFile = "/tmp/.x2go-".$user."/C-".$sess."/state";
+ if (! -e $stateFile )
+ {
+ syslog('warning', "$sess: state file for this session does not exist: $stateFile (this can be ignored during session startups)");
+ $state = "UNKNOWN";
+ }
+ else
+ {
+ open(F,"<$stateFile");
+ $state=<F>;
+ close(F);
+ }
+ return $state;
+}
+
+sub is_suspended
+{
+ my $state=get_agent_state(@_);
+ if(($state eq 'SUSPENDING')||($state eq 'SUSPENDED'))
+ {
+ return 1;
+ }
+ return 0;
+}
+
if ( @ARGV ) {
syslog('info', "x2golistshadowsessions has been called with options: @ARGV");
} else {
@@ -72,7 +111,7 @@ for (my $i=0;$i<@outp;$i++)
{
my $shadow_user = @sinfo[1];
$shadow_user =~ s/.*XSHAD(.*)XSHADPP.*/$1/;
- if(session_is_suspended(@sinfo[1], $shadow_user))
+ if(is_suspended(@sinfo[1], $shadow_user))
{
db_changestatus( 'S', @sinfo[1] );
@outp[$i] =~ s/\|R\|/\|S\|/;
--
Alioth's /srv/git/code.x2go.org/x2goserver.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git
More information about the x2go-commits
mailing list