Add sesman.ini FuseMountNameColonCharReplacement option

This commit is contained in:
Constantin Kulikov
2025-01-05 19:21:21 +03:00
parent e3d502ca06
commit 151c555fc0
5 changed files with 71 additions and 2 deletions
+9
View File
@@ -380,6 +380,15 @@ the user).
drive. To fix this, consult the docs for your chosen desktop.
.RE
.TP
\fBFuseMountNameColonCharReplacement\fR=\fIstring\fR
Character to replace colon in redirected drive mount point names.
If not specified no colon will not be replaced.
If empty then colon will be replaced by null character.
If longer than one character, only first character used.
Only last colon replaced.
.RE
.TP
\fBFuseDirectIO\fR=\fI[false|true]\fR
Defaults to \fIfalse\fR. Set to \fItrue\fR to disable page caching in
+22
View File
@@ -40,6 +40,7 @@
#define DEFAULT_RESTRICT_INBOUND_CLIPBOARD 0
#define DEFAULT_ENABLE_FUSE_MOUNT 1
#define DEFAULT_FUSE_MOUNT_NAME "xrdp-client"
#define DEFAULT_FUSE_MOUNT_NAME_COLON_CHAR_REPLACEMENT ':'
#define DEFAULT_FUSE_DIRECT_IO 0
#define DEFAULT_FILE_UMASK 077
#define DEFAULT_USE_NAUTILUS3_FLIST_FORMAT 0
@@ -220,6 +221,25 @@ read_config_chansrv(log_func_t logmsg,
break;
}
}
else if (g_strcasecmp(name, "FuseMountNameColonCharReplacement") == 0)
{
size_t vallen = g_strlen(value);
if (vallen < 1)
{
cfg->fuse_mount_name_colon_char_replacement = '\0';
}
else
{
if (vallen > 1)
{
logmsg(LOG_LEVEL_WARNING, "FuseMountNameColonCharReplacement "
"must be 1 character length, now it is '%s'."
"Only first char will be used!",
value);
}
cfg->fuse_mount_name_colon_char_replacement = value[0];
}
}
else if (g_strcasecmp(name, "FuseDirectIO") == 0)
{
cfg->fuse_direct_io = g_text2bool(value);
@@ -315,6 +335,7 @@ new_config(void)
cfg->restrict_outbound_clipboard = DEFAULT_RESTRICT_OUTBOUND_CLIPBOARD;
cfg->restrict_inbound_clipboard = DEFAULT_RESTRICT_INBOUND_CLIPBOARD;
cfg->fuse_mount_name = fuse_mount_name;
cfg->fuse_mount_name_colon_char_replacement = DEFAULT_FUSE_MOUNT_NAME_COLON_CHAR_REPLACEMENT;
cfg->fuse_direct_io = DEFAULT_FUSE_DIRECT_IO;
cfg->file_umask = DEFAULT_FILE_UMASK;
cfg->use_nautilus3_flist_format = DEFAULT_USE_NAUTILUS3_FLIST_FORMAT;
@@ -419,6 +440,7 @@ config_dump(struct config_chansrv *config)
g_writeln(" EnableFuseMount %s",
g_bool2text(config->enable_fuse_mount));
g_writeln(" FuseMountName: %s", config->fuse_mount_name);
g_writeln(" FuseMountNameColonCharReplacement: %c", config->fuse_mount_name_colon_char_replacement);
g_writeln(" FuseDirectIO: %s",
g_bool2text(config->fuse_direct_io));
g_writeln(" FileMask: 0%o", config->file_umask);
+2
View File
@@ -39,6 +39,8 @@ struct config_chansrv
/** * FuseMountName from sesman.ini */
char *fuse_mount_name;
/** * FuseMountNameColonCharReplacement from sesman.ini */
char fuse_mount_name_colon_char_replacement;
/** FileUmask from sesman.ini */
mode_t file_umask;
+37 -2
View File
@@ -191,6 +191,36 @@ int xfuse_path_in_xfuse_fs(const char *path)
#define XFUSE_ENTRY_TIMEOUT 5.0
extern struct config_chansrv *g_cfg; /* in chansrv.c */
/* Local utility functions */
static inline char *
_fuse_mount_name_colon_char_replace(const char *dirname)
{
char *newdirname = (char *) dirname;
if (g_cfg->fuse_mount_name_colon_char_replacement != ':')
{
newdirname = g_strdup(dirname);
if (newdirname == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR,
"Failed to duplicate fuse mount name string");
return (char *) dirname;
}
char *colonptr = g_strrchr(newdirname, ':');
if (colonptr != NULL)
{
*colonptr = g_cfg->fuse_mount_name_colon_char_replacement;
}
}
return newdirname;
}
/* End of Local utility functions*/
/* Type of buffer used for fuse_add_direntry() calls */
struct dirbuf1
{
@@ -343,7 +373,6 @@ struct req_list_item
int size;
};
extern struct config_chansrv *g_cfg; /* in chansrv.c */
static struct list *g_req_list = 0;
static struct xfs_fs *g_xfs; /* an inst of xrdp file system */
@@ -742,7 +771,13 @@ int xfuse_create_share(tui32 device_id, const char *dirname)
if (dirname != NULL && strlen(dirname) > 0 &&
xfuse_init_xrdp_fs() == 0)
{
xinode = xfs_add_entry(g_xfs, FUSE_ROOT_ID, dirname, (0777 | S_IFDIR));
char *newdirname = _fuse_mount_name_colon_char_replace(dirname);
xinode = xfs_add_entry(g_xfs, FUSE_ROOT_ID, newdirname, (0777 | S_IFDIR));
//free only if _fuse_mount_name_colon_char_replace allocated new string
if (newdirname != dirname)
{
g_free(newdirname);
}
if (xinode == NULL)
{
LOG_DEVEL(LOG_LEVEL_DEBUG, "xfs_add_entry() failed");
+1
View File
@@ -168,6 +168,7 @@ param=96
#FuseMountName=/run/user/%u/thinclient_drives
#FuseMountName=/media/thinclient_drives/%U/thinclient_drives
FuseMountName=thinclient_drives
#FuseMountNameColonCharReplacement=
; this value allows only the user to access their own mapped drives.
; Make this more permissive (e.g. 022) if required.
FileUmask=077