GUACAMOLE-249: Use filesystem constants defined by FreeRDP and WinPR headers rather than defining our own.

This commit is contained in:
Michael Jumper 2019-12-27 21:12:18 -08:00
parent 598b86a4cf
commit 6c239a7b98
5 changed files with 30 additions and 85 deletions

View File

@ -100,8 +100,7 @@ void guac_rdpdr_fs_process_create(guac_rdp_common_svc* svc,
if (file != NULL && strcmp(file->absolute_path, "\\") == 0) {
int download_id =
guac_rdp_fs_open((guac_rdp_fs*) device->data, "\\Download",
ACCESS_GENERIC_READ, 0,
DISP_FILE_OPEN_IF, FILE_DIRECTORY_FILE);
GENERIC_READ, 0, FILE_OPEN_IF, FILE_DIRECTORY_FILE);
if (download_id >= 0)
guac_rdp_fs_close((guac_rdp_fs*) device->data, download_id);
@ -460,7 +459,7 @@ void guac_rdpdr_fs_process_query_directory(guac_rdp_common_svc* svc,
/* Open directory entry */
entry_file_id = guac_rdp_fs_open((guac_rdp_fs*) device->data,
entry_path, ACCESS_FILE_READ_DATA, 0, DISP_FILE_OPEN, 0);
entry_path, FILE_READ_DATA, 0, FILE_OPEN, 0);
if (entry_file_id >= 0) {

View File

@ -167,7 +167,7 @@ static void* guac_rdpdr_download_to_owner(guac_user* owner, void* data) {
/* Attempt to open requested file */
char* path = (char*) data;
int file_id = guac_rdp_fs_open(filesystem, path,
ACCESS_FILE_READ_DATA, 0, DISP_FILE_OPEN, 0);
FILE_READ_DATA, 0, FILE_OPEN, 0);
/* If file opened successfully, start stream */
if (file_id >= 0) {

View File

@ -244,16 +244,16 @@ int guac_rdp_fs_open(guac_rdp_fs* fs, const char* path,
}
/* Translate access into flags */
if (access & ACCESS_GENERIC_ALL)
if (access & GENERIC_ALL)
flags = O_RDWR;
else if ((access & ( ACCESS_GENERIC_WRITE
| ACCESS_FILE_WRITE_DATA
| ACCESS_FILE_APPEND_DATA))
&& (access & (ACCESS_GENERIC_READ | ACCESS_FILE_READ_DATA)))
else if ((access & ( GENERIC_WRITE
| FILE_WRITE_DATA
| FILE_APPEND_DATA))
&& (access & (GENERIC_READ | FILE_READ_DATA)))
flags = O_RDWR;
else if (access & ( ACCESS_GENERIC_WRITE
| ACCESS_FILE_WRITE_DATA
| ACCESS_FILE_APPEND_DATA))
else if (access & ( GENERIC_WRITE
| FILE_WRITE_DATA
| FILE_APPEND_DATA))
flags = O_WRONLY;
else
flags = O_RDONLY;
@ -279,32 +279,32 @@ int guac_rdp_fs_open(guac_rdp_fs* fs, const char* path,
switch (create_disposition) {
/* Create if not exist, fail otherwise */
case DISP_FILE_CREATE:
case FILE_CREATE:
flags |= O_CREAT | O_EXCL;
break;
/* Open file if exists and do not overwrite, fail otherwise */
case DISP_FILE_OPEN:
case FILE_OPEN:
/* No flag necessary - default functionality of open */
break;
/* Open if exists, create otherwise */
case DISP_FILE_OPEN_IF:
case FILE_OPEN_IF:
flags |= O_CREAT;
break;
/* Overwrite if exists, fail otherwise */
case DISP_FILE_OVERWRITE:
case FILE_OVERWRITE:
flags |= O_TRUNC;
break;
/* Overwrite if exists, create otherwise */
case DISP_FILE_OVERWRITE_IF:
case FILE_OVERWRITE_IF:
flags |= O_CREAT | O_TRUNC;
break;
/* Supersede (replace) if exists, otherwise create */
case DISP_FILE_SUPERSEDE:
case FILE_SUPERSEDE:
unlink(real_path);
flags |= O_CREAT | O_TRUNC;
break;

View File

@ -108,59 +108,6 @@
*/
#define GUAC_RDP_FS_ENOTSUP -10
/*
* Access constants.
*/
#define ACCESS_GENERIC_READ 0x80000000
#define ACCESS_GENERIC_WRITE 0x40000000
#define ACCESS_GENERIC_ALL 0x10000000
#define ACCESS_FILE_READ_DATA 0x00000001
#define ACCESS_FILE_WRITE_DATA 0x00000002
#define ACCESS_FILE_APPEND_DATA 0x00000004
#define ACCESS_DELETE 0x00010000
/*
* Create disposition constants.
*/
#define DISP_FILE_SUPERSEDE 0x00000000
#define DISP_FILE_OPEN 0x00000001
#define DISP_FILE_CREATE 0x00000002
#define DISP_FILE_OPEN_IF 0x00000003
#define DISP_FILE_OVERWRITE 0x00000004
#define DISP_FILE_OVERWRITE_IF 0x00000005
/*
* File attributes.
*/
#define FILE_ATTRIBUTE_READONLY 0x00000001
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define FILE_ATTRIBUTE_NORMAL 0x00000080
/*
* Filesystem attributes.
*/
#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
#define FILE_CASE_PRESERVED_NAMES 0x00000002
#define FILE_UNICODE_ON_DISK 0x00000004
/*
* File create options.
*/
#define FILE_DIRECTORY_FILE 0x00000001
#define FILE_NON_DIRECTORY_FILE 0x00000040
/*
* File device types.
*/
#define FILE_DEVICE_DISK 0x00000007
#define SEC_TO_UNIX_EPOCH 11644473600
/**
@ -425,10 +372,10 @@ int guac_rdp_fs_get_status(int err);
* The absolute path to the file within the simulated filesystem.
*
* @param access
* A bitwise-OR of various RDPDR access flags, such as ACCESS_GENERIC_ALL
* or ACCESS_GENERIC_WRITE. This value will ultimately be translated to a
* standard O_RDWR, O_WRONLY, etc. value when opening the real file on the
* local filesystem.
* A bitwise-OR of various RDPDR access flags, such as GENERIC_ALL or
* GENERIC_WRITE. This value will ultimately be translated to a standard
* O_RDWR, O_WRONLY, etc. value when opening the real file on the local
* filesystem.
*
* @param file_attributes
* The attributes to apply to the file, if created. This parameter is
@ -436,9 +383,9 @@ int guac_rdp_fs_get_status(int err);
*
* @param create_disposition
* Any one of several RDPDR file creation dispositions, such as
* DISP_FILE_CREATE, DISP_FILE_OPEN_IF, etc. The creation disposition
* dictates whether a new file should be created, whether the file can
* already exist, whether existing contents should be truncated, etc.
* FILE_CREATE, FILE_OPEN_IF, etc. The creation disposition dictates
* whether a new file should be created, whether the file can already
* exist, whether existing contents should be truncated, etc.
*
* @param create_options
* A bitwise-OR of various RDPDR options dictating how a file is to be

View File

@ -90,8 +90,8 @@ int guac_rdp_upload_file_handler(guac_user* user, guac_stream* stream,
__generate_upload_path(filename, file_path);
/* Open file */
file_id = guac_rdp_fs_open(fs, file_path, ACCESS_GENERIC_WRITE, 0,
DISP_FILE_OVERWRITE_IF, 0);
file_id = guac_rdp_fs_open(fs, file_path, GENERIC_WRITE, 0,
FILE_OVERWRITE_IF, 0);
if (file_id < 0) {
guac_protocol_send_ack(user->socket, stream, "FAIL (CANNOT OPEN)",
GUAC_PROTOCOL_STATUS_CLIENT_FORBIDDEN);
@ -293,7 +293,7 @@ int guac_rdp_ls_ack_handler(guac_user* user, guac_stream* stream,
/* Attempt to open file to determine type */
int file_id = guac_rdp_fs_open(rdp_stream->ls_status.fs, absolute_path,
ACCESS_GENERIC_READ, 0, DISP_FILE_OPEN, 0);
GENERIC_READ, 0, FILE_OPEN, 0);
if (file_id < 0)
continue;
@ -359,8 +359,7 @@ int guac_rdp_download_get_handler(guac_user* user, guac_object* object,
return 0;
/* Attempt to open file for reading */
int file_id = guac_rdp_fs_open(fs, name, ACCESS_GENERIC_READ, 0,
DISP_FILE_OPEN, 0);
int file_id = guac_rdp_fs_open(fs, name, GENERIC_READ, 0, FILE_OPEN, 0);
if (file_id < 0) {
guac_user_log(user, GUAC_LOG_INFO, "Unable to read file \"%s\"",
name);
@ -442,8 +441,8 @@ int guac_rdp_upload_put_handler(guac_user* user, guac_object* object,
}
/* Open file */
int file_id = guac_rdp_fs_open(fs, name, ACCESS_GENERIC_WRITE, 0,
DISP_FILE_OVERWRITE_IF, 0);
int file_id = guac_rdp_fs_open(fs, name, GENERIC_WRITE, 0,
FILE_OVERWRITE_IF, 0);
/* Abort on failure */
if (file_id < 0) {