Merge branch 'master' into logging
This commit is contained in:
commit
7b9a09e173
10
disk.c
10
disk.c
@ -4,6 +4,7 @@
|
|||||||
Copyright (C) Jeroen Meijer <jeroen@oldambt7.com> 2003-2008
|
Copyright (C) Jeroen Meijer <jeroen@oldambt7.com> 2003-2008
|
||||||
Copyright 2003-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
|
Copyright 2003-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
|
||||||
Copyright 2017 Henrik Andersson <hean01@cendio.se> for Cendio AB
|
Copyright 2017 Henrik Andersson <hean01@cendio.se> for Cendio AB
|
||||||
|
Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -316,6 +317,7 @@ disk_enum_devices(uint32 * id, char *optarg)
|
|||||||
char *pos = optarg;
|
char *pos = optarg;
|
||||||
char *pos2;
|
char *pos2;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
DISK_DEVICE *pdisk_data;
|
||||||
|
|
||||||
/* skip the first colon */
|
/* skip the first colon */
|
||||||
optarg++;
|
optarg++;
|
||||||
@ -323,14 +325,16 @@ disk_enum_devices(uint32 * id, char *optarg)
|
|||||||
{
|
{
|
||||||
pos2 = next_arg(optarg, '=');
|
pos2 = next_arg(optarg, '=');
|
||||||
|
|
||||||
|
pdisk_data = (DISK_DEVICE *) xmalloc(sizeof(DISK_DEVICE));
|
||||||
|
memset(pdisk_data, 0, sizeof(DISK_DEVICE));
|
||||||
|
strncpy(pdisk_data->name, optarg, sizeof(pdisk_data->name) - 1);
|
||||||
strncpy(g_rdpdr_device[*id].name, optarg, sizeof(g_rdpdr_device[*id].name) - 1);
|
strncpy(g_rdpdr_device[*id].name, optarg, sizeof(g_rdpdr_device[*id].name) - 1);
|
||||||
if (strlen(optarg) > (sizeof(g_rdpdr_device[*id].name) - 1))
|
|
||||||
logger(Core, Warning, "disk_enum_devices(), share name %s truncated to %s",
|
|
||||||
optarg, g_rdpdr_device[*id].name);
|
|
||||||
|
|
||||||
g_rdpdr_device[*id].local_path = (char *) xmalloc(strlen(pos2) + 1);
|
g_rdpdr_device[*id].local_path = (char *) xmalloc(strlen(pos2) + 1);
|
||||||
strcpy(g_rdpdr_device[*id].local_path, pos2);
|
strcpy(g_rdpdr_device[*id].local_path, pos2);
|
||||||
g_rdpdr_device[*id].device_type = DEVICE_TYPE_DISK;
|
g_rdpdr_device[*id].device_type = DEVICE_TYPE_DISK;
|
||||||
|
g_rdpdr_device[*id].pdevice_data = (void *) pdisk_data;
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
(*id)++;
|
(*id)++;
|
||||||
|
|
||||||
|
45
rdpdr.c
45
rdpdr.c
@ -235,14 +235,24 @@ announcedata_size()
|
|||||||
{
|
{
|
||||||
int size, i;
|
int size, i;
|
||||||
PRINTER *printerinfo;
|
PRINTER *printerinfo;
|
||||||
|
DISK_DEVICE *diskinfo;
|
||||||
|
|
||||||
size = 8; /* static announce size */
|
size = 8; /* Header + DeviceCount */
|
||||||
size += g_num_devices * 0x14;
|
|
||||||
|
|
||||||
for (i = 0; i < g_num_devices; i++)
|
for (i = 0; i < g_num_devices; i++)
|
||||||
{
|
{
|
||||||
if (g_rdpdr_device[i].device_type == DEVICE_TYPE_PRINTER)
|
size += 4; /* DeviceType */
|
||||||
|
size += 4; /* DeviceId */
|
||||||
|
size += 8; /* PreferredDosName */
|
||||||
|
size += 4; /* DeviceDataLength */
|
||||||
|
|
||||||
|
switch (g_rdpdr_device[i].device_type)
|
||||||
{
|
{
|
||||||
|
case DEVICE_TYPE_DISK:
|
||||||
|
diskinfo = (DISK_DEVICE *) g_rdpdr_device[i].pdevice_data;
|
||||||
|
size += 2 * strlen(diskinfo->name) + 2;
|
||||||
|
break;
|
||||||
|
case DEVICE_TYPE_PRINTER:
|
||||||
printerinfo = (PRINTER *) g_rdpdr_device[i].pdevice_data;
|
printerinfo = (PRINTER *) g_rdpdr_device[i].pdevice_data;
|
||||||
printerinfo->bloblen =
|
printerinfo->bloblen =
|
||||||
printercache_load_blob(printerinfo->printer, &(printerinfo->blob));
|
printercache_load_blob(printerinfo->printer, &(printerinfo->blob));
|
||||||
@ -251,6 +261,9 @@ announcedata_size()
|
|||||||
size += 2 * strlen(printerinfo->driver) + 2;
|
size += 2 * strlen(printerinfo->driver) + 2;
|
||||||
size += 2 * strlen(printerinfo->printer) + 2;
|
size += 2 * strlen(printerinfo->printer) + 2;
|
||||||
size += printerinfo->bloblen;
|
size += printerinfo->bloblen;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,10 +274,11 @@ static void
|
|||||||
rdpdr_send_client_device_list_announce(void)
|
rdpdr_send_client_device_list_announce(void)
|
||||||
{
|
{
|
||||||
/* DR_CORE_CLIENT_ANNOUNCE_RSP */
|
/* DR_CORE_CLIENT_ANNOUNCE_RSP */
|
||||||
uint32 driverlen, printerlen, bloblen;
|
uint32 driverlen, printerlen, bloblen, disklen;
|
||||||
int i;
|
int i;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
PRINTER *printerinfo;
|
PRINTER *printerinfo;
|
||||||
|
DISK_DEVICE *diskinfo;
|
||||||
|
|
||||||
s = channel_init(rdpdr_channel, announcedata_size());
|
s = channel_init(rdpdr_channel, announcedata_size());
|
||||||
out_uint16_le(s, RDPDR_CTYP_CORE);
|
out_uint16_le(s, RDPDR_CTYP_CORE);
|
||||||
@ -272,16 +286,27 @@ rdpdr_send_client_device_list_announce(void)
|
|||||||
|
|
||||||
out_uint32_le(s, g_num_devices);
|
out_uint32_le(s, g_num_devices);
|
||||||
|
|
||||||
for (i = 0; i < g_num_devices; i++)
|
for (i = 0; i < g_num_devices; i++) /* DEVICE_ANNOUNCE */
|
||||||
{
|
{
|
||||||
out_uint32_le(s, g_rdpdr_device[i].device_type);
|
out_uint32_le(s, g_rdpdr_device[i].device_type);
|
||||||
out_uint32_le(s, i); /* RDP Device ID */
|
out_uint32_le(s, i); /* RDP Device ID */
|
||||||
/* Is it possible to use share names longer than 8 chars?
|
out_uint8p(s, g_rdpdr_device[i].name, 8); /* preferredDosName, limited to 8 characters */
|
||||||
/astrand */
|
|
||||||
out_uint8p(s, g_rdpdr_device[i].name, 8);
|
|
||||||
|
|
||||||
switch (g_rdpdr_device[i].device_type)
|
switch (g_rdpdr_device[i].device_type)
|
||||||
{
|
{
|
||||||
|
case DEVICE_TYPE_DISK:
|
||||||
|
diskinfo = (DISK_DEVICE *) g_rdpdr_device[i].pdevice_data;
|
||||||
|
|
||||||
|
/* The RDP specification says that the DeviceData is supposed to be
|
||||||
|
a null-terminated Unicode string, but that does not work. In
|
||||||
|
practice the string is expected to be an ASCII string, like a
|
||||||
|
variable-length preferredDosName. */
|
||||||
|
|
||||||
|
disklen = strlen(diskinfo->name) + 1;
|
||||||
|
|
||||||
|
out_uint32_le(s, disklen); /* DeviceDataLength */
|
||||||
|
out_uint8p(s, diskinfo->name, disklen); /* DeviceData */
|
||||||
|
break;
|
||||||
|
|
||||||
case DEVICE_TYPE_PRINTER:
|
case DEVICE_TYPE_PRINTER:
|
||||||
printerinfo = (PRINTER *) g_rdpdr_device[i].pdevice_data;
|
printerinfo = (PRINTER *) g_rdpdr_device[i].pdevice_data;
|
||||||
|
|
||||||
@ -793,7 +818,7 @@ rdpdr_send_client_capability_response(void)
|
|||||||
|
|
||||||
out_uint16_le(s, CAP_DRIVE_TYPE); /* CapabilityType */
|
out_uint16_le(s, CAP_DRIVE_TYPE); /* CapabilityType */
|
||||||
out_uint16_le(s, 8); /* CapabilityLength */
|
out_uint16_le(s, 8); /* CapabilityLength */
|
||||||
out_uint32_le(s, DRIVE_CAPABILITY_VERSION_01); /* Version */
|
out_uint32_le(s, DRIVE_CAPABILITY_VERSION_02); /* Version */
|
||||||
|
|
||||||
out_uint16_le(s, CAP_SMARTCARD_TYPE); /* CapabilityType */
|
out_uint16_le(s, CAP_SMARTCARD_TYPE); /* CapabilityType */
|
||||||
out_uint16_le(s, 8); /* CapabilityLength */
|
out_uint16_le(s, 8); /* CapabilityLength */
|
||||||
|
15
types.h
15
types.h
@ -3,6 +3,7 @@
|
|||||||
Common data types
|
Common data types
|
||||||
Copyright (C) Matthew Chapman 1999-2008
|
Copyright (C) Matthew Chapman 1999-2008
|
||||||
Copyright 2014 Henrik Andersson <hean01@cendio.se> for Cendio AB
|
Copyright 2014 Henrik Andersson <hean01@cendio.se> for Cendio AB
|
||||||
|
Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -25,6 +26,10 @@ typedef int RD_BOOL;
|
|||||||
#define False (0)
|
#define False (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX 256
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef signed char sint8;
|
typedef signed char sint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
@ -222,6 +227,12 @@ typedef struct rdpdr_device_info
|
|||||||
}
|
}
|
||||||
RDPDR_DEVICE;
|
RDPDR_DEVICE;
|
||||||
|
|
||||||
|
typedef struct rdpdr_disk_device_info
|
||||||
|
{
|
||||||
|
char name[PATH_MAX];
|
||||||
|
}
|
||||||
|
DISK_DEVICE;
|
||||||
|
|
||||||
typedef struct rdpdr_serial_device_info
|
typedef struct rdpdr_serial_device_info
|
||||||
{
|
{
|
||||||
int dtr;
|
int dtr;
|
||||||
@ -276,10 +287,6 @@ typedef struct notify_data
|
|||||||
}
|
}
|
||||||
NOTIFY;
|
NOTIFY;
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
|
||||||
#define PATH_MAX 256
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct fileinfo
|
typedef struct fileinfo
|
||||||
{
|
{
|
||||||
uint32 device_id, flags_and_attributes, accessmask;
|
uint32 device_id, flags_and_attributes, accessmask;
|
||||||
|
Loading…
Reference in New Issue
Block a user