[X2Go-Commits] [x2goserver] 01/01: Safely remove desktop files for client-side shared folders. Remove the correct desktop file, even if the shared folder has already been (forcefully) umounted. Such situations occur in cases where the connection gets interrupted. SSHFS will then get removed by the Linux kernel and we have to "guess" what desktop icons is actually to be removed.

git-admin at x2go.org git-admin at x2go.org
Fri Feb 28 16:13:14 CET 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goserver.

commit 0586f9be0d1aa51bb924117e182c393a8a0d5b1a
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Fri Feb 28 16:08:30 2014 +0100

    Safely remove desktop files for client-side shared folders. Remove the correct desktop file, even if the shared folder has already been (forcefully) umounted. Such situations occur in cases where the connection gets interrupted. SSHFS will then get removed by the Linux kernel and we have to "guess" what desktop icons is actually to be removed.
    
    Conflicts (resolved by Mike Gabriel):
    	x2goserver/bin/x2goumount-session
---
 debian/changelog                  |    6 +++
 x2goserver/bin/x2goumount-session |   96 +++++++++++++++++++++----------------
 2 files changed, 60 insertions(+), 42 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9f62f6c..2dd7b47 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -106,6 +106,12 @@ x2goserver (4.0.1.14-0x2go1) UNRELEASED; urgency=low
       the env var $X2GO_SESSION (current session) will be used.
     - Fix x2gostartagent. Make sure the -nolisten tcp option is configurable
       via x2goagent.options. (Fixes: #424).
+    - Safely remove desktop files for client-side shared folders. Remove
+      the correct desktop file, even if the shared folder has already
+      been (forcefully) umounted. Such situations occur in cases where
+      the connection gets interrupted. SSHFS will then get removed by the
+      Linux kernel and we have to "guess" what desktop icons is actually
+      to be removed.
   * x2goserver.spec:
     - Let builds for EPEL-7 behave like recent Fedora builds.
 
diff --git a/x2goserver/bin/x2goumount-session b/x2goserver/bin/x2goumount-session
index d3e30b8..e7f3acb 100755
--- a/x2goserver/bin/x2goumount-session
+++ b/x2goserver/bin/x2goumount-session
@@ -23,7 +23,8 @@
 use strict;
 use Sys::Hostname;
 use Sys::Syslog qw( :standard :macros );
-use File::BaseDir qw(xdg_config_home);
+use File::BaseDir qw( xdg_config_home );
+use File::Basename;
 
 use X2Go::Utils qw(source_environment);
 use X2Go::Server::DB qw(db_getdisplay db_getmounts db_deletemount);
@@ -141,7 +142,6 @@ break:
 		if (system("fusermount", "-u", "\"@line[1]\"") == 0)
 		{
 			syslog('notice', "successfully unmounted \"@line[1]\"");
-			$found=0;
 		}
 		else
 		{
@@ -157,9 +157,11 @@ break:
 			}
 		}
 	}
