summaryrefslogtreecommitdiffstats
path: root/sesman/chansrv/devredir.c
diff options
context:
space:
mode:
Diffstat (limited to 'sesman/chansrv/devredir.c')
-rw-r--r--sesman/chansrv/devredir.c106
1 files changed, 70 insertions, 36 deletions
diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c
index 8de28e43..418c29e7 100644
--- a/sesman/chansrv/devredir.c
+++ b/sesman/chansrv/devredir.c
@@ -120,13 +120,15 @@ dev_redir_init(void)
/* get a random number that will act as a unique clientID */
if ((fd = open("/dev/urandom", O_RDONLY)))
{
- read(fd, u.buf, 4);
+ if (read(fd, u.buf, 4) != 4)
+ {
+ }
close(fd);
}
else
{
/* /dev/urandom did not work - use address of struct s */
- tui64 u64 = (tui64) &s;
+ tui64 u64 = (tui64) (tintptr) &s;
u.clientID = (tui32) u64;
}
@@ -152,6 +154,7 @@ dev_redir_init(void)
int APP_CC
dev_redir_deinit(void)
{
+ scard_deinit();
return 0;
}
@@ -282,6 +285,10 @@ done:
int APP_CC
dev_redir_get_wait_objs(tbus *objs, int *count, int *timeout)
{
+ if (g_is_smartcard_redir_supported)
+ {
+ return scard_get_wait_objs(objs, count, timeout);
+ }
return 0;
}
@@ -289,6 +296,10 @@ dev_redir_get_wait_objs(tbus *objs, int *count, int *timeout)
int APP_CC
dev_redir_check_wait_objs(void)
{
+ if (g_is_smartcard_redir_supported)
+ {
+ return scard_check_wait_objs();
+ }
return 0;
}
@@ -515,7 +526,9 @@ void dev_redir_send_drive_dir_request(IRP *irp, tui32 device_id,
if (InitialQuery)
{
if (Path == NULL)
+ {
return;
+ }
/* Path in unicode needs this much space */
path_len = ((g_mbstowcs(NULL, Path, 0) * sizeof(twchar)) / 2) + 2;
@@ -617,6 +630,7 @@ void dev_redir_proc_client_core_cap_resp(struct stream *s)
case CAP_SMARTCARD_TYPE:
log_debug("got CAP_SMARTCARD_TYPE");
g_is_smartcard_redir_supported = 1;
+ scard_init();
xstream_seek(s, cap_len);
break;
}
@@ -704,7 +718,8 @@ void devredir_proc_client_devlist_announce_req(struct stream *s)
}
}
-void dev_redir_proc_device_iocompletion(struct stream *s)
+void APP_CC
+dev_redir_proc_device_iocompletion(struct stream *s)
{
FUSE_DATA *fuse_data = NULL;
IRP *irp = NULL;
@@ -859,11 +874,12 @@ done:
log_debug("exiting");
}
-void dev_redir_proc_query_dir_response(IRP *irp,
- struct stream *s_in,
- tui32 DeviceId,
- tui32 CompletionId,
- tui32 IoStatus)
+void APP_CC
+dev_redir_proc_query_dir_response(IRP *irp,
+ struct stream *s_in,
+ tui32 DeviceId,
+ tui32 CompletionId,
+ tui32 IoStatus)
{
FUSE_DATA *fuse_data = NULL;
XRDP_INODE *xinode = NULL;
@@ -984,11 +1000,12 @@ void dev_redir_proc_query_dir_response(IRP *irp,
* @return 0 on success, -1 on failure
*****************************************************************************/
-int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path)
+int APP_CC
+dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path)
{
tui32 DesiredAccess;
tui32 CreateOptions;
- tui32 CreateDisposition;
+ tui32 CreateDisposition;
int rval;
IRP *irp;
@@ -1028,8 +1045,9 @@ int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path)
return rval;
}
-int dev_redir_file_open(void *fusep, tui32 device_id, char *path,
- int mode, int type, char *gen_buf)
+int APP_CC
+dev_redir_file_open(void *fusep, tui32 device_id, char *path,
+ int mode, int type, char *gen_buf)
{
tui32 DesiredAccess;
tui32 CreateOptions;
@@ -1140,7 +1158,8 @@ int devredir_file_close(void *fusep, tui32 device_id, tui32 FileId)
* Remove (delete) a directory or file
*****************************************************************************/
-int devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
+int APP_CC
+devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
{
tui32 DesiredAccess;
tui32 CreateOptions;
@@ -1181,8 +1200,9 @@ int devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
* @return 0 on success, -1 on failure
*****************************************************************************/
-int devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
- tui32 Length, tui64 Offset)
+int APP_CC
+devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
+ tui32 Length, tui64 Offset)
{
struct stream *s;
IRP *irp;
@@ -1229,8 +1249,9 @@ int devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
return 0;
}
-int dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
- const char *buf, tui32 Length, tui64 Offset)
+int APP_CC
+dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
+ const char *buf, tui32 Length, tui64 Offset)
{
struct stream *s;
IRP *irp;
@@ -1293,7 +1314,8 @@ int dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
* @return FUSE_DATA on success, or NULL on failure
*****************************************************************************/
-void *devredir_fuse_data_peek(IRP *irp)
+void * APP_CC
+devredir_fuse_data_peek(IRP *irp)
{
log_debug("returning %p", irp->fd_head);
return irp->fd_head;
@@ -1305,7 +1327,8 @@ void *devredir_fuse_data_peek(IRP *irp)
* @return FUSE_DATA on success, NULL on failure
*****************************************************************************/
-void *devredir_fuse_data_dequeue(IRP *irp)
+void * APP_CC
+devredir_fuse_data_dequeue(IRP *irp)
{
FUSE_DATA *head;
@@ -1340,7 +1363,8 @@ void *devredir_fuse_data_dequeue(IRP *irp)
* @return 0 on success, -1 on failure
*****************************************************************************/
-int devredir_fuse_data_enqueue(IRP *irp, void *vp)
+int APP_CC
+devredir_fuse_data_enqueue(IRP *irp, void *vp)
{
FUSE_DATA *fd;
FUSE_DATA *tail;
@@ -1377,12 +1401,13 @@ int devredir_fuse_data_enqueue(IRP *irp, void *vp)
** miscellaneous stuff **
******************************************************************************/
-void devredir_insert_DeviceIoRequest(struct stream *s,
- tui32 DeviceId,
- tui32 FileId,
- tui32 CompletionId,
- tui32 MajorFunction,
- tui32 MinorFunction)
+void APP_CC
+devredir_insert_DeviceIoRequest(struct stream *s,
+ tui32 DeviceId,
+ tui32 FileId,
+ tui32 CompletionId,
+ tui32 MajorFunction,
+ tui32 MinorFunction)
{
/* setup DR_DEVICE_IOREQUEST header */
xstream_wr_u16_le(s, RDPDR_CTYP_CORE);
@@ -1398,7 +1423,8 @@ void devredir_insert_DeviceIoRequest(struct stream *s,
* Convert / to windows compatible \
*****************************************************************************/
-void devredir_cvt_slash(char *path)
+void APP_CC
+devredir_cvt_slash(char *path)
{
char *cptr = path;
@@ -1410,7 +1436,8 @@ void devredir_cvt_slash(char *path)
}
}
-void devredir_cvt_to_unicode(char *unicode, char *path)
+void APP_CC
+devredir_cvt_to_unicode(char *unicode, char *path)
{
char *dest;
char *src;
@@ -1435,7 +1462,8 @@ void devredir_cvt_to_unicode(char *unicode, char *path)
*dest++ = 0;
}
-void devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
+void APP_CC
+devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
{
char *dest;
char *dest_saved;
@@ -1472,7 +1500,8 @@ void devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
g_free(dest_saved);
}
-int dev_redir_string_ends_with(char *string, char c)
+int APP_CC
+dev_redir_string_ends_with(char *string, char c)
{
int len;
@@ -1480,14 +1509,16 @@ int dev_redir_string_ends_with(char *string, char c)
return (string[len - 1] == c) ? 1 : 0;
}
-void devredir_insert_RDPDR_header(struct stream *s, tui16 Component,
- tui16 PacketId)
+void APP_CC
+devredir_insert_RDPDR_header(struct stream *s, tui16 Component,
+ tui16 PacketId)
{
xstream_wr_u16_le(s, Component);
xstream_wr_u16_le(s, PacketId);
}
-void devredir_proc_cid_rmdir_or_file(IRP *irp, tui32 IoStatus)
+void APP_CC
+devredir_proc_cid_rmdir_or_file(IRP *irp, tui32 IoStatus)
{
struct stream *s;
int bytes;
@@ -1523,7 +1554,8 @@ void devredir_proc_cid_rmdir_or_file(IRP *irp, tui32 IoStatus)
return;
}
-void devredir_proc_cid_rmdir_or_file_resp(IRP *irp, tui32 IoStatus)
+void APP_CC
+devredir_proc_cid_rmdir_or_file_resp(IRP *irp, tui32 IoStatus)
{
FUSE_DATA *fuse_data;
@@ -1549,7 +1581,8 @@ void devredir_proc_cid_rmdir_or_file_resp(IRP *irp, tui32 IoStatus)
IRP_MJ_CLOSE, 0, 32);
}
-void devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus)
+void APP_CC
+devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus)
{
struct stream *s;
int bytes;
@@ -1601,7 +1634,8 @@ void devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus)
return;
}
-void devredir_proc_cid_rename_file_resp(IRP *irp, tui32 IoStatus)
+void APP_CC
+devredir_proc_cid_rename_file_resp(IRP *irp, tui32 IoStatus)
{
FUSE_DATA *fuse_data;