Closed chrhuebner closed 1 month ago
The execute permission on the folder containing the file isn't checked properly.
FileSystem fs = MemoryFileSystemBuilder.newEmpty().addFileAttributeView(PosixFileAttributeView.class).setCaseSensitive(true).build(); final Path path = fs.getPath("/", "sub1", "sub2", "test.txt"); final Path parent = path.getParent(); Files.createDirectories(parent); Files.write(path, "Hello World".getBytes(), StandardOpenOption.CREATE_NEW); Files.setPosixFilePermissions(parent, Set.of()); // removes execute permission final byte[] bytes = Files.readAllBytes(path); // Exception expected System.out.println(new String(bytes));
When I remove the permission on sub1 it works - the exception is thrown:
... Files.setPosixFilePermissions(parent.getParent(), Set.of()); // removes execute permission on sub1 ...
The check in https://github.com/marschall/memoryfilesystem/blob/9d9f843e041b7c325ccf416c1e035ece95e2055e/src/main/java/com/github/marschall/memoryfilesystem/MemoryFileSystem.java#L808 should also be done if isLast is true. But now for the current directory.
isLast
It seems as if the execute permission of parent directories are also not checked when files are deleted.
Thanks for reporting, I'll have a look.
I released 2.8.1 to Maven Central which should fix the issue.
The execute permission on the folder containing the file isn't checked properly.
When I remove the permission on sub1 it works - the exception is thrown:
The check in https://github.com/marschall/memoryfilesystem/blob/9d9f843e041b7c325ccf416c1e035ece95e2055e/src/main/java/com/github/marschall/memoryfilesystem/MemoryFileSystem.java#L808 should also be done if
isLast
is true. But now for the current directory.