cargo add
changes file permissions of Cargo.toml
to 600
#13896
Labels
A-filesystem
Area: issues with filesystems
C-bug
Category: bug
Command-add
Command-remove
S-accepted
Status: Issue or feature is accepted, and has a team member available to help mentor or review
Problem
When you run
cargo add
, it changes the file permissions ofCargo.toml
to 600 (user read+write only). This is a little bit painful when you're building the code as a different user than the user writing the code, for example if you're running the code in a container. This applies tocargo remove
as well. I tested this behaviour on Cargo 1.78.0 and nightly.Steps
Possible Solution(s)
I'm guessing that Cargo replaces the existing file with a new file, and this is why the permissions change. In this case, I think it would be better to create the file with the original user/group/world permissions (ignoring things like suid permissions), ideally bypassing the umask as well.
Edit: It appears to use the tempfile crate, which uses 600 by default on Linux.
cargo/crates/cargo-util/src/paths.rs
Lines 186 to 194 in 4de0094
Notes
No response
Version
The text was updated successfully, but these errors were encountered: