Before this patch, the test in `testExtractToReadOnlyDir()`, which
validates whether making jimage extract to a read-only directory results
in a failure, denied creating files but it did not deny creating
subdirectories.  Although this does make jimage fail (and consequently,
make the test pass), this isn't completely correct for two reasons.

First, the test invocation ends up writing a series of empty
subdirectories, when in reality we don't want the destination directory
to be modified at all.  Second, and more importantly, this leaves these
directories in a state where Cygwin cannot remove them (see JBS issue
for more details).

This patch fixes the problem by adding `APPEND_DATA` to the deny list,
thus prohibiting the principal running the test from creating both files
as well as directories.  This effectively sidesteps the issue of leaving
broken directories on disk.

See
https://learn.microsoft.com/en-us/windows/win32/fileio/file-access-rights-constants
for details about the file permissions, reproduced in part below:

> FILE_WRITE_DATA: For a directory object, the right to create a file in
the directory.
>
> FILE_APPEND_DATA: For a directory object, the right to create a
subdirectory.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - Deny creating both files and subdirectories in testExtractToReadOnlyDir

Changes: https://git.openjdk.org/jdk/pull/31646/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=31646&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8387188
  Stats: 3 lines in 1 file changed: 1 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/31646.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/31646/head:pull/31646

PR: https://git.openjdk.org/jdk/pull/31646

Reply via email to