[X2Go-Commits] [x2gothinclient] 02/06: usbmount/x2gousbmount: make user pseudo-selectible via a variable and fix usage across file.

git-admin at x2go.org git-admin at x2go.org
Tue Apr 25 22:44:19 CEST 2017


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

x2go pushed a commit to branch master
in repository x2gothinclient.

commit 3ade983456add8596fb3a1a679f9530bacf48c80
Author: Stefan Baur <X2Go-ML-1 at baur-itcs.de>
Date:   Tue Apr 25 22:27:59 2017 +0200

    usbmount/x2gousbmount: make user pseudo-selectible via a variable and fix usage across file.
---
 debian/changelog      |  2 ++
 usbmount/x2gousbmount | 25 +++++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 598574d..573e2df 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -83,6 +83,8 @@ x2gothinclient (1.5.0.0-0x2go1) UNRELEASED; urgency=low
   [ Stefan Baur ]
   * New upstream release (1.5.0.0):
     - Allow Xinerama / XRandR setup via /proc/cmdline. (Closes: #726).
+  * usbmount/x2gousbmount:
+    - Make user pseudo-selectible via a variable and fix usage across file.
 
   [ Mark Pedersen-Cook ]
   * debian/po:
diff --git a/usbmount/x2gousbmount b/usbmount/x2gousbmount
index 4da1fbd..be0e7b2 100755
--- a/usbmount/x2gousbmount
+++ b/usbmount/x2gousbmount
@@ -22,6 +22,13 @@ use strict;
 use File::Path::Expand;
 use Sys::Syslog qw( :standard :macros );
 
+my $user;
+if ( -d "/lib/live/config" ) {
+	$user='user';
+} else {
+	$user='x2gothinclient';
+}
+
 openlog($0,'cons,pid','user');
 setlogmask( LOG_UPTO(LOG_NOTICE) );
 
@@ -45,9 +52,11 @@ if ( check_x2gothinclientd() ||  ( -d "/usr/share/doc/x2gothinclient-minidesktop
 	my $action=$ENV{'ACTION'};
 	my @ldev=split("/","$dev");
 	my $ldev=@ldev[@ldev-1];
+	# mntdir is not the directory where the mountpoint will be rooted,
+	# but where tracking of mount states takes place
 	my $mntdir;
-	if ( -d expand_filename("~/mounts")) {
-		$mntdir=expand_filename("~/mounts");
+	if ( -d expand_filename("~$user/mounts")) {
+		$mntdir=expand_filename("~$user/mounts");
 	} elsif ( -d "/var/run" ) {
 		$mntdir="/var/run";
 	} elsif ( -d "/run" ) {
@@ -80,12 +89,12 @@ if ( check_x2gothinclientd() ||  ( -d "/usr/share/doc/x2gothinclient-minidesktop
 		mkdir("/media/$name/$ldev");
 
 		# mount the USB device
-		if(system("mount $dev /media/$name/$ldev -o uid=x2gothinclient,sync,uni_xlate")==0)
+		if(system("mount $dev /media/$name/$ldev -o uid=$user,sync,uni_xlate")==0)
 		{
 			syslog('notice', "USB device $name ($ldev) successfully mounted");
 			# if mounted, inform x2goclient about it...
 			system("touch $mntdir/$ldev.mounted");
-			open (D,">",expand_filename("~x2gothinclient/export/$name.$ldev"));
+			open (D,">",expand_filename("~$user/export/$name.$ldev"));
 			print D "export=/media/$name/$ldev\n";
 			close (D);
 		}
@@ -103,8 +112,8 @@ if ( check_x2gothinclientd() ||  ( -d "/usr/share/doc/x2gothinclient-minidesktop
 				{
 					# inform x2goclient about this...
 					system("touch $mntdir/$ldev.encrypted");
-					system("chown -R x2gothinclient /media/$name/$ldev/dsa.key");
-					open (D,">",expand_filename("~/x2gothinclient/logins/$name.$ldev"));
+					system("chown -R $user /media/$name/$ldev/dsa.key");
+					open (D,">",expand_filename("~$user/logins/$name.$ldev"));
 					print D "login=/media/$name/$ldev\n";
 					close (D);
 				}
@@ -135,7 +144,7 @@ if ( check_x2gothinclientd() ||  ( -d "/usr/share/doc/x2gothinclient-minidesktop
 			# inform x2goclient that the device has been removed
 			system ("umount -ff /media/$name/$ldev");
 			unlink ("$mntdir/$ldev.mounted");
-			open ( D,">",expand_filename("~x2gothinclient/export/$name.$ldev.unexport"));
+			open ( D,">",expand_filename("~$user/export/$name.$ldev.unexport"));
 			print D "unexport=/media/$name/$ldev\n";
 			close (D);
 			syslog('notice', "USB device $name ($ldev) successfully unmounted");
@@ -145,7 +154,7 @@ if ( check_x2gothinclientd() ||  ( -d "/usr/share/doc/x2gothinclient-minidesktop
 			# inform x2goclient that the device has been removed
 			# release the encrypted device mapping
 			unlink ("$mntdir/$ldev.encrypted");
-			open ( D,">",expand_filename("~/x2gothinclient/logins/$name.$ldev.unexport"));
+			open ( D,">",expand_filename("~$user/logins/$name.$ldev.unexport"));
 			print D "logout=/media/$name/$ldev\n";
 			system("umount /media/$name/$ldev");
 			system("/sbin/cryptsetup luksClose keystick");

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


More information about the x2go-commits mailing list