--- x2gomountdirs.orig	2013-10-23 13:00:43.606513703 +0100
+++ x2gomountdirs	2013-10-23 13:03:04.398514662 +0100
@@ -267,15 +267,28 @@
 
 	if (db_insertmount( $session, $mntpath, $host))
 	{
+
+		my $Config = new Config::Simple(syntax=>'ini');
+		$Config->read('/etc/x2go/x2goserver.conf' );
+		my $umask=$Config->param("security.umask");
+		my $umaskstr="";
+
+		if ($umask ne "")
+        	{
+        		$umaskstr="umask=$umask";
+        	} else {
+        		$umaskstr="default_permissions";
+        	}
 		my $code_conv=$ENV{'X2GO_ICONV'};
+
 		if ($code_conv ne "")
 		{
 			$code_conv="-o $code_conv";
 		}
-		$msg = "sshfs $code_conv -o idmap=user,uid=`id -u`,gid=`id -g`,ServerAliveInterval=300,Cipher=blowfish,IdentityFile=$key,UserKnownHostsFile=$key.ident \"$user\"\@$host:\"@dirs[$i]\" \"$mntpath\" -p $port";
+		$msg = "sshfs $code_conv -o idmap=user,uid=`id -u`,gid=`id -g`,$umaskstr,ServerAliveInterval=300,Cipher=blowfish,IdentityFile=$key,UserKnownHostsFile=$key.ident \"$user\"\@$host:\"@dirs[$i]\" \"$mntpath\" -p $port";
 		syslog('debug', "executing: $msg");
 		print "inserted, $msg\n";
-		if (system("sshfs  $code_conv -o idmap=user,uid=`id -u`,gid=`id -g`,ServerAliveInterval=300,Cipher=blowfish,IdentityFile=$key,UserKnownHostsFile=$key.ident \"$user\"\@$host:\"@dirs[$i]\" \"$mntpath\" -p $port 2>>~/mounts.log")==0)
+		if (system("sshfs  $code_conv -o idmap=user,uid=`id -u`,gid=`id -g`,$umaskstr,ServerAliveInterval=300,Cipher=blowfish,IdentityFile=$key,UserKnownHostsFile=$key.ident \"$user\"\@$host:\"@dirs[$i]\" \"$mntpath\" -p $port 2>>~/mounts.log")==0)
 		{
 			print "mount @dirs[$i] ok\n";
 			syslog('notice', "successfully mounted $user\@$host:$port@dirs[$i] to $mntpath");
