From 00dc153637109b8d601c2bd705d68d0ecc920935 Mon Sep 17 00:00:00 2001 From: Koundinya Veluri Date: Tue, 8 Aug 2023 11:34:32 -0700 Subject: [PATCH] Restore a change to improve backward compatibility --- src/coreclr/pal/src/sharedmemory/sharedmemory.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp b/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp index 9d7581788e9d6..a2342f23efa5c 100644 --- a/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp +++ b/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp @@ -188,7 +188,12 @@ bool SharedMemoryHelpers::EnsureDirectoryExists( } if (!createIfNotExist || chmod(path, PermissionsMask_AllUsers_ReadWriteExecute) != 0) { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); + // We were not asked to create the path or we weren't able to set the new permissions. + // As a last resort, check that at least the current user has full access. + if ((statInfo.st_mode & PermissionsMask_CurrentUser_ReadWriteExecute) != PermissionsMask_CurrentUser_ReadWriteExecute) + { + throw SharedMemoryException(static_cast(SharedMemoryError::IO)); + } } return true; }