-	if (! $found)
-	{
 
+	if (!$found) {
+		syslog('info', "SSHFS share already unmounted, taking care of further clean-up (".basename(@line[1]).")");
+		$remote = basename(@line[1]);
+	} else {
 		$remote=~s/\/cygdrive\///;
 		$remote=~s/\/windrive\///;
 		$remote=~s/\/uncpath\///;
@@ -167,55 +169,65 @@ break:
 		$remote=~s/ /_/g;
 		$remote=~s/\\040/_/g;
 		$remote=(split(":","$remote"))[1];
-		my $desktopdir;
-		if ( $ENV{'XDG_DESKTOP_DIR'} )
-		{
-			$desktopdir="$ENV{'XDG_DESKTOP_DIR'}";
-		} else {
-			$desktopdir="$ENV{'HOME'}/Desktop";
-		}
-		$remote="$desktopdir/$remote";
+	}
+	my $desktop_dir;
+	if ( $ENV{'XDG_DESKTOP_DIR'} )
+	{
+		$desktop_dir="$ENV{'XDG_DESKTOP_DIR'}";
+	} else {
+		$desktop_dir="$ENV{'HOME'}/Desktop";
+	}
 
-		my $current_desktop = 'NONE';
-		if (($session =~ m/_stDGNOME_dp/) && system_capture_merged_output("x2gofeature", "X2GO_GNOMEBINDINGS") == 0)
-		{
-			$current_desktop="-gnome";
-		}
-		elsif (($session =~ m/_stDMATE_dp/) && system_capture_merged_output("x2gofeature", "X2GO_MATEBINDINGS") == 0)
+	my $current_desktop = 'NONE';
+	if (($session =~ m/_stDGNOME_dp/) && system_capture_merged_output("x2gofeature", "X2GO_GNOMEBINDINGS") == 0)
+	{
+		$current_desktop="-gnome";
+	}
+	elsif (($session =~ m/_stDMATE_dp/) && system_capture_merged_output("x2gofeature", "X2GO_MATEBINDINGS") == 0)
+	{
+		$current_desktop="-mate";
+	}
+	elsif (($session =~ m/_stDLXDE_dp/) && system_capture_merged_output("x2gofeature", "X2GO_LXDEBINDINGS") == 0)
+	{
+		$current_desktop="-lxde";
+	}
+	elsif (($session =~ m/_st.*_dp/) && system_capture_merged_output("x2gofeature", "X2GO_FMBINDINGS") == 0)
+	{
+		$current_desktop="";
+	}
+
+	if ("$current_desktop" ne "NONE")
+	{
+		my $desktop_file;
+		if ( -f "$desktop_dir/$remote\ (sshfs-disk$current_desktop)")
 		{
-			$current_desktop="-mate";
+			$desktop_file = "$remote\ (sshfs-disk$current_desktop)";
 		}
-		elsif (($session =~ m/_stDLXDE_dp/) && system_capture_merged_output("x2gofeature", "X2GO_LXDEBINDINGS") == 0)
+		$remote=~s/%2framdrive%2fmnt%2f//;
+		if ( -f "$desktop_dir/$remote\ (sshfs-removable$current_desktop)")
 		{
-			$current_desktop="-lxde";
+			$desktop_file = "$remote\ (sshfs-removable$current_desktop)";
 		}
-		elsif (($session =~ m/_st.*_dp/) && system_capture_merged_output("x2gofeature", "X2GO_FMBINDINGS") == 0)
+		if ( -f "$desktop_dir/$remote\ (sshfs-cdrom/$current_desktop)")
 		{
-			$current_desktop="";
+			$desktop_file = "$remote\ (sshfs-cdrom$current_desktop)";
 		}
 
-		if ("$current_desktop" ne "NONE")
-		{
-			if ( -e "$remote\ (sshfs-disk$current_desktop)")
-			{
-				syslog('info', "removing desktop icon ,,$remote (sshfs-disk$current_desktop)''");
-				unlink("$remote\ (sshfs-disk$current_desktop)");
-			}
-			$remote=~s/%2framdrive%2fmnt%2f//;
-			if ( -e "$remote\ (sshfs-removable$current_desktop)")
-			{
-				syslog('info', "removing desktop icon ,,$remote\ (sshfs-removable$current_desktop)''");
-				unlink("$remote\ (sshfs-removable$current_desktop)");
-			}
-			if ( -e "$remote\ (sshfs-cdrom/$current_desktop)")
-			{
-				syslog('info', "removing desktop icon ,,$remote\ (sshfs-cdrom$current_desktop)''");
-				unlink("$remote\ (sshfs-cdrom$current_desktop)");
+		syslog('info', "Attempting removal of desktop file ,,$desktop_dir/$desktop_file''");
+		if ( -f "$desktop_dir/$desktop_file" ) {
+			open (DF,"<$desktop_dir/$desktop_file") or die "Can't open $desktop_file for reading";
+			my @desktop_file_content=<DF>;
+			close(DF);
+
+			if ( @desktop_file_content[1] == $session ) {
+				syslog('info', "removing desktop icon ,,$desktop_dir/$desktop_file''");
+				unlink("$desktop_dir/$desktop_file");
 			}
 		}
-		db_deletemount ($session, @line[1]);
-		rmdir (@line[1]);
+
 	}
+	db_deletemount ($session, @line[1]);
+	rmdir (@line[1]);
 cont:
 }
 

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



More information about the x2go-commits mailing list