RFR: 8073061: (fs) Files.copy(foo, bar, REPLACE_EXISTING) deletes bar even if foo is not readable [v6]

Brian Burkhalter bpb at openjdk.org
Thu Sep 21 18:00:51 UTC 2023


On Sun, 17 Sep 2023 08:18:56 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8073061: Tweak CopyMoveHelper.copyToForeignTarget
>
> test/jdk/java/nio/file/Files/CopyMoveVariations.java line 135:
> 
>> 133:                     Files.setPosixFilePermissions(linkTarget, perms);
>> 134:                 else
>> 135:                     Files.setPosixFilePermissions(source, perms);
> 
> Should this be expanded to cover the permissions of the directory containing the source file, that's the case where the access(2) call may fail because the directory can't be updated.

>From what I can tell, `access(source, R_OK)` will fail if the parent directory does not confer adequate permissions to read the file. I would think it would be the parent directory of the target which would need to be checked.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15501#discussion_r1329050142


More information about the nio-dev mailing list