./includes.chroot/usr/lib/x2go/tce/x2gousbmount <<USBMOUNTPATCH
A page in your DokuWiki was added or changed. Here are the details: Date : 2017/01/15 18:17 Browser : Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0 IP-Address : 78.43.90.159 Hostname : HSI-KBW-078-043-090-159.hsi4.kabel-badenwuerttemberg.de Old Revision: http://wiki.x2go.org/doku.php/doc:howto:tce?rev=1484503943 New Revision: http://wiki.x2go.org/doku.php/doc:howto:tce Edit Summary: [Starting the Build] User : stefanbaur @@ -86,8 +86,193 @@ # in a "build failed" message, even though the build might have worked): # export LBX2GO_IMAGETYPE='hdd' # to create a tar file only (seems to be broken in live-build): # export LBX2GO_IMAGETYPE='tar' + + </code> + + ==== Live-Patching the Build ==== + This patch is required if you need USB mount capability on the ThinClient while [[http://bugs.x2go.org/cgi-bin/bugreport.cgi?bug=1136|Bug #1136]] is still unresolved. + + <code> + mkdir -p ./includes.chroot/usr/lib/x2go/tce/ + + cat + + #!/usr/bin/perl + + # Copyright (C) 2007-2017 by X2Go project, http://wiki.x2go.org + # Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> + + # X2Go is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation; either version 2 of the License, or + # (at your option) any later version. + # + # X2Go is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program; if not, write to the + # Free Software Foundation, Inc., + # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + + use strict; + use File::Path::Expand; + use Sys::Syslog qw( :standard :macros ); + + my $user; + if ( -d "/lib/live/config" ) { + $user='user'; + } else { + $user='x2gothinclient'; + } + + mkdir "~$user/export" unless ( -d "~$user/export"); + mkdir "~$user/logins" unless ( -d "~$user/logins"); + + openlog($0,'cons,pid','user'); + setlogmask( LOG_UPTO(LOG_NOTICE) ); + + + sub check_x2gothinclientmode { + # check if X2GoClient is running in thinclient mode + # old code would check if x2gothinclientd was running, + # which fails on X2Go-TCE-live + my $x=`ps u -C x2goclient`; + if ( $x=~m/\W*--thinclient\W*/ ) + { + return 1; + } + return 0; + } + + if ( check_x2gothinclientmode() || ( -d "/usr/share/doc/x2gothinclient-minidesktop" ) ) + { + + open (F,">>/var/log/usb"); + + my $dev=$ENV{'DEVNAME'}; + my $model=$ENV{'ID_MODEL'}; + my $vendor=$ENV{'ID_VENDOR'}; + 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("~$user/mounts")) { + $mntdir=expand_filename("~$user/mounts"); + } elsif ( -d "/var/run" ) { + $mntdir="/var/run"; + } elsif ( -d "/run" ) { + $mntdir="/run"; + } else { + die "No directory found that we could use as \$mntdir..." + } + + my $name="${vendor}_${model}"; + $name=~s/ //g; + $name=~s/\\//g; + $name=~s/\///g; + print F "action: $action, device: $dev, model: $model ($ldev), total: $name\n"; + mkdir("/media"); + mkdir("/media/$name"); + print F "$name\n"; + + if ( $action eq "add") + { + + ### + ### ACTION: mount device after it has been added to USB subsystem + ### + + syslog('notice', "device add action called"); + + # prepare mount points + mkdir("/media"); + mkdir("/media/$name"); + mkdir("/media/$name/$ldev"); + + # mount the USB device + 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("~$user/export/$name.$ldev")); + print D "export=/media/$name/$ldev\n"; + close (D); + } + else + { + # the mount failed, let's assume that the device is encrypted... + my $enc=`ls -1 $mntdir | grep .encrypted`; + if( $enc eq "" ) + { + # use cryptsetup to decrypt the device... + system("/sbin/cryptsetup --key-file /etc/keys/keystick.key luksOpen $dev keystick"); + + # mount the ,,decrypted'' USB device via devmapper... + if(system("mount /dev/mapper/keystick /media/$name/$ldev ")==0) + { + # inform x2goclient about this... + system("touch $mntdir/$ldev.encrypted"); + 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); + } + else + { + # on mount failures release the decrypted device again + system("/sbin/cryptsetup luksClose keystick"); + } + } + else + { + print F "cryptodisk already present\n"; + } + } + } + elsif ( $action eq "remove" ) + { + + ### + ### ACTION: unmount device after it has been removed from the USB subsystem + ### + + syslog('notice', "device remove action called"); + + # we rely on our own mount logistics here... + if ( -e "$mntdir/$ldev.mounted" ) + { + # inform x2goclient that the device has been removed + system ("umount -ff /media/$name/$ldev"); + unlink ("$mntdir/$ldev.mounted"); + 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"); + } + elsif ( -e "$mntdir/$ldev.encrypted" ) + { + # inform x2goclient that the device has been removed + # release the encrypted device mapping + unlink ("$mntdir/$ldev.encrypted"); + 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"); + close (D); + } + } + + close (F); + } + USBMOUNTPATCH </code> ==== Starting the Build ==== -- This mail was generated by DokuWiki at http://wiki.x2go.org/