Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V0.10] Add sesman.ini FuseMountNameColonCharReplacement option #3389

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/man/sesman.ini.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions sesman/chansrv/chansrv_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions sesman/chansrv/chansrv_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
39 changes: 37 additions & 2 deletions sesman/chansrv/chansrv_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions sesman/sesman.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down