Skip to content

Commit

Permalink
Add sesman.ini FuseMountNameColonCharReplacement option
Browse files Browse the repository at this point in the history
  • Loading branch information
Bad-ptr committed Jan 6, 2025
1 parent e3d502c commit 170ad0c
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 5 deletions.
11 changes: 11 additions & 0 deletions docs/man/sesman.ini.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,17 @@ 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 specified string is longer than one character, then only first character
will be used.
If not specified, defaults to empty string, thus colon will be replaced by
null character.
If you want to keep colon in mount point names set this option to colon:
FuseMountNameColonCharReplacement=:
.RE

.TP
\fBFuseDirectIO\fR=\fI[false|true]\fR
Defaults to \fIfalse\fR. Set to \fItrue\fR to disable page caching in
Expand Down
26 changes: 25 additions & 1 deletion 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,23 @@ read_config_chansrv(log_func_t logmsg,
break;
}
}
else if (g_strcasecmp(name, "FuseMountNameColonCharReplacement") == 0)
{
g_free(cfg->fuse_mount_name_colon_char_replacement);
cfg->fuse_mount_name_colon_char_replacement = g_strdup(value);
if (cfg->fuse_mount_name_colon_char_replacement == NULL)
{
logmsg(LOG_LEVEL_ERROR, "Can't alloc FuseMountNameColonCharReplacement");
error = 1;
break;
}
if (g_strlen(cfg->fuse_mount_name_colon_char_replacement) > 1) {
logmsg(LOG_LEVEL_WARNING, "FuseMountNameColonCharReplacement "
"must be 1 character length, now it is '%s'."
"Only first char will be used!",
cfg->fuse_mount_name_colon_char_replacement);
}
}
else if (g_strcasecmp(name, "FuseDirectIO") == 0)
{
cfg->fuse_direct_io = g_text2bool(value);
Expand Down Expand Up @@ -299,12 +317,15 @@ new_config(void)
/* Do all the allocations at the beginning, then check them together */
struct config_chansrv *cfg = g_new0(struct config_chansrv, 1);
char *fuse_mount_name = g_strdup(DEFAULT_FUSE_MOUNT_NAME);
char *fuse_mount_name_colon_char_replacement = g_strdup(DEFAULT_FUSE_MOUNT_NAME_COLON_CHAR_REPLACEMENT);
char *log_file_path = g_strdup(DEFAULT_LOG_FILE_PATH);
if (cfg == NULL || fuse_mount_name == NULL || log_file_path == NULL)
if (cfg == NULL || fuse_mount_name == NULL || fuse_mount_name_colon_char_replacement == NULL
|| log_file_path == NULL)
{
/* At least one memory allocation failed */
g_free(log_file_path);
g_free(fuse_mount_name);
g_free(fuse_mount_name_colon_char_replacement);
g_free(cfg);
cfg = NULL;
}
Expand All @@ -315,6 +336,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 = 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 +441,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: %s", 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 All @@ -436,6 +459,7 @@ config_free(struct config_chansrv *cc)
{
g_free(cc->listen_port);
g_free(cc->fuse_mount_name);
g_free(cc->fuse_mount_name_colon_char_replacement);
g_free(cc->log_file_path);
g_free(cc);
}
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
30 changes: 27 additions & 3 deletions sesman/chansrv/chansrv_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,29 @@ 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 void _fuse_mount_name_colon_char_replace(char *const mntname, size_t nlen)
{
if (g_cfg->fuse_mount_name_colon_char_replacement &&
g_cfg->fuse_mount_name_colon_char_replacement[0] != ':')
{
for (size_t i = nlen-1; i > 0; --i) {
if (':' == mntname[i]) {
mntname[i] = g_cfg->fuse_mount_name_colon_char_replacement[0];
break;
}
}
}
return;
}

/* End of Local utility functions*/


/* Type of buffer used for fuse_add_direntry() calls */
struct dirbuf1
{
Expand Down Expand Up @@ -343,7 +366,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 @@ -734,14 +756,16 @@ int xfuse_get_wait_objs(tbus *objs, int *count, int *timeout)
* @return 0 on success, -1 on failure
*****************************************************************************/

int xfuse_create_share(tui32 device_id, const char *dirname)
int xfuse_create_share(tui32 device_id, char *dirname)
{
int result = -1;
XFS_INODE *xinode;
size_t dirnamelen = strlen(dirname);

if (dirname != NULL && strlen(dirname) > 0 &&
if (dirname != NULL && dirnamelen > 0 &&
xfuse_init_xrdp_fs() == 0)
{
_fuse_mount_name_colon_char_replace(dirname, dirnamelen);
xinode = xfs_add_entry(g_xfs, FUSE_ROOT_ID, dirname, (0777 | S_IFDIR));
if (xinode == NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion sesman/chansrv/chansrv_fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int xfuse_init(void);
int xfuse_deinit(void);
int xfuse_check_wait_objs(void);
int xfuse_get_wait_objs(tbus *objs, int *count, int *timeout);
int xfuse_create_share(tui32 share_id, const char *dirname);
int xfuse_create_share(tui32 share_id, char *dirname);
void xfuse_delete_share(tui32 share_id);

int xfuse_clear_clip_dir(void);
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

0 comments on commit 170ad0c

Please sign in to comment.