Skip to content

Fix #36601: Set proper file permissions for results-generic.bin on POSIX systems#36708

Merged
cobexer merged 6 commits intogradle:masterfrom
chanani:gh-36601
Feb 20, 2026
Merged

Fix #36601: Set proper file permissions for results-generic.bin on POSIX systems#36708
cobexer merged 6 commits intogradle:masterfrom
chanani:gh-36601

Conversation

@chanani
Copy link
Copy Markdown
Contributor

@chanani chanani commented Feb 12, 2026

Fixes #36601

Since Gradle 9.3.0, results-generic.bin is created with owner-only permissions (-rw-------) on POSIX systems, while other files in the same directory like output-events.bin correctly respect the system umask.

The cause was SerializableTestResultStore.Writer using Files.createTempFile() + Files.move(). createTempFile() defaults to 600 permissions on POSIX, and move() preserves them.

This PR replaces that pattern with a direct Files.newOutputStream() write, which naturally follows the system umask.

An integration test was added in AbstractTestTaskIntegrationTest to verify that all binary test result files have group-read and others-read permissions on POSIX systems.

@chanani chanani requested review from a team as code owners February 12, 2026 05:04
@chanani chanani requested a review from tresat February 12, 2026 05:04
@bot-gradle bot-gradle added from:contributor PR by an external contributor to-triage labels Feb 12, 2026
@chanani
Copy link
Copy Markdown
Contributor Author

chanani commented Feb 12, 2026

@octylFractal I've implemented the fix based on your suggestion in #36601 — replaced the Files.createTempFile() + Files.move() pattern with a direct Files.newOutputStream() write, and added an integration test in AbstractTestTaskIntegrationTest as you recommended.

Could you take a look when you get a chance? Thanks!

@tresat tresat requested review from octylFractal and removed request for tresat February 12, 2026 12:33
@ov7a
Copy link
Copy Markdown
Member

ov7a commented Feb 12, 2026

Thank you for your proposed contribution!

This PR has a valid DCO and tests. The relevant team for this area will confirm the design of the implementation choices.

@ov7a ov7a added 👋 team-triage Issues that need to be triaged by a specific team in:testing and removed to-triage labels Feb 12, 2026
@chanani
Copy link
Copy Markdown
Contributor Author

chanani commented Feb 18, 2026

Thanks for the review @octylFractal ! All feedback addressed

  • Moved permission test above private methods.
  • Replaced listFiles() with Files.walk() for full directory traversal.
  • Removed NioFiles alias, using fully-qualified java.nio.file.Files.
  • UnitTestPreconditions.FilePermissions already excludes Windows (MacOs || Linux only), so no additional guard needed.
  • Replaced createTempFile() with fixed-name in-progress-results-generic.bin via newOutputStream() — umask respected, temp file + move pattern preserved.

@big-guy big-guy added this to the 9.5.0 RC1 milestone Feb 18, 2026
@big-guy big-guy removed the 👋 team-triage Issues that need to be triaged by a specific team label Feb 18, 2026
Files.createTempFile() creates files with owner-only permissions (600)
on POSIX systems. When moved to the final results-generic.bin location,
these restrictive permissions were preserved, unlike other output files.

Remove the temporary file pattern and write directly to the target file
via Files.newOutputStream(), which respects the system umask.

Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
Verify that all files in the binary test results directory have
group-read and others-read permissions on POSIX systems.

Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
Reorder 'binary test result files have correct permissions' test to appear
before private utility methods in AbstractTestTaskIntegrationTest,
following Spock test class conventions.

Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
Replace listFiles() with Files.walk() to validate permissions for all
files including subdirectories. Remove NioFiles import alias and use
java.nio.file.Files fully-qualified name for better readability outside IDE.

Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
Replace Files.createTempFile() with a fixed-name in-progress file
written via Files.newOutputStream() to respect system umask, while
preserving the temporary file + move pattern to avoid leaving
incomplete results on write failure.

Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
Updated the temporary results file path logic to use Path.resolveSibling() instead of getParent().resolve() based on code review feedback.

Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
@octylFractal
Copy link
Copy Markdown
Member

Thank you for your contribution!

@octylFractal octylFractal added this pull request to the merge queue Feb 19, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 19, 2026
@chanani
Copy link
Copy Markdown
Contributor Author

chanani commented Feb 20, 2026

Hi @octylFractal, it looks like this PR was removed from the merge queue due to some failed TeamCity checks earlier. However, all 17 checks are passing now and there are no conflicts with the base branch.

Could you please re-add this to the merge queue when you have a chance? I believe the previous failure was just a transient CI issue rather than something caused by the changes in this PR. Thanks!

@octylFractal octylFractal added this pull request to the merge queue Feb 20, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 20, 2026
@cobexer cobexer added this pull request to the merge queue Feb 20, 2026
Merged via the queue into gradle:master with commit 6afc9ed Feb 20, 2026
17 checks passed
@chanani chanani deleted the gh-36601 branch February 20, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:contributor PR by an external contributor in:testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gradle 9.3.x generates results-generic.bin with wrong permssions

7 participants