RFR: 8357425: (fs) SecureDirectoryStream setPermissions should use fchmodat
Alan Bateman
alanb at openjdk.org
Fri May 30 05:37:51 UTC 2025
On Thu, 29 May 2025 23:37:26 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Modify to use the `fchmodat(2)` system call to set permissions where possible to do so. This fixes the problem presented in the issue description.
src/java.base/unix/classes/sun/nio/fs/UnixSecureDirectoryStream.java line 423:
> 421: else if (fchmodatNoFollowSupported())
> 422: fchmodat(dfd, file, UnixFileModeAttribute.toUnixMode(perms),
> 423: AT_SYMLINK_NOFOLLOW);
The 4 cases look okay. If you adds`int mode = UnixFileModeAttribute.toUnixMode(perms)` then it would avoid the repeated code and avoid the line splits, just makes it easier to read.
src/java.base/unix/classes/sun/nio/fs/UnixSecureDirectoryStream.java line 434:
> 432: }
> 433: } catch (UnixException x) {
> 434: x.rethrowAsIOException(file);
'file' will be null when changing the directory's permission, can you double check that case?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25534#discussion_r2115172005
PR Review Comment: https://git.openjdk.org/jdk/pull/25534#discussion_r2115172441
More information about the nio-dev
mailing list