[ijent] IJPL-171863: Make posix files writeable on Windows if they are accessed under root

(cherry picked from commit dfe7efa7d4d3a5f471d1e5b8d338ea017ebcd145)

IJ-CR-150391

GitOrigin-RevId: ca555716293df310ec2301c8340dde55998e7637
This commit is contained in:
Konstantin.Nisht
2024-11-21 12:45:30 +01:00
committed by intellij-monorepo-bot
parent 8b8c09642f
commit e25c31ab11
2 changed files with 5 additions and 0 deletions

View File

@@ -414,6 +414,10 @@ class IjentNioPosixFileAttributesWithDosAdapter(
val owner = owner()
val group = group()
return when {
userInfo.uid == 0 && owner is EelPosixUserPrincipal && owner.uid != 0 ->
// on unix, root can read everything except the files that they forbid for themselves
isDirectory
owner is EelPosixUserPrincipal && owner.uid == userInfo.uid ->
OWNER_WRITE !in permissions() || (isDirectory && OWNER_EXECUTE !in permissions())

View File

@@ -211,6 +211,7 @@ public final class FileAttributes {
boolean isHidden = false;
boolean isWritable = false;
// TODO KN: We should look at the OS of a Path, not at the OS of the IDE.
if (SystemInfo.isWindows) {
isHidden = path.getParent() != null && ((DosFileAttributes)attrs).isHidden();
isWritable = attrs.isDirectory() || !((DosFileAttributes)attrs).isReadOnly();