This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2goserver. from 68b8861 Only call $dbh->sqlite_busy_timeout() if the $dbh object is capable of that. Works around a too-old DBD::SQLite package on SLE 11.x. new e4aa085 Make it possible to change the state of shadow sessions. new e20bbe2 Provide --debug option for x2gocleansession that allows running x2gocleansessions in foreground (and in debug mode). The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: X2Go/Server/DB/SQLite3.pm | 9 +++- debian/changelog | 3 ++ x2goserver/sbin/x2gocleansessions | 99 ++++++++++++++++++++++++------------- 3 files changed, 77 insertions(+), 34 deletions(-) -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goserver. commit e4aa0850c984cab1c003f319c728ee33acec99d6 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Feb 5 10:21:42 2015 +0100 Make it possible to change the state of shadow sessions. --- X2Go/Server/DB/SQLite3.pm | 9 ++++++++- debian/changelog | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/X2Go/Server/DB/SQLite3.pm b/X2Go/Server/DB/SQLite3.pm index 5e73e56..2acb0b6 100644 --- a/X2Go/Server/DB/SQLite3.pm +++ b/X2Go/Server/DB/SQLite3.pm @@ -395,9 +395,16 @@ sub db_changestatus my $sid=shift or die "argument \"session_id\" missed"; $sid = sanitizer('x2gosid', $sid) or die "argument \"session_id\" malformed"; check_user($sid); + + # we need to be able to change the state of normal sessions ($realuser == $effective_user) + # _and_ desktop sharing session ($realuser != $effective_user). Thus, extracting the effective + # username from the session ID... + my $effective_user = $sid; + $effective_user =~ s/\-[0-9]+\-[0-9]{10}_.*//; + my $sth=$dbh->prepare("update sessions set last_time=datetime('now','localtime'), status=? where session_id = ? and uname=?"); - $sth->execute($status, $sid, $realuser); + $sth->execute($status, $sid, $effective_user); if ($sth->err()) { syslog('error', "changestatus (SQLite3 session db backend) failed with exitcode: $sth->err()"); diff --git a/debian/changelog b/debian/changelog index 3268e3c..6c6582a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -63,6 +63,7 @@ x2goserver (4.1.0.0-0x2go1.1) UNRELEASED; urgency=low parentheses. - Make sure to return "1" in X2Go::Server::DB Perl functions that don't return anything by default. + - Make it possible to change the state of shadow sessions. * debian/control: + Package X2Go::Log in separate package: libx2go-log-perl. + Package X2Go::Server::DB in separate package: libx2go-server-db-perl. -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goserver. commit e20bbe267137fea4f5ce933b7c5e296a6bbc1f72 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Feb 5 10:48:49 2015 +0100 Provide --debug option for x2gocleansession that allows running x2gocleansessions in foreground (and in debug mode). --- debian/changelog | 2 + x2goserver/sbin/x2gocleansessions | 99 ++++++++++++++++++++++++------------- 2 files changed, 68 insertions(+), 33 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6c6582a..ac1bef1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -64,6 +64,8 @@ x2goserver (4.1.0.0-0x2go1.1) UNRELEASED; urgency=low - Make sure to return "1" in X2Go::Server::DB Perl functions that don't return anything by default. - Make it possible to change the state of shadow sessions. + - Provide --debug option for x2gocleansession that allows running + x2gocleansessions in foreground (and in debug mode). * debian/control: + Package X2Go::Log in separate package: libx2go-log-perl. + Package X2Go::Server::DB in separate package: libx2go-server-db-perl. diff --git a/x2goserver/sbin/x2gocleansessions b/x2goserver/sbin/x2gocleansessions index 3dd6e0a..4cfe224 100755 --- a/x2goserver/sbin/x2gocleansessions +++ b/x2goserver/sbin/x2gocleansessions @@ -35,9 +35,22 @@ use X2Go::Server::Agent qw( session_is_suspended session_is_running session_has_ use X2Go::Server::DB qw( dbsys_rmsessionsroot ); use X2Go::Utils qw( system_capture_stdout_output is_true ); my $x2go_lib_path = system_capture_stdout_output("x2gopath", "libexec"); +use Getopt::Long; + + +my $debug; +GetOptions( 'debug' => \$debug ); openlog($0,'cons,pid','user'); -setlogmask( LOG_UPTO(loglevel()) ); +if ($debug) +{ + setlogmask( LOG_DEBUG ); +} +else +{ + setlogmask( LOG_UPTO(loglevel()) ); +} + sub check_pid { @@ -64,10 +77,27 @@ sub catch_term exit; } +sub log_message +{ + my $loglevel=shift; + my $msg=shift; + syslog($loglevel, $msg); + if ($debug) + { + print "$loglevel ::: $msg\n"; + } +} + my $uname; my $serv = hostname; -my $pid = fork(); -if (not defined $pid) +my $pid; + +if (! $debug) +{ + $pid = fork(); +} + +if ((!$debug) && (not defined $pid)) { print "resources not avilable.\n"; } @@ -79,7 +109,6 @@ elsif ($pid != 0) } elsif ($pid == 0 ) { - # check if we are to use the superenicer script for throttling does the nice level # of suspended sessions... my $Config = get_config(); @@ -91,23 +120,27 @@ elsif ($pid == 0 ) my $superenice_idle=$Config->param("superenicer.idle-nice-level"); my $superenice_ignoredusers=$Config->param("superenicer.ignored-users"); - # close any open file descriptor left open by our parent before the fork - my $fd; - for (glob "/proc/$$/fd/*") { - if ( ! -e $_ ) { next; } - if ($_ =~ m/\/proc\/\d+\/fd\/(\d+)/) { - $fd = $1; - if ( $fd < 3 ) { next; } - if (! POSIX::close($fd)) { - syslog('warning', "Error Closing $_: $!"); + if ( ! $debug ) + { + # close any open file descriptor left open by our parent before the fork + my $fd; + for (glob "/proc/$$/fd/*") { + if ( ! -e $_ ) { next; } + if ($_ =~ m/\/proc\/\d+\/fd\/(\d+)/) { + $fd = $1; + if ( $fd < 3 ) { next; } + if (! POSIX::close($fd)) { + log_message('warning', "Error Closing $_: $!"); + } } } - } - # redirect stdin, stdout and stderr - open *STDIN, q{<}, '/dev/null'; - open *STDOUT, q{>>}, '/dev/null'; - open *STDERR, q{>>}, '/dev/null'; + # redirect stdin, stdout and stderr + open *STDIN, q{<}, '/dev/null'; + open *STDOUT, q{>>}, '/dev/null'; + open *STDERR, q{>>}, '/dev/null'; + + } $SIG{TERM}=\&catch_term; $SIG{CHLD} = sub { wait }; @@ -155,26 +188,26 @@ elsif ($pid == 0 ) if (@sinfo[4]eq 'F') { - syslog('debug', "@sinfo[1] is blocked"); + log_message('debug', "@sinfo[1] is blocked"); if ($remembered_sessions_since{@sinfo[1]} ge 20) { # send SIGKILL to dangling X-server processes - syslog('warning', "@sinfo[1]: found stale X-server process (@sinfo[0]), sending SIGKILL"); + log_message('warning', "@sinfo[1]: found stale X-server process (@sinfo[0]), sending SIGKILL"); system("kill", "-9", "@sinfo[0]"); delete $remembered_sessions_since{@sinfo[1]}; } my $display = @sinfo[2]; if (-S "/tmp/.X11-unix/X$display") { # remove the NX-X11 socket file (as the agent will not have managed after a kill -9) - syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 socket file: /tmp/.X11-unix/X$display"); + log_message('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 socket file: /tmp/.X11-unix/X$display"); unlink("/tmp/.X11-unix/X$display"); } if (-e "/tmp/.X$display-lock") { # remove the NX-X11 lock file (as the agent will not have managed after a kill -9) - syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 lock file: /tmp/.X$display-lock"); + log_message('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 lock file: /tmp/.X$display-lock"); unlink("/tmp/.X$display-lock"); } - syslog('debug', "@sinfo[1]: unmounting all shares"); + log_message('debug', "@sinfo[1]: unmounting all shares"); system( "su", "@sinfo[11]", "-s", "/bin/sh", "-c", "export HOSTNAME && x2goumount-session @sinfo[1]"); #remove port forwarding system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "$x2go_lib_path/x2gormforward @sinfo[1]"); @@ -186,16 +219,16 @@ elsif ($pid == 0 ) if (-S "/tmp/.X11-unix/X$display") { # remove the NX-X11 socket file (we don't know how the agent disappeared, # someone might have shot it with kill -9) - syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 socket file: /tmp/.X11-unix/X$display"); + log_message('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 socket file: /tmp/.X11-unix/X$display"); unlink("/tmp/.X11-unix/X$display"); } if (-e "/tmp/.X$display-lock") { # remove the NX-X11 lock file (we don't know how the agent disappeared, # someone might have shot it with kill -9) - syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 lock file: /tmp/.X$display-lock"); + log_message('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 lock file: /tmp/.X$display-lock"); unlink("/tmp/.X$display-lock"); - } syslog('debug', "@sinfo[1], pid @sinfo[0] does not exist, changing status from @sinfo[4] to F"); - syslog('debug', "@sinfo[1]: unmounting all shares"); + } log_message('debug', "@sinfo[1], pid @sinfo[0] does not exist, changing status from @sinfo[4] to F"); + log_message('debug', "@sinfo[1]: unmounting all shares"); system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "export HOSTNAME && x2goumount-session @sinfo[1]"); } else @@ -205,8 +238,8 @@ elsif ($pid == 0 ) if (session_is_suspended(@sinfo[1],@sinfo[11])) { system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "$x2go_lib_path/x2gochangestatus S @sinfo[1]"); - syslog('debug', "@sinfo[1] is suspended, changing status from @sinfo[4] to S"); - syslog('debug', "@sinfo[1]: unmounting all shares"); + log_message('debug', "@sinfo[1] is suspended, changing status from @sinfo[4] to S"); + log_message('debug', "@sinfo[1]: unmounting all shares"); system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "export HOSTNAME && x2goumount-session @sinfo[1]"); #remove port forwarding system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "$x2go_lib_path/x2gormforward @sinfo[1]"); @@ -216,20 +249,20 @@ elsif ($pid == 0 ) { if (session_is_running(@sinfo[1],@sinfo[11])) { - syslog('debug', "@sinfo[1]: unmounting all shares"); + log_message('debug', "@sinfo[1]: unmounting all shares"); system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "export HOSTNAME && x2goumount-session @sinfo[1]"); system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "x2gosuspend-session @sinfo[1]"); - syslog('debug', "@sinfo[1] was found running and has now been suspended"); + log_message('debug', "@sinfo[1] was found running and has now been suspended"); } } if (@sinfo[4] eq 'T') { if (!session_has_terminated(@sinfo[1],@sinfo[11])) { - syslog('debug', "@sinfo[1]: unmounting all shares"); + log_message('debug', "@sinfo[1]: unmounting all shares"); system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "export HOSTNAME && x2goumount-session @sinfo[1]"); system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "x2goterminate-session @sinfo[1]"); - syslog('debug', "@sinfo[1] has been requested for termination via the session DB"); + log_message('debug', "@sinfo[1] has been requested for termination via the session DB"); #remove port forwarding system("su", "@sinfo[11]", "-s", "/bin/sh", "-c", "$x2go_lib_path/x2gormforward @sinfo[1]"); } -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git