Only complain about EEXIST for mkdir() if O_EXCL is set. Directory creation open should use ACCESS_GENERIC_READ (anything with WRITE will fail).

This commit is contained in:
Michael Jumper 2013-11-06 15:58:16 -08:00
parent 96637b5d19
commit 1570072b46

View File

@ -219,7 +219,7 @@ int guac_rdp_fs_open(guac_rdp_fs* fs, const char* path,
if (strncmp(normalized_path, "\\Outbox\\", 8) == 0) { if (strncmp(normalized_path, "\\Outbox\\", 8) == 0) {
/* Ensure \Sent exists */ /* Ensure \Sent exists */
int sent_id = guac_rdp_fs_open(fs, "\\Sent", ACCESS_GENERIC_ALL, 0, int sent_id = guac_rdp_fs_open(fs, "\\Sent", ACCESS_GENERIC_READ, 0,
DISP_FILE_OPEN_IF, FILE_DIRECTORY_FILE); DISP_FILE_OPEN_IF, FILE_DIRECTORY_FILE);
if (sent_id < 0) if (sent_id < 0)
return sent_id; return sent_id;
@ -287,9 +287,11 @@ int guac_rdp_fs_open(guac_rdp_fs* fs, const char* path,
if ((create_options & FILE_DIRECTORY_FILE) && (flags & O_CREAT)) { if ((create_options & FILE_DIRECTORY_FILE) && (flags & O_CREAT)) {
if (mkdir(real_path, S_IRWXU)) { if (mkdir(real_path, S_IRWXU)) {
if (errno != EEXIST || (flags & O_EXCL)) {
GUAC_RDP_DEBUG(1, "mkdir() failed: %s", strerror(errno)); GUAC_RDP_DEBUG(1, "mkdir() failed: %s", strerror(errno));
return guac_rdp_fs_get_errorcode(errno); return guac_rdp_fs_get_errorcode(errno);
} }
}
/* Unset O_CREAT and O_EXCL as directory must exist before open() */ /* Unset O_CREAT and O_EXCL as directory must exist before open() */
flags &= ~(O_CREAT | O_EXCL); flags &= ~(O_CREAT | O_EXCL);