Fix #36601: Set proper file permissions for results-generic.bin on POSIX systems#36708
Conversation
|
@octylFractal I've implemented the fix based on your suggestion in #36601 — replaced the Could you take a look when you get a chance? Thanks! |
|
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. |
|
Thanks for the review @octylFractal ! All feedback addressed
|
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 <[email protected]>
Verify that all files in the binary test results directory have group-read and others-read permissions on POSIX systems. Signed-off-by: CHANHAN <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Updated the temporary results file path logic to use Path.resolveSibling() instead of getParent().resolve() based on code review feedback. Signed-off-by: CHANHAN <[email protected]>
|
Thank you for your contribution! |
|
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! |
Fixes #36601
Since Gradle 9.3.0,
results-generic.binis created with owner-only permissions (-rw-------) on POSIX systems, while other files in the same directory likeoutput-events.bincorrectly respect the system umask.The cause was
SerializableTestResultStore.WriterusingFiles.createTempFile()+Files.move().createTempFile()defaults to 600 permissions on POSIX, andmove()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
AbstractTestTaskIntegrationTestto verify that all binary test result files have group-read and others-read permissions on POSIX systems.