holdenk opened a new pull request, #59061:
URL: https://github.com/apache/spark/pull/59061
### What changes were proposed in this pull request?
`Utils.chmod700` now makes a single `Files.setPosixFilePermissions(path,
"rwx------")` call on POSIX filesystems, instead of six
`File.setReadable/setWritable/setExecutable` calls.
On non-POSIX filesystems (e.g. Windows) the `File.set*` sequence is kept as
a best-effort, non-atomic fallback, but reordered: all permissions are stripped
first and owner permissions granted after, so the file is locked down as early
as possible and no intermediate state grants group/other access.
Review notes:
- `chmod700` guards the empty path explicitly: `new File("").toPath`
resolves to the process working directory in NIO, and the old `File.set*`
sequence returned `false` for it; the guard preserves that behavior instead of
chmod-ing the cwd.
- A `SecurityException` from the POSIX attempt now becomes `false` (matching
the documented `@return`) instead of propagating; only reachable under a
`SecurityManager` that denies file write.
### Why are the changes needed?
Each `File.set*` call is a non-atomic stat-then-chmod, so concurrent
`chmod700` calls on the same path (e.g. Workers sharing a local root dir in
local-cluster mode) can interleave into a broken permission set. On POSIX
filesystems a single `chmod` is atomic.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Added tests to `UtilsSuite`: concurrent `chmod700` calls on the same path
always leave `rwx------` (POSIX-only), a nonexistent path returns `false`, and
an empty path returns `false`. Ran the full `core` module build and test suite
locally (GREEN).
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor
Made with [Cursor](https://cursor.com)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]