Skip to content
Snippets Groups Projects
Commit 5b941f33 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Brad King
Browse files

SystemTools: Adapt permissions test to MSYS

Cygwin/MSYS uses umask on *stat* when noacl is set on the filesystem
(which MSYS sets by default), so the returned permissions don't
necessarily reflect what was actually set.

Solve by delaying umask to where it is actually needed.
parent f00dd83e
No related branches found
No related tags found
1 merge request!211SystemTools: Adapt test to MSYS
......@@ -292,14 +292,15 @@ static bool CheckFileOperations()
std::cerr << std::oct;
// Reset umask
#if defined(_WIN32) && !defined(__CYGWIN__)
#ifdef __MSYS__
mode_t fullMask = S_IWRITE;
#elif defined(_WIN32) && !defined(__CYGWIN__)
// NOTE: Windows doesn't support toggling _S_IREAD.
mode_t fullMask = _S_IWRITE;
#else
// On a normal POSIX platform, we can toggle all permissions.
mode_t fullMask = S_IRWXU | S_IRWXG | S_IRWXO;
#endif
mode_t orig_umask = umask(fullMask);
// Test file permissions without umask
mode_t origPerm, thisPerm;
......@@ -371,6 +372,7 @@ static bool CheckFileOperations()
res = false;
}
mode_t orig_umask = umask(fullMask);
// Test setting file permissions while honoring umask
if (!kwsys::SystemTools::SetPermissions(testNewFile, fullMask, true)) {
std::cerr << "Problem with SetPermissions (3) for: " << testNewFile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment