diff options
Diffstat (limited to 'sesman/chansrv/chansrv_fuse.c')
-rw-r--r-- | sesman/chansrv/chansrv_fuse.c | 86 |
1 files changed, 65 insertions, 21 deletions
diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 2eb78ea0..c4532ead 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -39,6 +39,8 @@ //#define USE_SYNC_FLAG +static char g_fuse_mount_name[256] = "xrdp_client"; + /* FUSE mount point */ char g_fuse_root_path[256] = ""; char g_fuse_clipboard_path[256] = ""; /* for clipboard use */ @@ -71,7 +73,7 @@ int xfuse_create_share(tui32 device_id, char *dirname) { r void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId) {} void xfuse_devredir_cb_write_file(void *vp, char *buf, size_t length) {} void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length) {} -void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) {} +int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) {} void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus) {} void xfuse_devredir_cb_rmdir_or_file(void *vp, tui32 IoStatus) {} void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus) {} @@ -369,6 +371,37 @@ int clipboard_request_file_data(int stream_id, int lindex, int offset, static void xfuse_mark_as_stale(int pinode); static void xfuse_delete_stale_entries(int pinode); +/*****************************************************************************/ +int APP_CC +load_fuse_config(void) +{ + int index; + char cfg_file[256]; + struct list *items; + struct list *values; + char *item; + char *value; + + items = list_create(); + items->auto_free = 1; + values = list_create(); + values->auto_free = 1; + g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH); + file_by_name_read_section(cfg_file, "Chansrv", items, values); + for (index = 0; index < items->count; index++) + { + item = (char *)list_get_item(items, index); + value = (char *)list_get_item(values, index); + if (g_strcasecmp(item, "FuseMountName") == 0) + { + g_strncpy(g_fuse_mount_name, value, 255); + } + } + list_delete(items); + list_delete(values); + return 0; +} + /***************************************************************************** ** ** ** public functions - can be called from any code path ** @@ -381,7 +414,8 @@ static void xfuse_delete_stale_entries(int pinode); * @return 0 on success, -1 on failure *****************************************************************************/ -int xfuse_init() +int APP_CC +xfuse_init(void) { struct fuse_args args = FUSE_ARGS_INIT(0, NULL); @@ -398,8 +432,10 @@ int xfuse_init() return -1; } - /* define FUSE mount point to ~/xrdp_client */ - g_snprintf(g_fuse_root_path, 255, "%s/xrdp_client", g_getenv("HOME")); + load_fuse_config(); + + /* define FUSE mount point to ~/xrdp_client, ~/thinclient_drives */ + g_snprintf(g_fuse_root_path, 255, "%s/%s", g_getenv("HOME"), g_fuse_mount_name); g_snprintf(g_fuse_clipboard_path, 255, "%s/.clipboard", g_fuse_root_path); /* if FUSE mount point does not exist, create it */ @@ -460,7 +496,8 @@ int xfuse_init() * @return 0 on success, -1 on failure *****************************************************************************/ -int xfuse_deinit() +int APP_CC +xfuse_deinit(void) { xfuse_deinit_xrdp_fs(); fifo_deinit(&g_fifo_opendir); @@ -1385,7 +1422,7 @@ static void xfuse_update_xrdpfs_size() * Add a file or directory to xrdp file system *****************************************************************************/ -void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) +int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) { XFUSE_INFO *fip = (XFUSE_INFO *) vp; XRDP_INODE *xip = NULL; @@ -1393,13 +1430,14 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) if ((fip == NULL) || (xinode == NULL)) { log_error("fip or xinode are NULL"); - return; + return -1; } if (!xfuse_is_inode_valid(fip->inode)) { log_error("inode %d is not valid", fip->inode); - return; + g_free(xinode); + return -1; } log_debug("parent_inode=%d name=%s", fip->inode, xinode->name); @@ -1407,8 +1445,8 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) /* if filename is . or .. don't add it */ if ((strcmp(xinode->name, ".") == 0) || (strcmp(xinode->name, "..") == 0)) { - free(xinode); - return; + g_free(xinode); + return -1; } xfuse_dump_fs(); @@ -1417,9 +1455,9 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) { log_debug("inode=%d name=%s already exists in xrdp_fs; not adding it", fip->inode, xinode->name); - free(xinode); + g_free(xinode); xip->stale = 0; - return; + return -1; } xinode->parent_inode = fip->inode; @@ -1436,6 +1474,7 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) xfuse_update_xrdpfs_size(); xfuse_dump_fs(); + return 0; } /** @@ -1742,12 +1781,15 @@ void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus) new_xinode = xfuse_get_inode_from_pinode_name(fip->new_inode, fip->new_name); - if (new_xinode->mode & S_IFREG) - xfuse_delete_file_with_xinode(new_xinode); - else - xfuse_delete_dir_with_xinode(new_xinode); + if (new_xinode) + { + if (new_xinode->mode & S_IFREG) + xfuse_delete_file_with_xinode(new_xinode); + else + xfuse_delete_dir_with_xinode(new_xinode); - new_xinode = NULL; + new_xinode = NULL; + } } old_xinode = xfuse_get_inode_from_pinode_name(fip->inode, fip->name); @@ -1759,7 +1801,8 @@ void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus) } old_xinode->parent_inode = fip->new_inode; - strcpy(old_xinode->name, fip->new_name); + strncpy(old_xinode->name, fip->new_name, 1023); + old_xinode->name[1023] = 0; if (fip->inode != fip->new_inode) { @@ -1987,7 +2030,7 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, return; } - di = (struct dir_info *) fi->fh; + di = (struct dir_info *) (tintptr) (fi->fh); if (di == NULL) { /* something seriously wrong somewhere! */ @@ -2142,7 +2185,7 @@ static void xfuse_remove_dir_or_file(fuse_req_t req, fuse_ino_t parent, } strcat(full_path, "/"); - strcat(full_path, name); + strncat(full_path, name, sizeof(full_path) - strlen(full_path)); if (xinode->is_loc_resource) { @@ -2583,7 +2626,6 @@ static void xfuse_cb_release(fuse_req_t req, fuse_ino_t ino, struct fip, fip->fi, fip->fi->fh); FileId = handle->FileId; - free(handle); fip->fi->fh = 0; xinode->close_in_progress = 1; @@ -2592,6 +2634,8 @@ static void xfuse_cb_release(fuse_req_t req, fuse_ino_t ino, struct log_error("failed to send devredir_close_file() cmd"); fuse_reply_err(req, EREMOTEIO); } + + free(handle); } /** |