This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository telekinesis. commit 64f03a56fe390eaa383206f504284dde948f6b1d Author: Mihai Moldovan <ionic@ionic.de> Date: Fri Jan 9 02:14:57 2015 +0100 common: fix whitespace errors, replace tabs with spaces in mixed environments, fixup comments. --- X2Go/Telekinesis/Apps/AppCore.pm | 84 +++--- X2Go/Telekinesis/Client/Supporting_Services.pm | 2 +- X2Go/Telekinesis/CommonCore.pm | 50 ++-- X2Go/Telekinesis/CoreSupport.pm | 74 ++--- client/bin/telekinesis-client | 364 ++++++++++++------------ server/bin/tekicmd | 30 +- server/bin/telekinesis-server | 248 ++++++++-------- 7 files changed, 426 insertions(+), 426 deletions(-) diff --git a/X2Go/Telekinesis/Apps/AppCore.pm b/X2Go/Telekinesis/Apps/AppCore.pm index 016c48a..14555ca 100644 --- a/X2Go/Telekinesis/Apps/AppCore.pm +++ b/X2Go/Telekinesis/Apps/AppCore.pm @@ -23,10 +23,10 @@ ################################################################################################################# package X2Go::Telekinesis::Apps::AppCore; use strict; -use Glib qw/TRUE FALSE/; +use Glib qw/TRUE FALSE/; use Exporter qw(import); our @EXPORT_OK = qw(getTeKiPaths tkappDie appDBugLog cleanUpOldAppSession checkAppSesLOCKnDirs initLOCKandDirs getXWinPosNDim showAboutPOP getBasicServersideInfo getCmdFlags getBasicClientsideInfo epicFailPOP); -use X2Go::Telekinesis::CommonCore qw(tcDie sanitizer genRandFID checkPID sanitizeFilePath sanitizeDirPath genRandSID clups dbugPrint); +use X2Go::Telekinesis::CommonCore qw(tcDie sanitizer genRandFID checkPID sanitizeFilePath sanitizeDirPath genRandSID clups dbugPrint); use File::Path qw(make_path remove_tree); sub appDBugLog { @@ -35,7 +35,7 @@ sub appDBugLog { if ($theAppName) { my $lTime = time(); my $logLevel = 0; - if (uc($_[1]) eq "T") {$logLevel = 1;} + if (uc($_[1]) eq "T") {$logLevel = 1;} elsif (uc($_[1]) eq "W") {$logLevel = 2;} elsif (uc($_[1]) eq "I") {$logLevel = 9;} if (-d $::X2GoTKSHome) { @@ -49,7 +49,7 @@ sub appDBugLog { } } } -} +} sub tkappDie { my $error = "@_"; @@ -69,7 +69,7 @@ sub getTeKiPaths { if (length(clups($pathLine)) > 0) { $pathLine =~ s/\n//g; if ($pathLine =~ /^\#/) { - #NOT GOING TO DO ANYTHING FOR COMMANDS ARE WE ??? NAH... + #NOT GOING TO DO ANYTHING FOR COMMANDS ARE WE ??? NAH... } elsif ($pathLine =~ /^([A-Z]{1})\:([0-9A-Z\_\-]{3,32})\=(.*)$/) { my $pName = $2; my $prePath = $3; @@ -77,7 +77,7 @@ sub getTeKiPaths { $prePath =~ s/[\s]*$//g; $prePath =~ s/\/$//g; my $cleanPath = sanitizeDirPath($prePath) or die("Sanitation of '$pName' => '$prePath' failed during loading of paths file!"); - if (($cleanPath ne 0) and (-d $cleanPath)) { + if (($cleanPath ne 0) and (-d $cleanPath)) { $Paths{$pName} = $cleanPath; } } @@ -111,12 +111,12 @@ sub checkAppSesLOCKnDirs { my $LiveSesExists = 0; if ($AppNAMEandSID =~ /^([a-z]{4,32})\_([a-zA-Z0-9]{3,32})$/) { if (-f "$X2GoTKSHome/apps/$AppNAMEandSID.lock") { # So if there is a lock file... - open(OLF,"$X2GoTKSHome/apps/$AppNAMEandSID.lock");my ($OldPID,$OldStartTime,undef) = <OLF>;close(OLF);# Lets have a look inside... + open(OLF,"$X2GoTKSHome/apps/$AppNAMEandSID.lock");my ($OldPID,$OldStartTime,undef) = <OLF>;close(OLF);# Lets have a look inside... $OldPID = sanitizer("num",$OldPID);$OldStartTime =~ s/\D//g; - my ($psP,$psU,$psN,$psC) = checkPID($OldPID); # And check if the PID is still running + my ($psP,$psU,$psN,$psC) = checkPID($OldPID); # And check if the PID is still running if (($psC =~ /$AppName/) and ($psU eq $::UserName)) { # And if it is running and OURS...?!? #################### - # Force NEW Stuff + # Force NEW Stuff if ($::CmdFlags{'FORCENEW'}) {# About time to start cleaning up if we are ordered to FORCE a new clean session appDBugLog("START FORCING NEW..."); kill("TERM",$OldPID);# Try to kill it in a friendly and polite manner.... @@ -127,22 +127,22 @@ sub checkAppSesLOCKnDirs { sleep 3;# Give it some time to die... my ($psP3,$psU3,$psN3,$psC3) = checkPID($OldPID);# Then Check again... if the pid still is running if (($psC3 =~ /$AppName/) and ($psU3 eq $::UserName)) {# and if it is... - epicFailPOP("We did try to kill the damn thing ($AppName) running as pid $OldPID, but it just wont die..."); + epicFailPOP("We did try to kill the damn thing ($AppName) running as pid $OldPID, but it just wont die..."); } else { cleanUpOldAppSession($X2GoTKSHome,$AppNAMEandSID); # ok it dead now.... lets get on with the cleaning.... - } + } } else { cleanUpOldAppSession($X2GoTKSHome,$AppNAMEandSID); # ok it dead now.... lets get on with the cleaning.... - } + } } else { - # Return some value instead of dying so we know what to do next... (load files to playlist of existing mTP etc..?) + # Return some value instead of dying so we know what to do next... (load files to playlist of existing mTP etc..?) $LiveSesExists = 1; } # Force NEW Stuff #################### } else {# If the pid is not ours nor this app..... lets automaticaly clean up the old/dead session... appDBugLog("Old PID not us? :$psC:$AppName: :$psU:$::UserName:"); - cleanUpOldAppSession($X2GoTKSHome,$AppNAMEandSID); + cleanUpOldAppSession($X2GoTKSHome,$AppNAMEandSID); } } else { if ((-d "$X2GoTKSHome/local/appData/$AppNAMEandSID/") or (-d "$X2GoTKSHome/local/appData/$AppNAMEandSID/")) {cleanUpOldAppSession($X2GoTKSHome,$AppNAMEandSID);} @@ -161,10 +161,10 @@ sub cleanUpOldAppSession { appDBugLog("Start cleaning old session junk...\nCleaning up $AppNAMEandSID..."); if (-d "$X2GoTKSHome/local/appData/$AppNAMEandSID") { remove_tree("$X2GoTKSHome/local/appData/$AppNAMEandSID") or tcDie("Can't remove the \"$X2GoTKSHome/local/appData/$AppNAMEandSID\" dir!\ There is probably still some junk left in it?!"); - } + } if (-d "$X2GoTKSHome/remote/appData/$AppNAMEandSID") { remove_tree("$X2GoTKSHome/remote/appData/$AppNAMEandSID") or tcDie("Can't remove the \"$X2GoTKSHome/remote/appData/$AppNAMEandSID\" dir!\ There is probably still some junk left in it?!"); - } + } if (-f "$X2GoTKSHome/apps/$AppNAMEandSID.lock") { unlink("$X2GoTKSHome/apps/$AppNAMEandSID.lock"); } @@ -178,8 +178,8 @@ sub getCmdFlags { foreach my $ent (@_) { $ent =~ s/\n//g; if ($ent =~ /^\-set([A-Z0-9]{4,24})\=(.*)$/) { - $theArgs{$1} = $2; - } + $theArgs{$1} = $2; + } } return %theArgs; } @@ -232,7 +232,7 @@ sub getBasicClientsideInfo { sub showAboutPOP { my $dialog = Gtk2::Dialog->new ("About $::APPDNAME v$::APPVER", undef, [qw/modal destroy-with-parent/], - 'gtk-ok' => 'ok', + 'gtk-ok' => 'ok', ); $dialog->set_resizable(0); @@ -245,10 +245,10 @@ sub showAboutPOP { my $swW = 580; my $swH = 400; - + if (-f "$::theSHAREDIR/aboutimg.png") { my $pBuf0 = Gtk2::Gdk::Pixbuf->new_from_file ("$::theSHAREDIR/aboutimg.png"); - my $aboutImage = Gtk2::Image->new_from_pixbuf($pBuf0);#$aboutImage->set_size_request(600,280); + my $aboutImage = Gtk2::Image->new_from_pixbuf($pBuf0);#$aboutImage->set_size_request(600,280); my $eb0 = Gtk2::EventBox->new;$eb0->set_size_request(600,280);$eb0->add($aboutImage); $vBox0->pack_start ($eb0, TRUE, TRUE, 0); $swH = 200; @@ -256,7 +256,7 @@ sub showAboutPOP { if (-f "$::theSHAREDIR/aboutbylogo.png") { my $pBuf1 = Gtk2::Gdk::Pixbuf->new_from_file ("$::theSHAREDIR/aboutbylogo.png"); - my $aboutByImage = Gtk2::Image->new_from_pixbuf($pBuf1);#$aboutByImage->set_size_request(180,150); + my $aboutByImage = Gtk2::Image->new_from_pixbuf($pBuf1);#$aboutByImage->set_size_request(180,150); my $eb1 = Gtk2::EventBox->new;$eb1->set_size_request(190,190);$eb1->add($aboutByImage); $hBox0->pack_start ($eb1, TRUE, TRUE, 0); $swW = 400; @@ -298,7 +298,7 @@ __ $dialog->vbox->pack_start ($vBox0, TRUE, TRUE, 0); $dialog->set_default_response ('ok'); if ($dialog->run eq 'ok') {$dialog->destroy;} - + } sub getXWinPosNDim { @@ -309,7 +309,7 @@ sub getXWinPosNDim { $line =~ s/[\n\ ]//g; if ($line =~ /^Width:(\d{1,5})$/) { $Xpos{'width'} = $1; - } elsif ($line =~ /^Height:(\d{1,5})$/) { + } elsif ($line =~ /^Height:(\d{1,5})$/) { $Xpos{'height'} = $1; } elsif ($line =~ /^Absoluteupper-leftX:([\-\d]{1,5})$/) { $Xpos{'absupleftx'} = $1; @@ -331,30 +331,30 @@ sub epicFailPOP { appDBugLog("$VerboseStuff"); Gtk2->init; Gtk2::Rc->parse_string(<<__); - style "err_text" { - font_name ="sans 10" - text[NORMAL] = "#FF0000" - base[NORMAL] = "#000000" - GtkTextView::cursor-color = "red" - } - - widget "*Text*" style "err_text" + style "err_text" { + font_name ="sans 10" + text[NORMAL] = "#FF0000" + base[NORMAL] = "#000000" + GtkTextView::cursor-color = "red" + } + + widget "*Text*" style "err_text" __ my $window = Gtk2::Window->new; - $window->set_title('Epic FAIL!'); + $window->set_title('Epic FAIL!'); $window->signal_connect( delete_event => sub { exit } ); $window->set_default_size( 500, 300 ); - $window->set_keep_above(1); + $window->set_keep_above(1); my $vbox = Gtk2::VBox->new;$window->add($vbox); - $vbox->pack_start( Gtk2::Label->new ("$ENV{'APPNAME'} v$ENV{'APPVER'} experienced an EPIC FAIL:"), FALSE, FALSE, 1 ); + $vbox->pack_start( Gtk2::Label->new ("$ENV{'APPNAME'} v$ENV{'APPVER'} experienced an EPIC FAIL:"), FALSE, FALSE, 1 ); my $scroller = Gtk2::ScrolledWindow->new;$vbox->add($scroller); - my $textview = Gtk2::TextView->new;$textview ->set_editable (0);$textview ->can_focus(0); + my $textview = Gtk2::TextView->new;$textview ->set_editable (0);$textview ->can_focus(0); my $buffer = $textview->get_buffer; $scroller->add($textview); - my $button = Gtk2::Button->new_from_stock('gtk-quit'); - $button->signal_connect( clicked => sub { exit; } ); + my $button = Gtk2::Button->new_from_stock('gtk-quit'); + $button->signal_connect( clicked => sub { exit; } ); $vbox->pack_start( $button, FALSE, FALSE, 0 ); - $buffer->insert( $buffer->get_end_iter, "$VerboseStuff\n"); + $buffer->insert( $buffer->get_end_iter, "$VerboseStuff\n"); $window->show_all; if ($::MainAppWindow) { $::MainAppWindow->destroy(); @@ -362,10 +362,10 @@ __ } $::EPICFAIL = 1; $ENV{'EPICFAIL'} = 1; - Gtk2->main; - Gtk2->main_quit; + Gtk2->main; + Gtk2->main_quit; return 0; -} +} 1; diff --git a/X2Go/Telekinesis/Client/Supporting_Services.pm b/X2Go/Telekinesis/Client/Supporting_Services.pm index 955d693..22774be 100644 --- a/X2Go/Telekinesis/Client/Supporting_Services.pm +++ b/X2Go/Telekinesis/Client/Supporting_Services.pm @@ -40,7 +40,7 @@ sub getActiveWindowAndDTSIZE { ($focused_win, undef) = $x11->GetInputFocus; $focused_win =~ s/\D//g; - return ($focused_win,$width,$height); + return ($focused_win,$width,$height); } diff --git a/X2Go/Telekinesis/CommonCore.pm b/X2Go/Telekinesis/CommonCore.pm index f4c7f33..2779b71 100644 --- a/X2Go/Telekinesis/CommonCore.pm +++ b/X2Go/Telekinesis/CommonCore.pm @@ -23,7 +23,7 @@ ################################################################################################################# package X2Go::Telekinesis::CommonCore; use strict; -use Exporter qw(import); +use Exporter qw(import); our @EXPORT_OK = qw(tcDie sanitizer checkPID sanitizeFilePath sanitizeDirPath genRandSID genRandFID clups dbugPrint); @@ -34,7 +34,7 @@ sub tcDie { sub dbugPrint { if ($ENV{'TKDBUGDUMP'} eq 1) {print "@_\n";} -} +} sub sanitizeDirPath { # NOT REALLY WORTH A DAMN, SOMEONE SHOULD FIX THIS!!! @@ -44,8 +44,8 @@ sub sanitizeDirPath { if ($fPath =~ /^(.*)$/) { $fPath = $1; return $fPath; - } else {return 0;} - } else {return 0;} + } else {return 0;} + } else {return 0;} } sub sanitizeFilePath { @@ -56,12 +56,12 @@ sub sanitizeFilePath { if ($fPath =~ /^(.*)$/) { $fPath = $1; return $fPath; - } else {return 0;} - } else {return 0;} + } else {return 0;} + } else {return 0;} } sub sanitizer { -# Over Zelous string sanitizer that makes perl strict and perl -T happy... +# Overzealous string sanitizer that makes perl strict and perl -T happy... my $type = $_[0]; my $string = $_[1]; if ($type eq "anumazcs") { @@ -69,77 +69,77 @@ sub sanitizer { if ($string =~ /^([a-zA-Z0-9]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "alpazuc") { $string = uc($string); $string =~ s/[^A-Z]//g; if ($string =~ /^([A-Z]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "alpazlc") { $string = lc($string); $string =~ s/[^a-z]//g; if ($string =~ /^([a-z]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazlc") { $string = lc($string); $string =~ s/[^a-z0-9]//g; if ($string =~ /^([a-z0-9]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "num") { $string =~ s/\D//g; if ($string =~ /^([0-9]*)$/) { $string = $1; return $string; - } else {return 0;} - }elsif ($type eq "numdot") { + } else {return 0;} + } elsif ($type eq "numdot") { $string =~ s/[^0-9\.]//g; if ($string =~ /^([0-9\.]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazcsdaus") { $string =~ s/[^a-zA-Z0-9\_\-]//g; if ($string =~ /^([a-zA-Z0-9\_\-]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazcsdausdots") { $string =~ s/[^a-zA-Z0-9\_\-\:\.]//g; if ($string =~ /^([a-zA-Z0-9\_\-\:\.]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazcsdausdotspipe") { $string =~ s/[^a-zA-Z0-9\_\-\:\.\|]//g; if ($string =~ /^([a-zA-Z0-9\_\-\:\.\|]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "pnixusername") { $string =~ s/[^a-zA-Z0-9\_\-\.]//g; if ($string =~ /^([a-zA-Z0-9\_\-\.]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "tekiappname") { $string = lc($string); $string =~ s/[^a-z]//g; if ($string =~ /^([a-z]{4,32})$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "tekiappsid") { $string =~ s/[^a-zA-Z0-9]//g; if ($string =~ /^([a-zA-Z0-9]{3,32})$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "x2gosid") { $string =~ s/[^a-zA-Z0-9\_\-\$\.]//g; if ($string =~ /^([a-zA-Z0-9\_\-\$\.]*)$/) { @@ -152,7 +152,7 @@ sub sanitizer { } else {return 0;} } elsif ($type eq "SOMETHINGELSE") { return 0; - } else {tcDie("Some dumb smuch asked for a nonexisten sanitation rule....\nIt may be a big deal... or it may not be...\nNever the less we're putting an end to this...");} + } else {tcDie("Some dumb smuch asked for a non-existent sanitation rule....\nIt may be a big deal... or it may not be...\nNevertheless, we're putting an end to this...");} } sub checkPID { @@ -166,9 +166,9 @@ sub checkPID { } sub genRandSID { - srand(); + srand(); my $time = time(); - my $rcnt = (24 - length($time)); + my $rcnt = (24 - length($time)); my @chars = ('0'..'9','a'..'z','A'..'Z'); my $randmake; for (my $i=0; $i<$rcnt; $i++) {$randmake .= $chars[int(rand($#chars + 1))];} @@ -176,9 +176,9 @@ sub genRandSID { } sub genRandFID { - srand(); + srand(); my $time = time(); - my $rcnt = (32 - length($time)); + my $rcnt = (32 - length($time)); my @chars = ('0'..'9','a'..'z','A'..'Z'); my $randmake; for (my $i=0; $i<$rcnt; $i++) {$randmake .= $chars[int(rand($#chars + 1))];} diff --git a/X2Go/Telekinesis/CoreSupport.pm b/X2Go/Telekinesis/CoreSupport.pm index 663b3bb..497f6cc 100644 --- a/X2Go/Telekinesis/CoreSupport.pm +++ b/X2Go/Telekinesis/CoreSupport.pm @@ -26,7 +26,7 @@ use strict; #use warnings; use File::stat; use Exporter qw(import); - + our @EXPORT_OK = qw( vCompChkWeNewest versionCompCheck getConnectToken premZealot getCmdFlags dbugPrint tcDie sanitizeDirPath sanitizeFilePath sanitizer checkPID genRandSID genRandToken clups); @@ -38,7 +38,7 @@ sub vCompChkWeNewest { $w1 = sprintf("%03d", $w1);$w2 = sprintf("%03d", $w2);$w3 = sprintf("%03d", $w3);$w4 = sprintf("%03d", $w4); my $chkWe = "$w1$w2$w3$w4"; my ($t1,$t2,$t3,$t4) = $Them =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; - $t1 = sprintf("%03d", $t1);$t2 = sprintf("%03d", $t2);$t3 = sprintf("%03d", $t3);$t4 = sprintf("%03d", $t4); + $t1 = sprintf("%03d", $t1);$t2 = sprintf("%03d", $t2);$t3 = sprintf("%03d", $t3);$t4 = sprintf("%03d", $t4); my $chkThem = "$t1$t2$t3$t4"; if ($chkWe >= $chkThem) { return "U"; @@ -58,7 +58,7 @@ sub versionCompCheck { my $inCheckApp = sanitizer("anumazlc",$_[2]); my $inCheckVer = sanitizer("numdot",$_[3]); - if (-d $inCheckDir) { # If the dir dont exist thers no point in doing anything else? + if (-d $inCheckDir) { # If the dir doesn't exist there's no point in doing anything else? my $useCheckDir; if ($inCheckApp eq "self") {# <- If we are looking up information about our self... $useCheckDir = $inCheckDir; @@ -69,28 +69,28 @@ sub versionCompCheck { open(VCF,"$useCheckDir/$inCheckApp.vc"); my ($vcfOwnVersionA,@vcfCompInfo) = <VCF>; close(VCF); - my ($vcfOwnVersion,$isItSelf) = $vcfOwnVersionA =~ /^([0-9\.]*)\:(.)/;# <- First line should be the localy installed version (what we got our self... hench the S) + my ($vcfOwnVersion,$isItSelf) = $vcfOwnVersionA =~ /^([0-9\.]*)\:(.)/;# <- First line should be the locally installed version (what we got our self... hence the S) $isItSelf = clups($isItSelf); if ($isItSelf eq "S") { # <- and this should be S if not... the .vc file is not a good .vc file.... if ($inCheckType eq 0) {# Check type "0" is a local version request call... - return ($inCheckApp,$vcfOwnVersion);#so we answer the call with this reply - } elsif (($inCheckType eq 1) and ($inCheckVer =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) {# Type 1 is a compatibility check call where we reply 0 or 1 + return ($inCheckApp,$vcfOwnVersion);#so we answer the call with this reply + } elsif (($inCheckType eq 1) and ($inCheckVer =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) {# Type 1 is a compatibility check call where we reply 0 or 1 if ($inCheckVer eq $vcfOwnVersion) {# If check version is the same as our version... the it should be ok.. right?!! return 1; - } else {# Otherwise start more "indepth" checking procedures.... + } else {# Otherwise start more "in-depth" checking procedures.... my $vCompState = "N"; foreach my $vcfCompLine (@vcfCompInfo) {# the rest of the .vc file should be lines with version numbers and compatibility flags. my ($vcfCLver,$vcfCLstate) = split(/\:/,uc($vcfCompLine)); - $vcfCLver = sanitizer("numdot",$vcfCLver); - $vcfCLstate =~ s/[^CB]//g; # flags are either C=compatible or B=broken.. + $vcfCLver = sanitizer("numdot",$vcfCLver); + $vcfCLstate =~ s/[^CB]//g; # flags are either C=compatible or B=broken.. if (($vcfCLstate) and ($vcfCLver =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) {# the .vc file line to be a valid line the state flag need to be valid so does the version number format.... if ($inCheckVer eq $vcfCLver) { unless ($vCompState eq "B") {$vCompState = $vcfCLstate;}# If for some nutty reason there are duplicates and one is broken... then thats what we'll report } } } - # If the final judgement is C (compatible) then we return 1, for anything else we return 0) + # If the final judgement is C (compatible) then we return 1, for anything else we return 0) if ($vCompState eq "C") {return 1;} else {return 0;} } } else {return 0;} @@ -129,8 +129,8 @@ sub getCmdFlags { $ent =~ s/\n//g; #print "EX:$ent:EX\n"; if ($ent =~ /^\-set([A-Z0-9]{4,24})\=(.*)$/) { - $theArgs{$1} = $2; - } + $theArgs{$1} = $2; + } } return %theArgs; } @@ -140,7 +140,7 @@ sub dbugPrint { if (($::CmdFlags{'DEBUG'}) or (uc($_[1]) eq "T")) { my $lTime = time(); my $logLevel = 0; - if (uc($_[1]) eq "T") {$logLevel = 1;} + if (uc($_[1]) eq "T") {$logLevel = 1;} elsif (uc($_[1]) eq "W") {$logLevel = 2;} elsif (uc($_[1]) eq "I") {$logLevel = 9;} if (-d $::X2GoSesHome) { @@ -153,7 +153,7 @@ sub dbugPrint { close(LOG); } } -} +} sub tcDie { my $error = "@_"; @@ -181,8 +181,8 @@ sub sanitizeDirPath { if ($fPath =~ /^(.*)$/) { $fPath = $1; return $fPath; - } else {return 0;} - } else {return 0;} + } else {return 0;} + } else {return 0;} } sub sanitizeFilePath { @@ -193,12 +193,12 @@ sub sanitizeFilePath { if ($fPath =~ /^(.*)$/) { $fPath = $1; return $fPath; - } else {return 0;} - } else {return 0;} + } else {return 0;} + } else {return 0;} } sub sanitizer { -# Over Zelous string sanitizer that makes perl strict and perl -T happy... +# Overzealous string sanitizer that makes perl strict and perl -T happy... my $type = $_[0]; my $string = $_[1]; if ($type eq "anumazcs") { @@ -206,64 +206,64 @@ sub sanitizer { if ($string =~ /^([a-zA-Z0-9]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "alpazuc") { $string = uc($string); $string =~ s/[^A-Z]//g; if ($string =~ /^([A-Z]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "alpazlc") { $string = lc($string); $string =~ s/[^a-z]//g; if ($string =~ /^([a-z]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazlc") { $string = lc($string); $string =~ s/[^a-z0-9]//g; if ($string =~ /^([a-z0-9]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "num") { $string =~ s/\D//g; if ($string =~ /^([0-9]*)$/) { $string = $1; return $string; - } else {return 0;} - }elsif ($type eq "numdot") { + } else {return 0;} + } elsif ($type eq "numdot") { $string =~ s/[^0-9\.]//g; if ($string =~ /^([0-9\.]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazcsdaus") { $string =~ s/[^a-zA-Z0-9\_\-]//g; if ($string =~ /^([a-zA-Z0-9\_\-]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazcsdausdots") { $string =~ s/[^a-zA-Z0-9\_\-\:\.]//g; if ($string =~ /^([a-zA-Z0-9\_\-\:\.]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "anumazcsdausdotspipe") { $string =~ s/[^a-zA-Z0-9\_\-\:\.\|]//g; if ($string =~ /^([a-zA-Z0-9\_\-\:\.\|]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "pnixusername") { $string =~ s/[^a-zA-Z0-9\_\-\.]//g; if ($string =~ /^([a-zA-Z0-9\_\-\.]*)$/) { $string = $1; return $string; - } else {return 0;} + } else {return 0;} } elsif ($type eq "x2gosid") { $string =~ s/[^a-zA-Z0-9\_\-\$\.]//g; if ($string =~ /^([a-zA-Z0-9\_\-\$\.]*)$/) { @@ -276,7 +276,7 @@ sub sanitizer { } else {return 0;} } elsif ($type eq "SOMETHINGELSE") { return 0; - } else {tcDie("Some dumb smuch asked for a nonexisten sanitation rule....\nIt may be a big deal... or it may not be...\nNever the less we're putting an end to this...");} + } else {tcDie("Some dumb smuch asked for a non-existent sanitation rule....\nIt may be a big deal... or it may not be...\nNevertheless, we're putting an end to this...");} } sub checkPID { @@ -290,9 +290,9 @@ sub checkPID { } sub genRandSID { - srand(); + srand(); my $time = time(); - my $rcnt = (16 - length($time)); + my $rcnt = (16 - length($time)); my @chars = ('0'..'9','a'..'z','A'..'Z'); my $randmake; for (my $i=0; $i<$rcnt; $i++) {$randmake .= $chars[int(rand($#chars + 1))];} @@ -304,11 +304,11 @@ sub genRandToken { my $RemOrLocal = $_[0]; my $HomeDir = $_[1]; my $FullTokenPath; - if ($RemOrLocal eq "local") {$FullTokenPath = "$HomeDir/local/token";} - elsif ($RemOrLocal eq "remote") {$FullTokenPath = "$HomeDir/remote/token";} + if ($RemOrLocal eq "local") {$FullTokenPath = "$HomeDir/local/token";} + elsif ($RemOrLocal eq "remote") {$FullTokenPath = "$HomeDir/remote/token";} else {tcDie("Someone stepped on a turd and wiped it off, somewhere in the code of this thig...");} - srand(); - my $rcnt = 128; + srand(); + my $rcnt = 128; my @chars = ('0'..'9','a'..'z','A'..'Z'); my $randmake; for (my $i=0; $i<$rcnt; $i++) {$randmake .= $chars[int(rand($#chars + 1))];} diff --git a/client/bin/telekinesis-client b/client/bin/telekinesis-client index 2639973..b1423af 100644 --- a/client/bin/telekinesis-client +++ b/client/bin/telekinesis-client @@ -25,8 +25,8 @@ use strict; use Data::Dumper;# Not in use right this moment but will be very soon...! use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep - clock_gettime clock_getres clock_nanosleep clock - stat ); + clock_gettime clock_getres clock_nanosleep clock + stat ); use Glib qw/TRUE FALSE/; use File::Path qw(make_path remove_tree); #use IO::Socket; @@ -36,7 +36,7 @@ use X2Go::Telekinesis::CoreSupport qw(versionCompCheck getConnectToken premZealo use X2Go::Telekinesis::Client::Supporting_Services qw(getActiveWindowAndDTSIZE); my $TeKiCVersion = "0.0.6.2"; $ENV{'PATH'} = "/bin:/usr/bin"; -@SIG{qw( INT TERM HUP )} = \&doSelfTerminate; # +@SIG{qw( INT TERM HUP )} = \&doSelfTerminate; # my $runCSTATE = "CI";# The runState of telekinesis CI=Initiating, CR=Running, CS=Suspending, CT=Terminating. # Were adding a C to the name and value to signify that this is the state of the client and not the whole thing... our %CmdFlags = getCmdFlags(@ARGV); # Get stuff from command line! @@ -46,11 +46,11 @@ my $UserHome = sanitizeDirPath($ENV{'HOME'}); unless (-d $UserHome) {tcDie("User got no HOME directory?");} ################################################################################################################################# # Again with the checking of the x2go and x2go session directory. -my $X2GoSID = sanitizer("x2gosid",$CmdFlags{'X2GOSID'}) or tcDie("Invalid X2Go Session ID!"); +my $X2GoSID = sanitizer("x2gosid",$CmdFlags{'X2GOSID'}) or tcDie("Invalid X2Go Session ID!"); our $X2GoSesHome = sanitizeDirPath("$UserHome/.x2go/S-$X2GoSID") or tcDie("NO X2Go session home!?\n\"$UserHome/.x2go/S-$X2GoSID\"\nWTF!?!"); our $X2GoTKCHome = "$X2GoSesHome/telekinesis"; dbugPrint("--------------------------------------------------------------------------------"); -# Just drawing a line, sepparating the old and the new.... Just to make the log a bit more human firendly... +# Just drawing a line, separating the old and the new.... Just to make the log a bit more human friendly... dbugPrint("X2GO Session ID: $X2GoSID\nTelekinesis Client HOME: $X2GoTKCHome"); ################################################################################################################################# # Attempt to load paths file.... @@ -61,7 +61,7 @@ if (-f "/etc/x2go/telekinesis/client/paths") { if (length(clups($pathLine)) > 0) { $pathLine =~ s/\n//g; if ($pathLine =~ /^\#/) { - #NOT GOING TO DO ANYTHING FOR COMMANDS ARE WE ??? NAH... + #NOT GOING TO DO ANYTHING FOR COMMANDS ARE WE ??? NAH... } elsif ($pathLine =~ /^([A-Z]{1})\:([0-9A-Z\_\-]{3,32})\=(.*)$/) { my $pName = $2; my $prePath = $3; @@ -69,7 +69,7 @@ if (-f "/etc/x2go/telekinesis/client/paths") { $prePath =~ s/[\s]*$//g; $prePath =~ s/\/$//g; my $cleanPath = sanitizeDirPath($prePath) or tcDie("Sanitation of '$pName' => '$prePath' failed during loading of paths file!"); - if (($cleanPath ne 0) and (-d $cleanPath)) { + if (($cleanPath ne 0) and (-d $cleanPath)) { $TeKiPaths{$pName} = $cleanPath; } } @@ -79,14 +79,14 @@ if (-f "/etc/x2go/telekinesis/client/paths") { close(PATHS); } else {tcDie("NO PATHS FILE!");} ################################################################################################################################# -# By now TeKiPaths should be loaded... Time to verify that all REQUIRED paths are there and contain what we expect... +# By now TeKiPaths should be loaded... Time to verify that all REQUIRED paths are there and contain what we expect... my $vCompDir = "$TeKiPaths{'SHARE'}/client/vcomp";# Where we put the files containing version compatibility stuff.. unless (-f "$vCompDir/self.vc") {tcDie("The 'vCompDir' did not seem to be where we expect it...");}# And if we cant even find out own declaration, something is wrong. #$ENV{'TEKIAPPDIR'} = "/home/theuser/x2gos/telekinesis/applications/"; my $TeKiCSAppDir = sanitizeDirPath("$TeKiPaths{'LIB'}/client/applications") or tcDie("No client side applications directory... "); ################################################################################################################################# # Over zealusly initiate the variable that holds the user name -my ($GPWUIDuserName,undef) = getpwuid( $< );# More reliable than $ENV{'USER'} etc... +my ($GPWUIDuserName,undef) = getpwuid( $< );# More reliable than $ENV{'USER'} etc... my $UserName = sanitizer("pnixusername",$GPWUIDuserName); if ($UserName eq 0) {tcDie("Is \"$UserName\" a valid portable UNIX username?\nNah.... Didn't think so....\nWe're done! BYE BYE!\n");} dbugPrint("Running as USER: $UserName\nWith HOME Dir: $UserHome"); @@ -96,43 +96,43 @@ dbugPrint("Running as USER: $UserName\nWith HOME Dir: $UserHome"); my $tkWormholeAtPORT = $CmdFlags{'WORMHOLEPORT'};# Try to grab the info from the command line flag... $tkWormholeAtPORT =~ s/\D//g;# Should be a number so we just wipe away anything else... if (($tkWormholeAtPORT > 0) and ($tkWormholeAtPORT < 100000)) { - # WE probably want to do something here....?! RIGHT? + # WE probably want to do something here....?! RIGHT? } else {tcDie("Did not get a usefull port number input from command line!");} my $tkWormholeAtADDR = "localhost";# For now we're going to stick with "localhost"... but we're not hardcoding it future down... dbugPrint("Requests connecting to master at port $tkWormholeAtPORT on $tkWormholeAtADDR"); ################################################################################################################################# # Check for lock file existace and running processes.... at this time there should be none.... -if (-f "$X2GoTKCHome/lock") { # So if there is one... - open(OLF,"$X2GoTKCHome/lock");my ($OldPID,$OldStartTime,undef) = <OLF>;close(OLF);# Lets have a look inside... +if (-f "$X2GoTKCHome/lock") { # So if there is one... + open(OLF,"$X2GoTKCHome/lock");my ($OldPID,$OldStartTime,undef) = <OLF>;close(OLF);# Lets have a look inside... $OldPID = sanitizer("num",$OldPID);$OldStartTime =~ s/\D//g; - my ($psP,$psU,$psN,$psC) = checkPID($OldPID); # And check if the PID is still running - if (($psC =~ /telekinesis/) and ($psU eq $UserName)) { # And if it is running and OURS.... Is it telekinesis?!? - # Since we probably dont want to automagically murder a running session. We're going to just suggest a solution to the user.. - # Though nobody should be executing this manualy... + my ($psP,$psU,$psN,$psC) = checkPID($OldPID); # And check if the PID is still running + if (($psC =~ /telekinesis/) and ($psU eq $UserName)) { # And if it is running and OURS.... Is it telekinesis?!? + # Since we probably don't want to automagically murder a running session. We're going to just suggest a solution to the user.. + # Though nobody should be executing this manually... if ($CmdFlags{'FORCENEW'}) {# About time to start cleaning up if we are ordered to FORCE a new clean session dbugPrint("START FORCING NEW..."); kill("TERM",$OldPID);# Try to kill it in a friendly and polite manner.... sleep 2;# Give it some time to die... - my ($psP2,$psU2,$psN2,$psC2) = checkPID($OldPID);# Then Check if the pid still is running + my ($psP2,$psU2,$psN2,$psC2) = checkPID($OldPID);# Then check if the PID still is running if (($psC2 =~ /telekinesis/) and ($psU2 eq $UserName)) {# and if it is... - kill("KILL",$OldPID);# Try killing it in a more abrupt and brutal fassion... + kill("KILL",$OldPID);# Try killing it in a more abrupt and brutal fashion... sleep 3;# Give it some time to die... - my ($psP3,$psU3,$psN3,$psC3) = checkPID($OldPID);# Then Check again... if the pid still is running + my ($psP3,$psU3,$psN3,$psC3) = checkPID($OldPID);# Then Check again... if the PID still is running if (($psC3 =~ /telekinesis/) and ($psU3 eq $UserName)) {# and if it is... - tcDie("We did try to kill the damn thing running as pid $OldPID, but it just wont die..."); + tcDie("We did try to kill the damn thing running as pid $OldPID, but it just wont die..."); } else { - cleanUpOldSession($X2GoTKCHome);# ok it dead now.... lets get on with the cleaning.... - } + cleanUpOldSession($X2GoTKCHome);# ok it's dead now.... let's get on with the cleaning.... + } } else { - cleanUpOldSession($X2GoTKCHome);# ok it dead now.... lets get on with the cleaning.... - } + cleanUpOldSession($X2GoTKCHome);# ok it's dead now.... let's get on with the cleaning.... + } } else { - my $runTime = (time() - $OldStartTime);# How long has it been running for? - tcDie("Looks like we've already been running as pid $OldPID for $runTime secods\nrun with the -setFORCENEW=1 to kill the old and force a new!"); + my $runTime = (time() - $OldStartTime);# How long has it been running for? + tcDie("Looks like we've already been running as pid $OldPID for $runTime seconds\nrun with the -setFORCENEW=1 to kill the old and force a new!"); } - } else {# If its not telekinesis... lets automaticaly clean up the old/dead session... + } else {# If its not telekinesis... let's automatically clean up the old/dead session... cleanUpOldSession($X2GoTKCHome); } } else { @@ -140,11 +140,11 @@ if (-f "$X2GoTKCHome/lock") { # So if there is one... } -if (-d "$X2GoTKCHome") { # This really should not be happeining! - tcDie("After countless cleanup attempts... things are still a mess... so we're giving up..."); +if (-d "$X2GoTKCHome") { # This really should not be happening! + tcDie("After countless cleanup attempts... things are still a mess... so we're giving up..."); } else { # By now we should be ready to prep for the startup of a new session! - doPrepForNewSESSION($X2GoTKCHome,$X2GoSID,$UserName); + doPrepForNewSESSION($X2GoTKCHome,$X2GoSID,$UserName); } ################################################################################################################################# @@ -157,7 +157,7 @@ my %sstatusi;$sstatusi{'lastRTT'} = 0;$sstatusi{'WormholeState'} = 0;$sstatusi{' my %LSRVC; my %TnW; my %CHANS; -my %TeKiServices;&declareBuiltInServices; +my %TeKiServices;&declareBuiltInServices; my %vSupApp; my %LocalConnections; my $LocalSocket; @@ -165,7 +165,7 @@ my $TheWormhole; ###### if (-f "$X2GoTKCHome/lock") { - $LocalSocket = IO::Socket::UNIX->new(Local => "$X2GoTKCHome/local/sock", Type => SOCK_STREAM, Reuse => 1, + $LocalSocket = IO::Socket::UNIX->new(Local => "$X2GoTKCHome/local/sock", Type => SOCK_STREAM, Reuse => 1, Timeout => 5, Listen => SOMAXCONN );# Start the socket that will be dealing with local applications... if (defined $LocalSocket){ premZealot("$X2GoTKCHome/local/sock");# Set the propper premissions on the socket! @@ -174,18 +174,18 @@ if (-f "$X2GoTKCHome/lock") { } else { tcDie("Unable to start local master socket!"); } - $sstatusi{'prevRunSTATE'} = $runCSTATE;# THIS IS THE ONLY TIME AND PLACE WE EVER SET 'prevRunSTATE' MANUALY!!!!! + $sstatusi{'prevRunSTATE'} = $runCSTATE;# THIS IS THE ONLY TIME AND PLACE WE EVER SET 'prevRunSTATE' MANUALLY!!!!! $runCSTATE = "CR"; } else {tcDie("WTF?");} -##################################### ##################################### ##################################### ##################################### -# The Main Gtk2 event loop +##################################### ##################################### ##################################### ##################################### +# The Main Gtk2 event loop Gtk2->init; $TnW{'runstatechanges'} = Glib::Timeout->add (100, \&coreRunSTATEchanges); my $timeoutRoundTripStat = Glib::Timeout->add (1000, sub {if((defined $TheWormhole and ($sstatusi{'WormholeState'} eq 3))){my ($sendTimeS,$sendTimeMS) = gettimeofday;print $TheWormhole "\nCORE_RTT_INIT\|$sendTimeS\.$sendTimeMS\|$sstatusi{'lastRTT'}\|\n";} 1;}, ['no','thing']); Gtk2->main; -# The Main Gtk2 event loop -##################################### ##################################### ##################################### ##################################### +# The Main Gtk2 event loop +##################################### ##################################### ##################################### ##################################### dbugPrint("Execution came to a natural end..."); @@ -196,18 +196,18 @@ dbugPrint("Execution came to a natural end..."); # HERE IS WHERE WE PUT ALL THE SUBS FOR THIS APP ################################################################################################################################# -# This SUB do various prepparations as part of session initiation and other changes to runSTATE +# This SUB do various preparations as part of session initiation and other changes to runSTATE sub coreRunSTATEchanges { - if (($sstatusi{'prevRunSTATE'} ne $runCSTATE) or ($sstatusi{'WormholeState'} eq 0)) { + if (($sstatusi{'prevRunSTATE'} ne $runCSTATE) or ($sstatusi{'WormholeState'} eq 0)) { dbugPrint("Run STATE changed from $sstatusi{'prevRunSTATE'} to $runCSTATE!"); if ($runCSTATE eq "CR") { if (($sstatusi{'WormholeState'} eq 0) and ( ! defined $TheWormhole)) { $sstatusi{'WormholeState'} = 1; - dbugPrint("Attempting to initiate Wormhole..."); + dbugPrint("Attempting to initiate wormhole..."); if ($sstatusi{'WHCRetryCnt'} > 0) { if ($sstatusi{'WHCRetryCnt'} > 10) { - dbugPrint("Too many retry attems at opening the wormhole...\nThere is a problem bigger than just a sporadic glitch..."); - doSelfTerminate(); + dbugPrint("Too many retry attempts at opening the wormhole...\nThere is a problem bigger than just a sporadic glitch..."); + doSelfTerminate(); } else { my $sleepTime = (($sstatusi{'WHCRetryCnt'}*100000)*2); dbugPrint("Sleeping for: $sleepTime u"); @@ -217,21 +217,21 @@ sub coreRunSTATEchanges { $TheWormhole = IO::Socket::INET->new(PeerAddr => $tkWormholeAtADDR,PeerPort => $tkWormholeAtPORT,Proto => 'tcp',Timeout => 10); $sstatusi{'WHCRetryCnt'}++; my $wormholeToken = getConnectToken("remote",$X2GoTKCHome); - if ((defined $TheWormhole) and ($wormholeToken ne 0)){ + if ((defined $TheWormhole) and ($wormholeToken ne 0)){ $sstatusi{'WormholeState'} = 1; - dbugPrint("Connected?\nTrying to authenticate with:$wormholeToken"); + dbugPrint("Connected?\nTrying to authenticate with:$wormholeToken"); print $TheWormhole "IDC|$wormholeToken|\n"; $TnW{'WormholeWatcher'} = Glib::IO->add_watch( fileno($TheWormhole), [qw/in hup err/], \&CShandleTheWormhole, $TheWormhole ); } else { - #$TheWormhole->close; + #$TheWormhole->close; #$TheWormhole= undef; $sstatusi{'WormholeState'} = 0; dbugPrint("ERROR: Can't connect to port $tkWormholeAtPORT on $tkWormholeAtADDR: $!\nTrying to reconnect in a bit..."); - } - + } + } } elsif (($runCSTATE eq "CS") or ($runCSTATE eq "CT")) { -# Maybe we want to do something here? + # Maybe we want to do something here? } $sstatusi{'prevRunSTATE'} = $runCSTATE; } @@ -239,7 +239,7 @@ sub coreRunSTATEchanges { } ################################################################################################################################# -# This SUB do various prepparations as part of session initiation. +# This SUB do various preparations as part of session initiation. sub doPrepForNewSESSION { dbugPrint("Start C Session Prepping...."); my $X2GoTKCHome = $_[0]; @@ -247,8 +247,8 @@ sub doPrepForNewSESSION { my $UserName = $_[2]; my $PID = $$; my $time = time(); - # make shure its a valid "porable" unix username.... - if (!-d "$X2GoTKCHome") {mkdir("$X2GoTKCHome") or tcDie("$X2GoTKCHome does not exist... We need someone create this for us!\nIf not we're don't feel that warm and fuzzy welcoming feeling!");} + # make sure its a valid "portable" unix username.... + if (!-d "$X2GoTKCHome") {mkdir("$X2GoTKCHome") or tcDie("$X2GoTKCHome does not exist... We need someone create this for us!\nIf not we won't feel that warm and fuzzy welcoming feeling!");} premZealot("$X2GoTKCHome"); open(LOCK,">$X2GoTKCHome/lock");print LOCK "$PID\n$time\n";close(LOCK); if (!-d "$X2GoTKCHome/local") {mkdir("$X2GoTKCHome/local") or tcDie("Can't create \"$X2GoTKCHome/local\" dir!");} @@ -258,7 +258,7 @@ sub doPrepForNewSESSION { if (!-f "$X2GoTKCHome/remote/token") {symlink("/tmp/.x2go-$UserName/telekinesis/S-$X2GoSID","$X2GoTKCHome/remote") or tcDie("Remote Symlink failed!");} } else {tcDie("SSHFS Init probably failed?");} - dbugPrint("DONE Session prepping..."); + dbugPrint("DONE Session prepping..."); } ################################################################################################################################# @@ -268,38 +268,38 @@ sub cleanUpOldSession { dbugPrint("Start cleaning old session junk...\nCleaning up $X2GoTKCHome..."); if (-d "$X2GoTKCHome") { remove_tree("$X2GoTKCHome") or tcDie("Can't remove the \"$X2GoTKCHome\" dir!\ There is probably still some junk left in it?!"); - } + } dbugPrint("DONE cleaning old session junk!"); } ############################################################################################################################################ ################################################################################################################################# -# Local Socet stuff +# Local socket stuff ################################################################################################################################# -# This SUB do initiation of local socet connections +# This SUB do initiation of local socket connections sub initLocalCSocketCon { my ( $fd, $condition, $fh ) = @_; - dbugPrint("Local socket connection starting..: $fd, $condition, $fh"); + dbugPrint("Local socket connection starting..: $fd, $condition, $fh"); my $client = $LocalSocket->accept() or dbugPrint("Can't accept connection @_"); $client->autoflush(1); my $bytes = sysread($client,my $data,4096); my $saneData = sanitizer("anumazcsdausdotspipe","$data"); -# dbugPrint("SD:$saneData:sd"); # Bit too much info to log... +# dbugPrint("SD:$saneData:sd"); # Bit too much info to log... if ($saneData =~ /^QUICKIE\|/) { - dbugPrint("Handing over to quickie handler...(thats yet to be implemented on the client side!)"); + dbugPrint("Handing over to quickie handler...(that's yet to be implemented on the client side!)"); # Nothing using QUICKIE handling on the client side... for now... } elsif ($saneData =~ /^APP\|INITC\|([a-z]{3,32})\|([a-zA-Z0-9]{3,32})\|([a-zA-Z0-9]{3,32})\|/) { if ($vSupApp{'agree'}{$1}) { my $chanID = "$1\_$2"; - dbugPrint("Channel ID: $chanID\nHanding over to appinit handler...\n$CHANS{$chanID}{'expectSlaveToken'} eq $3"); + dbugPrint("Channel ID: $chanID\nHanding over to appinit handler...\n$CHANS{$chanID}{'expectSlaveToken'} eq $3"); if ($CHANS{$chanID}{'initTime'} and ($CHANS{$chanID}{'expectSlaveToken'} eq $3)) { - dbugPrint("Sanity auth ok..."); - # removeChannel($chanID); + dbugPrint("Sanity auth ok..."); + # removeChannel($chanID); $CHANS{$chanID}{'iowatcher'} = Glib::IO->add_watch ( fileno( $client ), ['in', 'hup', 'err'], \&handleClientsideAppConnection, $client ); - $CHANS{$chanID}{'sockclient'} = $client; + $CHANS{$chanID}{'sockclient'} = $client; print $TheWormhole "\nAPP|INITC|$1|$2|\n"; } else { print $client "TERMINATE|NO_REASON|\n"; @@ -310,9 +310,9 @@ sub initLocalCSocketCon { if ($vSupApp{'server'}{$1}) { dbugPrint("Our $1 version is not compatible with the server..."); print $client "TERMINATE|NO_PAIR1|\n"; - } else { + } else { if ($sstatusi{'WormholeState'} < 3) { - dbugPrint("Not connected to server or incomplete version negotaitions"); + dbugPrint("Not connected to server or incomplete version negotiations"); print $client "RETRYLATER|NO_PAIR|\n"; $client->close;$client = undef; } else { @@ -325,13 +325,13 @@ sub initLocalCSocketCon { } else { print $client "TERMINATE|NO_REASON|\n"; $client->close;$client = undef; - } + } return 1; } sub handleClientsideAppConnection { my ( $fd, $condition, $client ) = @_; - dbugPrint("Handling: $fd, $condition, $client"); + dbugPrint("Handling: $fd, $condition, $client"); if ( $condition >= 'hup' or $condition >= 'err' ) {$client->close;$client = undef;return 0;} if ($client) { if ( $condition >= 'in' ) { @@ -357,7 +357,7 @@ sub handleClientsideAppConnection { ################################################################################################################################# ################################################################################################################################# -# A couple channel managment subs: +# A couple channel management subs: sub initClientSideChan { my $appName = sanitizer("alpazlc",$_[0]); my $appSID = $_[1]; @@ -367,10 +367,10 @@ sub initClientSideChan { if (-x $appEXEC) { my $chanID = "$appName\_$appSID"; dbugPrint("Channel ID: $chanID"); - dbugPrint("Handing over to appinit handler..."); + dbugPrint("Handing over to appinit handler..."); if ($CHANS{$chanID}{'initTime'}) { removeChannel($chanID); - } + } unless ($CHANS{$chanID}{'initTime'}) { $CHANS{$chanID}{'initTime'} = time(); $CHANS{$chanID}{'expectSlaveToken'} = genRandSID(); @@ -379,13 +379,13 @@ sub initClientSideChan { dbugPrint("problems with the removal of existing channel..."); } } else {dbugPrint("The executable for this application seem to be missing!\n$appEXEC");} - } else {dbugPrint("Trying to run something we did not agree on? Serverside should already have caugth this!?!?!");} + } else {dbugPrint("Trying to run something we did not agree on? Server side should already have caugth this!?!?!");} } sub removeChannel { my $rmChID = $_[0];# should by this point be sanitized anyhow... if ($CHANS{$rmChID}{'initTime'}) { - Glib::Source->remove($CHANS{$rmChID}{'iowatcher'}) or dbugPrint("Problems while removing WATCHER on existing channel: \"$rmChID\"...\nProbably not a big deal anyway... since it means its already removed."); + Glib::Source->remove($CHANS{$rmChID}{'iowatcher'}) or dbugPrint("Problems while removing WATCHER on existing channel: \"$rmChID\"...\nProbably not a big deal anyway... since it means its already removed."); if ($CHANS{$rmChID}{'sockclient'}) { my $client = $CHANS{$rmChID}{'sockclient'}; sayToClient($client,"TERMINATE|BECAUSEISAIDSO|"); @@ -393,7 +393,7 @@ sub removeChannel { $CHANS{$rmChID}{'sockclient'}->close; } $CHANS{$rmChID} = undef; - } + } } @@ -418,13 +418,13 @@ sub sayToClient { -# Local Socet Stuff +# Local socket Stuff ################################################################################################################################# ############################################################################################################################################ ################################################################################################################################# # START OF HARDCODED SERVICES AND SUPPORTIVE SUBS... -# This Section Hadles LOCAL client side Telekinesis hardcoded services.... -# Originaly created to handle polling for the status of X2Go client window. +# This Section Handles LOCAL client side Telekinesis hardcoded services.... +# Originally created to handle polling for the status of X2Go client window. sub declareBuiltInServices { $TeKiServices{'StateOfX2GoCliWin'}{'gotit'} = 1; $TeKiServices{'StateOfX2GoCliWin'}{'active'} = 0; @@ -442,19 +442,19 @@ sub initBuiltInServices { dbugPrint("Core service name: '$requestedServiceName'"); ################################# # - if ($requestedServiceName eq "StateOfX2GoCliWin") { - $TeKiServices{'StateOfX2GoCliWin'}{'clients'}{$requestedBy} = 1; - runStateOfX2GoCliWin(1); - if ($TeKiServices{'StateOfX2GoCliWin'}{'active'} ne 1) { - dbugPrint("Service STARTED"); - $TeKiServices{'StateOfX2GoCliWin'}{'active'} = 1; - $TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'} = 0; - $TeKiServices{'StateOfX2GoCliWin'}{'glibTimeoutID'} = Glib::Timeout->add (50, \&runStateOfX2GoCliWin);# Make this configurable? - } else { - dbugPrint("Service already started..."); - } - - } + if ($requestedServiceName eq "StateOfX2GoCliWin") { + $TeKiServices{'StateOfX2GoCliWin'}{'clients'}{$requestedBy} = 1; + runStateOfX2GoCliWin(1); + if ($TeKiServices{'StateOfX2GoCliWin'}{'active'} ne 1) { + dbugPrint("Service STARTED"); + $TeKiServices{'StateOfX2GoCliWin'}{'active'} = 1; + $TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'} = 0; + $TeKiServices{'StateOfX2GoCliWin'}{'glibTimeoutID'} = Glib::Timeout->add (50, \&runStateOfX2GoCliWin);# Make this configurable? + } else { + dbugPrint("Service already started..."); + } + + } # ################################# } @@ -463,77 +463,77 @@ sub initBuiltInServices { } sub runStateOfX2GoCliWin { - if ($TeKiServices{'StateOfX2GoCliWin'}{'active'} eq 1) { - unless ($TeKiServices{'StateOfX2GoCliWin'}{'DecWid'}) { - if (-f "$X2GoSesHome/session.window") { - open(SWXID,"$X2GoSesHome/session.window"); - my ($tmpSwXid,undef) = <SWXID>; - close(SWXID); - if ($tmpSwXid =~ /ID:(\d*)/) { - dbugPrint("session.window file OK ($1)"); - $TeKiServices{'StateOfX2GoCliWin'}{'DecWid'} = $1; - $TeKiServices{'StateOfX2GoCliWin'}{'theWindow'} = Gtk2::Gdk::Window->foreign_new($1); - } - } - } - - if ($TeKiServices{'StateOfX2GoCliWin'}{'theWindow'}) { - - if ($TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'} < 1) { - ($TeKiServices{'StateOfX2GoCliWin'}{'ActiveWID'},$TeKiServices{'StateOfX2GoCliWin'}{'DeskW'},$TeKiServices{'StateOfX2GoCliWin'}{'DeskH'}) = getActiveWindowAndDTSIZE(); - $TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'} = 5; - } else { - $TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'}--; - } - my $DeskW = $TeKiServices{'StateOfX2GoCliWin'}{'DeskW'}; - my $DeskH = $TeKiServices{'StateOfX2GoCliWin'}{'DeskH'}; - - my $FullScreen = 0; - my $Visible = 0; - my ($ax,$ay) = $TeKiServices{'StateOfX2GoCliWin'}{'theWindow'}->get_origin; - my ($relx, $rely, $w, $h, undef) = $TeKiServices{'StateOfX2GoCliWin'}{'theWindow'}->get_geometry; - if ($TeKiServices{'StateOfX2GoCliWin'}{'ActiveWID'} eq $TeKiServices{'StateOfX2GoCliWin'}{'DecWid'}) { - $Visible = 1; - } - - if (($w >= $DeskW) and ($h >= $DeskH)) { - if (($relx == 0) and ($rely == 0)) {if (($ax == 0) and ($ay == 0)) { - $FullScreen = 1; - }} - } - - if ( - ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'FullScreen'} ne $FullScreen) or - ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'Visible'} ne $Visible) or - ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ax'} ne $ax) or - ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ay'} ne $ay) or - ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'h'} ne $h) or - ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'w'} ne $w) or - ($_[0] eq 1) - ) { - - $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'FullScreen'} = $FullScreen; - $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'Visible'} = $Visible; - $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ax'} = $ax; - $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ay'} = $ay; - $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'h'} = $h; - $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'w'} = $w; - my $SendString = "1|1|0|0|0|0"; - if ($FullScreen eq 1) { - # Default And Asuming we're thin client mode in which case we should never get this far anyhow.... - } else { - $SendString = clups("0|$Visible|$ax|$ay|$h|$w"); - } - dbugPrint("StateOfX2GoCW: A:$TeKiServices{'StateOfX2GoCliWin'}{'ActiveWID'} U:$TeKiServices{'StateOfX2GoCliWin'}{'DecWid'} S:$SendString"); - foreach my $chanID (keys $TeKiServices{'StateOfX2GoCliWin'}{'clients'}) { - if ($CHANS{$chanID}{'sockclient'}) { - my $client = $CHANS{$chanID}{'sockclient'}; - sayToClient($client,"CORE|SERVICES|X2GOWINDOWSTATE|$SendString|"); - } - } - } - } - } + if ($TeKiServices{'StateOfX2GoCliWin'}{'active'} eq 1) { + unless ($TeKiServices{'StateOfX2GoCliWin'}{'DecWid'}) { + if (-f "$X2GoSesHome/session.window") { + open(SWXID,"$X2GoSesHome/session.window"); + my ($tmpSwXid,undef) = <SWXID>; + close(SWXID); + if ($tmpSwXid =~ /ID:(\d*)/) { + dbugPrint("session.window file OK ($1)"); + $TeKiServices{'StateOfX2GoCliWin'}{'DecWid'} = $1; + $TeKiServices{'StateOfX2GoCliWin'}{'theWindow'} = Gtk2::Gdk::Window->foreign_new($1); + } + } + } + + if ($TeKiServices{'StateOfX2GoCliWin'}{'theWindow'}) { + + if ($TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'} < 1) { + ($TeKiServices{'StateOfX2GoCliWin'}{'ActiveWID'},$TeKiServices{'StateOfX2GoCliWin'}{'DeskW'},$TeKiServices{'StateOfX2GoCliWin'}{'DeskH'}) = getActiveWindowAndDTSIZE(); + $TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'} = 5; + } else { + $TeKiServices{'StateOfX2GoCliWin'}{'loopCnt'}--; + } + my $DeskW = $TeKiServices{'StateOfX2GoCliWin'}{'DeskW'}; + my $DeskH = $TeKiServices{'StateOfX2GoCliWin'}{'DeskH'}; + + my $FullScreen = 0; + my $Visible = 0; + my ($ax,$ay) = $TeKiServices{'StateOfX2GoCliWin'}{'theWindow'}->get_origin; + my ($relx, $rely, $w, $h, undef) = $TeKiServices{'StateOfX2GoCliWin'}{'theWindow'}->get_geometry; + if ($TeKiServices{'StateOfX2GoCliWin'}{'ActiveWID'} eq $TeKiServices{'StateOfX2GoCliWin'}{'DecWid'}) { + $Visible = 1; + } + + if (($w >= $DeskW) and ($h >= $DeskH)) { + if (($relx == 0) and ($rely == 0)) {if (($ax == 0) and ($ay == 0)) { + $FullScreen = 1; + }} + } + + if ( + ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'FullScreen'} ne $FullScreen) or + ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'Visible'} ne $Visible) or + ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ax'} ne $ax) or + ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ay'} ne $ay) or + ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'h'} ne $h) or + ($TeKiServices{'StateOfX2GoCliWin'}{'data'}{'w'} ne $w) or + ($_[0] eq 1) + ) { + + $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'FullScreen'} = $FullScreen; + $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'Visible'} = $Visible; + $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ax'} = $ax; + $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'ay'} = $ay; + $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'h'} = $h; + $TeKiServices{'StateOfX2GoCliWin'}{'data'}{'w'} = $w; + my $SendString = "1|1|0|0|0|0"; + if ($FullScreen eq 1) { + # Default and assuming we're thin client mode in which case we should never get this far anyhow.... + } else { + $SendString = clups("0|$Visible|$ax|$ay|$h|$w"); + } + dbugPrint("StateOfX2GoCW: A:$TeKiServices{'StateOfX2GoCliWin'}{'ActiveWID'} U:$TeKiServices{'StateOfX2GoCliWin'}{'DecWid'} S:$SendString"); + foreach my $chanID (keys $TeKiServices{'StateOfX2GoCliWin'}{'clients'}) { + if ($CHANS{$chanID}{'sockclient'}) { + my $client = $CHANS{$chanID}{'sockclient'}; + sayToClient($client,"CORE|SERVICES|X2GOWINDOWSTATE|$SendString|"); + } + } + } + } + } # Insert cleanup routine at the end.... return 1; } @@ -542,10 +542,10 @@ sub runStateOfX2GoCliWin { ################################################################################################################################# ############################################################################################################################################ ################################################################################################################################# -# Wormhole Conection Stuff +# Wormhole Connection Stuff ################################################################################################################################# -# This sub, is the client side handeler of the wormhole connection +# This sub is the client side handler of the wormhole connection sub CShandleTheWormhole { my ( $fd, $condition, $fh ) = @_; if ( $condition >= 'in' ) { @@ -579,7 +579,7 @@ sub CShandleTheWormhole { } elsif ($saneData =~ /^VNEGS\|2\|ALL\|DONE\|.*$/) { if ($vSupApp{'agree'}{'self'}) { - print $TheWormhole "VNEGC|3|ALL|DONE|\n"; + print $TheWormhole "VNEGC|3|ALL|DONE|\n"; $sstatusi{'WormholeState'} = 3; } else { print $TheWormhole "ERRLOG|BROKEN_TELEKINESIS_PAIR|\n"; @@ -588,27 +588,27 @@ sub CShandleTheWormhole { } } - if ($saneData =~ /^CORE_CHAN\|INIT\|([a-z]{4,32})\_([a-zA-Z0-9]{3,32})\|$/) { - dbugPrint("Init clientside chan for APP: $1 ID: $2"); + if ($saneData =~ /^CORE_CHAN\|INIT\|([a-z]{4,32})\_([a-zA-Z0-9]{3,32})\|$/) { + dbugPrint("Init clientside chan for APP: $1 ID: $2"); initClientSideChan($1,$2); } if ($saneData =~ /^APP\|([a-zA-Z0-9]{3,32})\|([a-z]{4,32})\|([a-zA-Z0-9]{3,32})\|(.*)$/) { - my $chanID = "$2_$3"; + my $chanID = "$2_$3"; if ($CHANS{$chanID}{'sockclient'}) { my $chanSockCli = $CHANS{$chanID}{'sockclient'}; - if ($1 eq "APPCOM") { - print $chanSockCli "\nAPPCOM\|$4\n"; - } - } + if ($1 eq "APPCOM") { + print $chanSockCli "\nAPPCOM\|$4\n"; + } + } } elsif ($saneData =~ /^CORE_RTT_REPL\|(\d*)\.(\d*)\|$/) { my $elapsed = tv_interval( [$1,$2], [gettimeofday]);$elapsed =~ s/\,/\./g;$sstatusi{'lastRTT'} = $elapsed; } elsif ($saneData =~ /^CORE_TERMINATE\|(\w{1})\|.*/) { dbugPrint("The serverside Telekinesis wants us to terminate....($1)"); - doSelfTerminate(); - - } + doSelfTerminate(); + + } }} } else { @@ -621,9 +621,9 @@ sub CShandleTheWormhole { $fh->close; $fh = undef; dbugPrint("Server connection lost !!\nTrying to reconnect in a bit...\n"); - } + } } - + if ($fh) { return TRUE; } else { @@ -640,8 +640,8 @@ sub clientVNeg { # my $vCompDir = sanitizeDirPath($_[0]); my $vnSTEP = sanitizer("anumazlc",$_[0]); if ((defined $TheWormhole) and (-d $vCompDir)) { - if ($vnSTEP eq "step1") { - my @tmpWeGOT; + if ($vnSTEP eq "step1") { + my @tmpWeGOT; push @tmpWeGOT, "self"; opendir(VCD, "$vCompDir/apps/"); while(readdir(VCD)) { @@ -655,7 +655,7 @@ sub clientVNeg { foreach my $checkApp (@tmpWeGOT) { my ($vccName,$vccVersion) = versionCompCheck($vCompDir,0,$checkApp); if (($vccName eq $checkApp) and ($vccVersion =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) { - $vSupApp{'client'}{$vccName}{'version'} = $vccVersion; + $vSupApp{'client'}{$vccName}{'version'} = $vccVersion; print $TheWormhole "VNEGC|1|$vccName|$vccVersion|\n"; } } @@ -665,20 +665,20 @@ sub clientVNeg { } } -# Wormhole Conection Stuff +# Wormhole Connection Stuff ################################################################################################################################# ############################################################################################################################################ ################################################################################################################################# # This sub, supposedly try to do a clean termination of the Telekinesis session -sub doSelfTerminate { +sub doSelfTerminate { dbugPrint("Self Terminating............\n"); $runCSTATE = "CT"; # STOP STUFF.... cleanUpOldSession($X2GoTKCHome);# Then clean up after our self before we go.... (You don't want to leave this mess for your mom...) - Gtk2->main_quit; - return FALSE; -} + Gtk2->main_quit; + return FALSE; +} # And this should be the very end of everything!? ################################################################################################################################# ############################################################################################################################################ diff --git a/server/bin/tekicmd b/server/bin/tekicmd index ab59f31..4a4f9db 100644 --- a/server/bin/tekicmd +++ b/server/bin/tekicmd @@ -31,8 +31,8 @@ if (sanitizer("x2gosid",$CmdFlags{'X2GOSID'})) { $X2GoSID = sanitizer("x2gosid",$CmdFlags{'X2GOSID'}); } elsif (sanitizer("x2gosid",$ENV{'X2GO_SESSION'})) { $X2GoSID = sanitizer("x2gosid",$ENV{'X2GO_SESSION'}); -} else { - print "No X2Go Session ID in ENV or ARGV!\n"; +} else { + print "No X2Go Session ID in ENV or ARGV!\n"; exit; } @@ -51,11 +51,11 @@ if (lc(@ARGV[0]) =~ /-shell/) { } else { if ($CmdFlags{'SESSIONSUSPEND'}) { # print "SUSPEND\n"; - doLocalQuickie("CORE|SUSPEND"); + doLocalQuickie("CORE|SUSPEND"); } elsif ($CmdFlags{'SESSIONRESUME'}) { # print "RESUME\n"; doLocalQuickie("CORE|RESUME"); - } + } } @@ -66,17 +66,17 @@ if (lc(@ARGV[0]) =~ /-shell/) { sub cmdPrompt { print "\nTeKi# "; my $cmd = lc(<STDIN>);$cmd =~ s/[\n]//g; -# print " GOT: $cmd\n"; +# print " GOT: $cmd\n"; if ($cmd =~ /help/) { print "In interactive mode the 'tekicmd' tool is most usefull for debugging.\n", - "The following commands are available in this interactive shell:\n\n", - " help Your looking at the output of this command right now... duh!!!\n", - " quit/exit Terminates this tool. The Telekinesis instance is unaffected\n"; + "The following commands are available in this interactive shell:\n\n", + " help Shows this help message.\n", + " quit/exit Terminates this tool. The Telekinesis instance is unaffected\n"; } elsif ($cmd =~ /hello/) { print "Yes yes yes.... Hello to you too!\n"; } elsif ($cmd =~ /fuck/) { - print "Seriously!?!?! Profanities?! Like thats going to help....\n"; + print "Seriously!?!?! Profanities?! Like that's going to help....\n"; } else { print "'$cmd' does not seem to be a valid command....\nIf it wasnt a simple typo, you'd probably want to check out the 'help' command\nJust saying....\n"; } @@ -90,17 +90,17 @@ sub cmdPrompt { sub doLocalQuickie { my $stuffToSay = clups($_[0]); - if (-S $TeKiLSockPath) { - my $QuickSocket = IO::Socket::UNIX->new( Peer => $TeKiLSockPath, - Type => SOCK_STREAM, - Timeout => 10 ); - if (defined $QuickSocket){ + if (-S $TeKiLSockPath) { + my $QuickSocket = IO::Socket::UNIX->new( Peer => $TeKiLSockPath, + Type => SOCK_STREAM, + Timeout => 10 ); + if (defined $QuickSocket) { print $QuickSocket "\nQUICKIE|$stuffToSay|\n"; $QuickSocket->close; $QuickSocket = undef; } else { die("ERROR: Can't connect to local socket"); - } + } } else {return 0;} } diff --git a/server/bin/telekinesis-server b/server/bin/telekinesis-server index bfbd6dd..254afb2 100644 --- a/server/bin/telekinesis-server +++ b/server/bin/telekinesis-server @@ -26,19 +26,19 @@ # Copyright (C) 2013-2015 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> # ################################################################################################################# -#use warnings; -use strict; +#use warnings; +use strict; #use String::HexConvert ':all'; # Nothing using this? use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep clock_gettime clock_getres clock_nanosleep clock stat ); use Data::Dumper;# Not in use right this moment but will be very soon...! -use Glib qw/TRUE FALSE/; +use Glib qw/TRUE FALSE/; use File::Path qw(make_path remove_tree); use IO::Socket::UNIX qw( SOCK_STREAM SOMAXCONN ); use Gtk2; use X2Go::Telekinesis::CoreSupport qw( vCompChkWeNewest versionCompCheck premZealot getConnectToken getCmdFlags dbugPrint tcDie sanitizeDirPath sanitizeFilePath sanitizer checkPID genRandSID genRandToken clups);; my $TeKiSVersion = "0.0.6.2"; $ENV{'PATH'} = "/bin:/usr/bin"; -@SIG{qw( INT TERM HUP )} = \&doSelfTerminate; # +@SIG{qw( INT TERM HUP )} = \&doSelfTerminate; # my $runSTATE = "I";# The runState of telekinesis I=Initiating, R=Running, S=Suspended, T=Terminating. our %CmdFlags = getCmdFlags(@ARGV); # Get stuff from command line! ################################################################################################################################# @@ -52,7 +52,7 @@ my $X2GoSID = sanitizer("x2gosid",$ENV{'X2GO_SESSION'}); our $X2GoSesHome = sanitizeDirPath("$UserHome/.x2go/C-$X2GoSID"); our $X2GoTKSHome = "$X2GoSesHome/telekinesis"; dbugPrint("--------------------------------------------------------------------------------"); -# Just drawing a line, sepparating the old and the new.... Just to make the log a bit more human firendly... +# Just drawing a line, separating the old and the new.... Just to make the log a bit more human friendly... dbugPrint("STARTING Telekinesis SERVER\nX2Go SesID ENV: $X2GoSID\nX2GoTKSHome: $X2GoTKSHome"); ################################################################################################################################# # Attempt to load paths file.... @@ -63,7 +63,7 @@ if (-f "/etc/x2go/telekinesis/server/paths") { if (length(clups($pathLine)) > 0) { $pathLine =~ s/\n//g; if ($pathLine =~ /^\#/) { - #NOT GOING TO DO ANYTHING FOR COMMANDS ARE WE ??? NAH... + #NOT GOING TO DO ANYTHING FOR COMMANDS ARE WE ??? NAH... } elsif ($pathLine =~ /^([A-Z]{1})\:([0-9A-Z\_\-]{3,32})\=(.*)$/) { my $pName = $2; my $prePath = $3; @@ -71,7 +71,7 @@ if (-f "/etc/x2go/telekinesis/server/paths") { $prePath =~ s/[\s]*$//g; $prePath =~ s/\/$//g; my $cleanPath = sanitizeDirPath($prePath) or tcDie("Sanitation of '$pName' => '$prePath' failed during loading of paths file!"); - if (($cleanPath ne 0) and (-d $cleanPath)) { + if (($cleanPath ne 0) and (-d $cleanPath)) { $TeKiPaths{$pName} = $cleanPath; } } @@ -81,7 +81,7 @@ if (-f "/etc/x2go/telekinesis/server/paths") { close(PATHS); } else {tcDie("NO PATHS FILE!");} ################################################################################################################################# -# By now TeKiPaths should be loaded... Time to verify that all REQUIRED paths are there and contain what we expect... +# By now TeKiPaths should be loaded... Time to verify that all REQUIRED paths are there and contain what we expect... my $vCompDir = "$TeKiPaths{'SHARE'}/server/vcomp";# Where we put the files containing version compatibility stuff.. unless (-f "$vCompDir/self.vc") {tcDie("The 'vCompDir' did not seem to be where we expect it...");}# And if we cant even find out own declaration, something is wrong. @@ -94,63 +94,63 @@ unless (-f "$vCompDir/self.vc") {tcDie("The 'vCompDir' did not seem to be where } else {tcDie("Did not get a usefull port number input from command line!");} my $tksBindToADDR = "localhost";# For now we're going to stick with "localhost"... but we're not hardcoding it future down... - # to make it easyer to change if need be, in the future.... if changed to getting host from command line - # Use BINDTOADDR as flag and remeber putting some form of sanitation and checking here... + # to make it easier to change if need be, in the future.... if changed to getting host from command line + # Use BINDTOADDR as flag and remeber putting some form of sanitation and checking here... dbugPrint("Requests binding to port $tksBindToPORT on $tksBindToADDR"); ################################################################################################################################# # Over zealusly initiate the variable that holds the user name -my ($GPWUIDuserName,undef) = getpwuid( $< );# More reliable than $ENV{'USER'} etc... +my ($GPWUIDuserName,undef) = getpwuid( $< );# More reliable than $ENV{'USER'} etc... my $UserName = sanitizer("pnixusername",$GPWUIDuserName); if ($UserName eq 0) {tcDie("Is \"$UserName\" a valid portable UNIX username?\nNah.... Didn't think so....\nWe're done! BYE BYE!\n");} dbugPrint("Running as USER: $UserName\nWith HOME Dir: $UserHome"); ################################################################################################################################# ################################################################################################################################# -# Check for lock file existace and running processes.... at this time there should be none.... +# Check for lock file existence and running processes.... at this time there should be none.... if (-f "$X2GoTKSHome/lock") { # So if there is one... - open(OLF,"$X2GoTKSHome/lock");my ($OldPID,$OldStartTime,undef) = <OLF>;close(OLF);# Lets have a look inside... + open(OLF,"$X2GoTKSHome/lock");my ($OldPID,$OldStartTime,undef) = <OLF>;close(OLF);# Lets have a look inside... $OldPID = sanitizer("num",$OldPID);$OldStartTime =~ s/\D//g; - my ($psP,$psU,$psN,$psC) = checkPID($OldPID); # And check if the PID is still running + my ($psP,$psU,$psN,$psC) = checkPID($OldPID); # And check if the PID is still running #print "$OldPID,$psP,$psU,$psN,$psC\n"; - if (($psC =~ /telekinesis/) and ($psU eq $UserName)) { # And if it is running and OURS.... Is it telekinesis?!? - # Since we probably dont want to automagically murder a running session. We're going to just suggest a solution to the user.. - # Though nobody should be executing this manualy... + if (($psC =~ /telekinesis/) and ($psU eq $UserName)) { # And if it is running and OURS.... Is it telekinesis?!? + # Since we probably don't want to automagically murder a running session. We're going to just suggest a solution to the user.. + # Though nobody should be executing this manually... if ($CmdFlags{'FORCENEW'}) {# About time to start cleaning up if we are ordered to FORCE a new clean session dbugPrint("START FORCING NEW..."); kill("TERM",$OldPID);# Try to kill it in a friendly and polite manner.... sleep 2;# Give it some time to die... - my ($psP2,$psU2,$psN2,$psC2) = checkPID($OldPID);# Then Check if the pid still is running + my ($psP2,$psU2,$psN2,$psC2) = checkPID($OldPID);# Then check if the PID still is running if (($psC2 =~ /telekinesis/) and ($psU2 eq $UserName)) {# and if it is... - kill("KILL",$OldPID);# Try killing it in a more abrupt and brutal fassion... + kill("KILL",$OldPID);# Try killing it in a more abrupt and brutal fashion... sleep 3;# Give it some time to die... - my ($psP3,$psU3,$psN3,$psC3) = checkPID($OldPID);# Then Check again... if the pid still is running + my ($psP3,$psU3,$psN3,$psC3) = checkPID($OldPID);# Then check again... if the PID still is running if (($psC3 =~ /telekinesis/) and ($psU3 eq $UserName)) {# and if it is... - tcDie("We did try to kill the damn thing running as pid $OldPID, but it just wont die..."); + tcDie("We did try to kill the damn thing running as PID $OldPID, but it just won't die..."); } else { - cleanUpOldSession($X2GoTKSHome);# ok it dead now.... lets get on with the cleaning.... - } + cleanUpOldSession($X2GoTKSHome);# ok it's dead now.... let's get on with the cleaning.... + } } else { - cleanUpOldSession($X2GoTKSHome);# ok it dead now.... lets get on with the cleaning.... - } + cleanUpOldSession($X2GoTKSHome);# ok it's dead now.... let's get on with the cleaning.... + } } else { - my $runTime = (time() - $OldStartTime);# How long has it been running for? - tcDie("Looks like we've already been running as pid $OldPID for $runTime secods\nrun with the -setFORCENEW=1 to kill the old and force a new!"); + my $runTime = (time() - $OldStartTime);# How long has it been running for? + tcDie("Looks like we've already been running as PID $OldPID for $runTime seconds\nrun with the -setFORCENEW=1 to kill the old and force a new!"); } - } else {# If its not telekinesis... lets automaticaly clean up the old/dead session... + } else {# If its not telekinesis... let's automatically clean up the old/dead session... cleanUpOldSession($X2GoTKSHome); } } else { - if (-d "$X2GoTKSHome") {cleanUpOldSession($X2GoTKSHome);}# Just in case there were no lock file but the directory still existed... + if (-d "$X2GoTKSHome") {cleanUpOldSession($X2GoTKSHome);}# Just in case there were no lock files but the directory still existed... } -if (-d "$X2GoTKSHome") { # This really should not be happeining! - tcDie("After countless cleanup attempts... things are still a mess... so we're giving up..."); +if (-d "$X2GoTKSHome") { # This really should not be happining! + tcDie("After countless cleanup attempts... things are still a mess... so we're giving up..."); } else { # By now we should be ready to prep for the startup of a new session! - doPrepForNewSESSION($X2GoTKSHome,$X2GoSID); + doPrepForNewSESSION($X2GoTKSHome,$X2GoSID); } ################################################################################################################################# @@ -166,19 +166,19 @@ my $TheWormhole; my $currentLocalToken = genRandToken('local',$X2GoTKSHome);# NOT IN USE ANYMORE? my $currentReMToken = genRandToken('remote',$X2GoTKSHome); ################################################################################################################################# -# Initiate the SERVER -if (-f "$X2GoTKSHome/lock") {# By this time we should be able to find a lock file again... +# Initiate the SERVER +if (-f "$X2GoTKSHome/lock") {# By this time we should be able to find a lock file again... $LocalSocket = IO::Socket::UNIX->new(Local => "$X2GoTKSHome/local/sock", Type => SOCK_STREAM, Reuse => 1, Timeout => 5, Listen => SOMAXCONN );# Start the socket that will be dealing with local applications... - if (defined $LocalSocket){ - premZealot("$X2GoTKSHome/local/sock");# Set the propper premissions on the socket! + if (defined $LocalSocket) { + premZealot("$X2GoTKSHome/local/sock");# Set the proper permissions on the socket! dbugPrint("Local master SOCKET open on $X2GoTKSHome/local/sock"); $TnW{'localSocketWatcher'} = Glib::IO->add_watch ( fileno($LocalSocket), 'in', \&initLocalSocketCon, $LocalSocket);# Hand it over to a watcher... } else { tcDie("Unable to start local master socket!"); } - $sstatusi{'prevRunSTATE'} = $runSTATE;# THIS IS THE ONLY PLACE WE EVER SET 'prevRunSTATE' MANUALY!!!!! + $sstatusi{'prevRunSTATE'} = $runSTATE;# THIS IS THE ONLY PLACE WE EVER SET 'prevRunSTATE' MANUALLY!!!!! changeInternalStates("R","X"); } else {tcDie("WTF?");}# Yeah seriously!!! WTF!!! @@ -186,15 +186,15 @@ if (-f "$X2GoTKSHome/lock") {# By this time we should be able to find a lock fil ##################################### ##################################### ##################################### ##################################### -# The Main Gtk2 event loop +# The Main Gtk2 event loop Gtk2->init; &coreRunSTATEchanges; -Gtk2->main; +Gtk2->main; -# The Main Gtk2 event loop -##################################### ##################################### ##################################### ##################################### +# The Main Gtk2 event loop +##################################### ##################################### ##################################### ##################################### dbugPrint("Execution came to a natural end..."); # Once we get past the Main Gtk2 event loop... we're shutting down! # Nothing but SUBS past this point.... @@ -207,24 +207,24 @@ dbugPrint("Execution came to a natural end..."); # Once we get past the Main Gtk # This SUB do initiation of local socet connections sub initLocalSocketCon { my ( $fd, $condition, $fh ) = @_; - dbugPrint("LocalSocketCon start $fd, $condition, $fh"); + dbugPrint("LocalSocketCon start $fd, $condition, $fh"); my $client = $LocalSocket->accept() or dbugPrint("Can't accept connection @_"); $client->autoflush(1); my $bytes = sysread($client,my $data,4096); my $saneData = sanitizer("anumazcsdausdotspipe","$data"); # dbugPrint("SD:$saneData:sd"); if ($saneData =~ /^QUICKIE\|(.*)$/) { - dbugPrint("Handing over to quickie handler..."); + dbugPrint("Handing over to quickie handler..."); quickieHandler($1); } elsif ($saneData =~ /^APP\|INIT\|([a-z]{4,32})\|([a-zA-Z0-9]{3,32})\|/) { - + if ($vSupApp{'agree'}{$1}) { my $chanID = "$1\_$2"; dbugPrint("Channel ID: $chanID"); - dbugPrint("Handing over to appinit handler..."); + dbugPrint("Handing over to appinit handler..."); if ($CHANS{$chanID}{'initTime'}) { removeChannel($chanID); - } + } unless ($CHANS{$chanID}{'initTime'}) { $CHANS{$chanID}{'initTime'} = time(); $CHANS{$chanID}{'sockclient'} = $client; @@ -241,7 +241,7 @@ sub initLocalSocketCon { if ($vSupApp{'client'}{$1}) { dbugPrint("Incompatible $1 version on the client"); print $client "TERMINATE|NO_PAIR1|\n"; - } else { + } else { if ($sstatusi{'WormholeState'} < 3) { dbugPrint("Client not connected or incomplete version negotaitions"); print $client "RETRYLATER|NO_PAIR|\n"; @@ -256,14 +256,14 @@ sub initLocalSocketCon { } else { print $client "BYE!\n"; $client->close;$client = undef; - } + } return 1; } sub handleServersideAppConnection { my ( $fd, $condition, $client ) = @_; - dbugPrint("Handling AppCon: $fd, $condition, $client"); - + dbugPrint("Handling AppCon: $fd, $condition, $client"); + if ( $condition >= 'hup' or $condition >= 'err' ) { $client->close; $client = undef; @@ -277,23 +277,23 @@ sub handleServersideAppConnection { foreach my $dataLine (split(/\n/,$data)) {if (length(clups($dataLine)) > 0) { # Do something smarter in the future my $saneData = sanitizer("anumazcsdausdotspipe","$dataLine"); - if ($saneData =~ /^APP\|([A-Z]{2,32})\|([a-z]{4,32})\|([a-zA-Z0-9]{3,32})\|(.*)$/) { - - my $chanID = "$2_$3"; -# print "IN_FROM_C: $chanID\n"; - if ($CHANS{$chanID}{'sockclient'}) { - my $chanSockCli = $CHANS{$chanID}{'sockclient'}; - dbugPrint("C:1$chanSockCli C2:$client"); - if ($1 eq "INITC") { -# print $chanSockCli "\nAPP\|INITC\|\n"; - } elsif ($1 eq "RESUME") { - throughWormhole("\nCORE_CHAN|INIT|$chanID|\n"); - } elsif ($1 eq "APPCOM") { -# print "ToWH:APP|APPCOM|$2|$3|$4\n"; - throughWormhole("\nAPP|APPCOM|$2|$3|$4\n"); - } - } - + if ($saneData =~ /^APP\|([A-Z]{2,32})\|([a-z]{4,32})\|([a-zA-Z0-9]{3,32})\|(.*)$/) { + + my $chanID = "$2_$3"; +# print "IN_FROM_C: $chanID\n"; + if ($CHANS{$chanID}{'sockclient'}) { + my $chanSockCli = $CHANS{$chanID}{'sockclient'}; + dbugPrint("C:1$chanSockCli C2:$client"); + if ($1 eq "INITC") { +# print $chanSockCli "\nAPP\|INITC\|\n"; + } elsif ($1 eq "RESUME") { + throughWormhole("\nCORE_CHAN|INIT|$chanID|\n"); + } elsif ($1 eq "APPCOM") { +# print "ToWH:APP|APPCOM|$2|$3|$4\n"; + throughWormhole("\nAPP|APPCOM|$2|$3|$4\n"); + } + } + } # print $client "$data\n"; # REMOVE THIS ? @@ -308,29 +308,29 @@ sub handleServersideAppConnection { } ################################################################################################################################# -# quickie handler... -# Make this more GENERIC in the FUTURE... but still enforce strict sanitation... -# So anything more GENERIC still needs to fit into some strich formating scheeme. +# quickie handler... +# Make this more GENERIC in the FUTURE... but still enforce strict sanitation... +# So anything more GENERIC still needs to fit into some strict formating scheme. # For now we're just handling mTP MEDIA loading into existing mTP instances... -# Could we use some other aproach for this file loading stuff... SHURE.... But this aims to be kind of a "function demo". -# Pleace forward endless debates and objection to: blackhole@gznianguan.com or boucebox@gznianguan.com +# Could we use some other approach for this file loading stuff... SURE.... But this aims to be kind of a "function demo". +# Please forward endless debates and objection to: blackhole@gznianguan.com or boucebox@gznianguan.com sub quickieHandler { if ($_[0] =~ /^([a-z]{4,32})\|([a-zA-Z0-9]{3,32})\|(.*)\|/) { my $chanID = "$1_$2"; dbugPrint("QUICKIE: 1:$1 2:$2 3:$3"); -# YES Shure... THIS COULD SHOULD AND WILL BE GENERALIZED but as for now.... Its here.. and stays here... +# YES Sure... THIS COULD SHOULD AND WILL BE GENERALIZED but as for now.... It's here.. and stays here... if ($CHANS{$chanID}{'sockclient'}) { my $chanSockCli = $CHANS{$chanID}{'sockclient'}; if ($3 =~ /^ENQUEUEDMEDIA\|([a-zA-Z0-9]{3,32})\|([a-zA-Z0-9]{3,32})\|/) { print $chanSockCli "\nENQUEUEDMEDIA\|$1\|$2\|\n"; } elsif ($3 =~ /^PLAYMEDIA\|([a-zA-Z0-9]{3,32})\|([a-zA-Z0-9]{3,32})\|/) { print $chanSockCli "\nPLAYMEDIA\|$1\|$2\|\n"; - } + } } } elsif ($_[0] =~ /CORE\|(.*)/) { if (($1 =~ /^(SUSPEND)\|/) or ($1 =~ /^(RESUME)\|/)) { - if ($1 eq "RESUME") {changeInternalStates("R","X");} - elsif ($1 eq "SUSPEND") {changeInternalStates("S","X");} + if ($1 eq "RESUME") {changeInternalStates("R","X");} + elsif ($1 eq "SUSPEND") {changeInternalStates("S","X");} elsif ($1 eq "TERMINATE") {changeInternalStates("T","X");} # NOT YET IMPLEMENTED FULLY (does it need to be?) &coreRunSTATEchanges; dbugPrint("SUSPEND/RESUME GOT TO STEP2: $1"); @@ -340,7 +340,7 @@ sub quickieHandler { } ################################################################################################################################# -# A couple channel managment subs: +# A couple channel management subs: sub changeInternalStates { my $INrunState = uc($_[0]); my $INWHS = $_[1]; @@ -387,7 +387,7 @@ sub sayToAllChan { sub removeChannel { my $rmChID = $_[0];# should by this point be sanitized already... if ($CHANS{$rmChID}{'initTime'}) { - Glib::Source->remove ($CHANS{$rmChID}{'iowatcher'}) or dbugPrint("Problems while removing WATCHER on existing channel: \"$rmChID\"...\nProbably not a big deal anyway... since it means its already removed."); + Glib::Source->remove ($CHANS{$rmChID}{'iowatcher'}) or dbugPrint("Problems while removing WATCHER on existing channel: \"$rmChID\"...\nProbably not a big deal anyway... since it means it's already removed."); # print "Before:\n",Dumper($CHANS{$rmChID}),"\n\n"; if ($CHANS{$rmChID}{'sockclient'}) { my $client = $CHANS{$rmChID}{'sockclient'}; @@ -398,7 +398,7 @@ sub removeChannel { $CHANS{$rmChID} = undef; # print "After:\n",Dumper($CHANS{$rmChID}),"\n----------------------------------\n\n"; - } + } } sub sayToClient { @@ -419,10 +419,10 @@ sub throughWormhole { } ################################################################################################################################# -# This SUB do various prepparations as part of session initiation and other changes to runSTATE +# This SUB do various preparations as part of session initiation and other changes to runSTATE sub coreRunSTATEchanges { #print "coreRunSTATE SUB\n"; - if ($sstatusi{'prevRunSTATE'} ne $runSTATE) { + if ($sstatusi{'prevRunSTATE'} ne $runSTATE) { dbugPrint("Run STATE changed from $sstatusi{'prevRunSTATE'} to $runSTATE!"); if ($runSTATE eq "R") { if (($sstatusi{'masterSOCKup'} eq 0) and ( ! defined $theWormholeSocket)) { @@ -440,7 +440,7 @@ sub coreRunSTATEchanges { if (defined $theWormholeSocket){ $sstatusi{'masterSOCKup'} = 1; $TnW{'WormholeSocketWatcher'} = Glib::IO->add_watch ( fileno($theWormholeSocket), 'in', \&initWormhole, $theWormholeSocket); - dbugPrint("Master SOCKET open on $tksBindToADDR:$tksBindToPORT"); + dbugPrint("Master SOCKET open on $tksBindToADDR:$tksBindToPORT"); } else { $sstatusi{'masterSOCKup'} = 0; tcDie("Unable to start master socket!"); @@ -475,19 +475,19 @@ sub coreRunSTATEchanges { return 1; } ################################################################################################################################# -# This SUB deals with the initial phase of a incomming master connection +# This SUB deals with the initial phase of a incomming master connection sub initWormhole { dbugPrint("INIT WORMHOLE"); my ( $fd, $condition, $fh ) = @_; my $initState = 0; - dbugPrint("Wormhole callback start $fd, $condition, $fh"); - my $client = $theWormholeSocket->accept() or dbugPrint("Can't accept connection @_"); + dbugPrint("Wormhole callback start $fd, $condition, $fh"); + my $client = $theWormholeSocket->accept() or dbugPrint("Can't accept connection @_"); $client->autoflush(1); my $bytes = sysread($client,my $data,256); my $saneData = sanitizer("anumazcsdausdotspipe","$data"); -# dbugPrint("SD:$saneData:sd"); +# dbugPrint("SD:$saneData:sd"); if (($runSTATE eq "R") and ($saneData =~ /^IDC\|([a-zA-Z0-9]{60,260})\|.*$/)) { - dbugPrint("IDC:$1:IDC\nTOK:$currentReMToken:TOK"); + dbugPrint("IDC:$1:IDC\nTOK:$currentReMToken:TOK"); if ($currentReMToken eq $1) { $currentReMToken = genRandToken('remote',$X2GoTKSHome);# Hurry Change the Token! dbugPrint("Wormhole connection GRANTED!\nToken: $1"); @@ -496,12 +496,12 @@ sub initWormhole { Glib::Source->remove($TnW{'theWormholeWatcher'}) or dbugPrint("Problems while removing the Wormhole WATCHER!\n(It should have been removed already, anyway so no worries..)"); } $TheWormhole = $client; -# $sstatusi{'WormholeState'} = 1; - changeInternalStates("X",1); +# $sstatusi{'WormholeState'} = 1; + changeInternalStates("X",1); undef %vSupApp; $TnW{'theWormholeWatcher'} = Glib::IO->add_watch ( fileno( $TheWormhole ),['in', 'hup', 'err'], \&handleTheWormhole, $TheWormhole ); throughWormhole("GREETINGS"); - serverVNeg("STEP1"); + serverVNeg("STEP1"); $initState = 1; } else { $initState = 0; @@ -509,7 +509,7 @@ sub initWormhole { dbugPrint("Wrong Token: $1\nChanged to: $currentReMToken"); } } else { - dbugPrint("Incomming connetction did not look like a valid wormhole connection... so we dropped it..."); + dbugPrint("Incoming connetction did not look like a valid wormhole connection... so we dropped it..."); } unless ($initState eq 1) {$client->close;$client = undef;}# if the init state was not 1.... clean up this client and get rid of it. @@ -520,12 +520,12 @@ sub handleTheWormhole { my ( $fd, $condition, $client ) = @_; if ( $condition >= 'hup' or $condition >= 'err' ) { dbugPrint("Wormhole connection LOST!\nCleaning up the mess..."); - $client->close;$client = undef; + $client->close;$client = undef; # $sstatusi{'WormholeState'} = 0; changeInternalStates("X",0); undef %vSupApp; if (defined $TnW{'theWormholeWatcher'}) { - Glib::Source->remove($TnW{'theWormholeWatcher'}) or dbugPrint("Problems while removing the Wormhole WATCHER2!"); + Glib::Source->remove($TnW{'theWormholeWatcher'}) or dbugPrint("Problems while removing the Wormhole WATCHER2!"); } return 0; @@ -556,25 +556,25 @@ sub handleTheWormhole { } else { throughWormhole("ERRLOG|BROKEN_TELEKINESIS_PAIR|"); # ADD SOMETHING TO CLOSE THE CONNECTION HERE! - } + } } } elsif ($sstatusi{'WormholeState'} eq 3) { # if ($saneData =~ /^APP/) {print " APP:$saneData:APP\n";} if ($saneData =~ /^APP\|([a-zA-Z0-9]{3,32})\|([a-z]{4,32})\|([a-zA-Z0-9]{3,32})\|(.*)$/) { - my $chanID = "$2_$3"; - if ($CHANS{$chanID}{'sockclient'}) { - my $chanSockCli = $CHANS{$chanID}{'sockclient'}; - - if ($1 eq "INITC") { - print $chanSockCli "\nAPP\|INITC\|\n"; - } elsif ($1 eq "APPCOM") { - print $chanSockCli "\nAPPCOM\|$4\n"; - } - } - + my $chanID = "$2_$3"; + if ($CHANS{$chanID}{'sockclient'}) { + my $chanSockCli = $CHANS{$chanID}{'sockclient'}; + + if ($1 eq "INITC") { + print $chanSockCli "\nAPP\|INITC\|\n"; + } elsif ($1 eq "APPCOM") { + print $chanSockCli "\nAPPCOM\|$4\n"; + } + } + } elsif ($saneData =~ /^CORE_RTT_INIT\|(.*)\|(.*)\|$/) { - print $client "\nCORE_RTT_REPL\|$1\|\n"; + print $client "\nCORE_RTT_REPL\|$1\|\n"; $sstatusi{'lastRTT'} = $2; # print "RTT:$2\n"; } elsif ($saneData =~ /^TERMINATE$/) { @@ -584,14 +584,14 @@ sub handleTheWormhole { }} return 1; } else { - $client->close;$client = undef; + $client->close;$client = undef; changeInternalStates("X",0); undef %vSupApp; return 0; } } else {return 1;} } else { - $client->close;$client = undef; + $client->close;$client = undef; changeInternalStates("X",0); undef %vSupApp; return 0; @@ -604,8 +604,8 @@ sub handleTheWormhole { sub serverVNeg { my $vnSTEP = sanitizer("anumazlc",$_[0]); if ((defined $TheWormhole) and (-d $vCompDir)) { - if ($vnSTEP eq "step1") { - my @tmpWeGOT; + if ($vnSTEP eq "step1") { + my @tmpWeGOT; push @tmpWeGOT, "self"; opendir(VCD, "$vCompDir/apps/"); while(readdir(VCD)) { @@ -619,7 +619,7 @@ sub serverVNeg { foreach my $checkApp (@tmpWeGOT) { my ($vccName,$vccVersion) = versionCompCheck($vCompDir,0,$checkApp); if (($vccName eq $checkApp) and ($vccVersion =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) { - $vSupApp{'server'}{$vccName}{'version'} = $vccVersion; + $vSupApp{'server'}{$vccName}{'version'} = $vccVersion; throughWormhole("VNEGS|1|$vccName|$vccVersion||"); } } @@ -628,29 +628,29 @@ sub serverVNeg { } elsif ($vnSTEP eq "step2") { foreach my $key (keys ($vSupApp{'server'})) { if ($vSupApp{'client'}{$key}) { - my $WhoIsNewest = vCompChkWeNewest($vSupApp{'server'}{$key}{'version'},$vSupApp{'client'}{$key}{'version'}); + my $WhoIsNewest = vCompChkWeNewest($vSupApp{'server'}{$key}{'version'},$vSupApp{'client'}{$key}{'version'}); if ($WhoIsNewest eq "U") { if (versionCompCheck($vCompDir,1,$key,$vSupApp{'client'}{$key}{'version'})) { dbugPrint("$key is OK version!!"); $vSupApp{'agree'}{$key} = 1; throughWormhole("VNEGS|2|AOK|$key|"); } else { - dbugPrint("$key $vSupApp{'server'}{$key}{'version'} will not work with $vSupApp{'client'}{$key}{'version'}!!"); + dbugPrint("$key $vSupApp{'server'}{$key}{'version'} will not work with $vSupApp{'client'}{$key}{'version'}!!"); } } else { - dbugPrint("We got older $key version that the client... need to ask the client..."); + dbugPrint("We got older $key version that the client... need to ask the client..."); $vSupApp{'tmpwfc'}{$key} = 1; throughWormhole("VNEGS|2|UTM|$key|"); } - } - } + } + } throughWormhole("VNEGS|2|ALL|DONE|"); } } } ################################################################################################################################# -# This SUB do various prepparations as part of session initiation. +# This SUB do various preparations as part of session initiation. sub doPrepForNewSESSION { dbugPrint("Start SESSION prepping...."); my $X2GoTKSHome = $_[0]; @@ -679,7 +679,7 @@ sub cleanUpOldSession { dbugPrint("Start cleaning old session junk...\nCleaning up $X2GoTKSHome..."); if (-d "$X2GoTKSHome") { remove_tree("$X2GoTKSHome") or tcDie("Can't remove the \"$X2GoTKSHome\" dir!\ There is probably still some junk left in it?!"); - } + } dbugPrint("DONE cleaning old session junk!"); } @@ -688,8 +688,8 @@ sub cleanUpOldSession { ################################################################################################################################# -# This sub, supposedly try to do a clean termination of the Telekinesis session -sub doSelfTerminate { +# This sub supposedly try to do a clean termination of the Telekinesis session +sub doSelfTerminate { dbugPrint("Self Terminating............\n"); $runSTATE = "T"; # sleep 1; @@ -706,11 +706,11 @@ sub doSelfTerminate { } $theWormholeSocket->close; $theWormholeSocket = undef; - } + } cleanUpOldSession($X2GoTKSHome);# Then clean up after our self before we go.... (You don't want to leave this mess for your mom...) - Gtk2->main_quit; - return FALSE; -} + Gtk2->main_quit; + return FALSE; +} # And this should be the very end of everything!? ################################################################################################################################# ############################################################################################################################################ -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/telekinesis.git