Subject: Bug when you mount more 1 folder at login
From: Pascal Vibet - ADACIS <[email-masked]>
To: [email-masked]
Cc: Vibet Pascal <[email-masked]>, "[email-masked]" <[email-masked]>
Date: Fri, 30 Nov 2012 07:49:28 +0100

Package: x2goserver

Version: 3.1.1.3-0~571~precise1_amd64

I want to mount 3 folder at login. Only the first one is mount at
login.

This is log file: cat ~/mounts.log
SSHFS version 2.3
Server version: 3
Extension: [email-masked] <1>
Extension: [email-masked] <2>
Extension: [email-masked] <2>
Extension: [email-masked] <1>
fuse: bad mount point
`/tmp/.x2go-xxxxxxx/media/disk/disk/_home_xxxxxxx_folder2': No such file
or directory
fuse: bad mount point
`/tmp/.x2go-xxxxxxx/media/disk/disk/disk/_home_xxxxxxx_folder3': No such
file or directory

The bug is in /usr/bin/x2gomountdirs, explication:

the $mdir variable is initialize line:
87	my $mdir="$tmp_dir/.x2go-$ENV{'USER'}/media";

but in code bloc
    162	for (my $i=0;$i<@dirs;$i++)
    163	{
    164		my $printspool=0;
    165		my $mimeboxspool=0;
    166		my $mntpath;
    167		if(@dirs[$i]=~m/__PRINT_SPOOL_/)
    168		{
    169			@dirs[$i]=~s/__PRINT_SPOOL_//;
    170			$printspool=1;
    171			$mntpath=$spooldir;
    172			syslog('debug', "mounting $spooldir, mount point type is print
spool directory");
    173		}
    174		elsif(@dirs[$i]=~m/__MIMEBOX_SPOOL_/)
    175		{
    176			@dirs[$i]=~s/__MIMEBOX_SPOOL_//;
    177			$mimeboxspool=1;
    178			$mntpath=$mimeboxdir;
    179			syslog('debug', "mounting $mimeboxdir, mount point type is
MIME box directory");
    180		}
    181		else
    182		{
    183			my $p=@dirs[$i];
    184			if ($type ne "dir")
    185			{
    186				$p=~s/\/ramdrive\/mnt\///;
    187				if ($p =~ m/CDROM/)
    188				{
    189					$mdir=$mdir."/cd";
    190				}
    191				else
    192				{
    193					$mdir=$mdir."/rm";
    194				}
    195			}
    196			else
    197			{
    198				$mdir=$mdir."/disk";
    199			}
    200			$p=~s/\//_/g;
    201			$p=~s/ /_/g;
    202			$p=~s/~_cygdrive_//;
    203			$p=~s/~_windrive_//;
    204			$p=~s/~//g;
    205			mkdir("$mdir/$p");
    206			$mntpath="$mdir/$p";
    207		}

if we have more than 1 folder to share, $mdir variable will became:
first time:
$mdir="$tmp_dir/.x2go-$ENV{'USER'}/media/disk"
second time:
$mdir="$tmp_dir/.x2go-$ENV{'USER'}/media/disk/disk";
third time:
$mdir="$tmp_dir/.x2go-$ENV{'USER'}/media/disk/disk/disk";

Solution is to fix $mdir variable in begin for loop. Add
$mdir="$tmp_dir/.x2go-$ENV{'USER'}/media" in line:
    164		my $printspool=0;
    165		my $mimeboxspool=0;
    166		my $mntpath;
=> 167          $mdir="$tmp_dir/.x2go-$ENV{'USER'}/media";

Regards

---------------------------------
Pascal Vibet