diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c index 446792c9..05401f97 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c @@ -257,11 +257,16 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path, } /* Create directory first, if necessary */ - if (file_attributes & FILE_ATTRIBUTE_DIRECTORY && (flags & O_CREAT)) { + if ((create_options & FILE_DIRECTORY_FILE) && (flags & O_CREAT)) { + if (mkdir(real_path, S_IRWXU)) { GUAC_RDP_DEBUG(1, "mkdir() failed: %s", strerror(errno)); return guac_rdpdr_fs_get_errorcode(errno); } + + /* Unset O_CREAT and O_EXCL as directory must exist before open() */ + flags &= ~(O_CREAT | O_EXCL); + } /* Open file */ diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h index ecba92f3..c551d2cd 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h @@ -175,6 +175,13 @@ #define FILE_UNICODE_ON_DISK 0x00000004 +/* + * File create options. + */ + +#define FILE_DIRECTORY_FILE 0x00000001 +#define FILE_NON_DIRECTORY_FILE 0x00000040 + #define SEC_TO_UNIX_EPOCH 11644473600 /**