Uh oh!
There was an error while loading. Please reload this page.
fs::copy() linux: handle sparse files and set file mode early - #58636
fs::copy() linux: handle sparse files and set file mode early#58636haraldh wants to merge 1 commit into
Conversation
rust-highfive
commented
Feb 22, 2019
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
d9df8b9 to
58e4ee2CompareA convenience method like fs::copy() should try to prevent pitfalls a normal user doesn't think about. In case of an empty umask, setting the file mode early prevents temporarily world readable or even writeable files, because the default mode is 0o666. In case the target is a named pipe or special device node, setting the file mode can lead to unwanted side effects, like setting permissons on `/dev/stdout` or for root setting permissions on `/dev/null`. Not handling sparse files could fill up the users disk very quickly. Fixes: rust-lang#26933rust-lang#37885rust-lang#58635
mattico
commented
Feb 26, 2019
Rust doesn't support kernels older than 2.6 (https://forge.rust-lang.org/platform-support.html). I don't object to the check being there but something else is likely to break before anyone gets to this code. |
Centril
commented
Feb 26, 2019
alexcrichton
commented
Feb 27, 2019
Thanks for the PR! We actually had a different request for this as well recently, but I think the verdict is still the same as before. We're not currently in a position to maintain complicated maintenance of file copying to this degree. This sort of algorithm would be perfect for crates.io, however! Would you be ok to slim down this PR to just the bug fixes aside from the sparse file handling? |
If handling sparse files is out of scope by design then it should probably be mentioned in |
haraldh
commented
Feb 28, 2019
Fix for the non-sparse version: |
gnzlbg
commented
Feb 28, 2019
Would it help if this PR would add a test to prevent this from breaking again? |
bors
commented
Feb 28, 2019
☔ The latest upstream changes (presumably #58208) made this pull request unmergeable. Please resolve the merge conflicts. |
alexcrichton
commented
Feb 28, 2019
haraldh
commented
Mar 1, 2019
@alexcrichton yeah, close this, if sparse files won't be handled. |
alexcrichton
commented
Mar 1, 2019
Ok! |
A convenience method like fs::copy() should try to prevent pitfalls a
normal user doesn't think about.
In case of an empty umask, setting the file mode early prevents
temporarily world readable or even writeable files,
because the default mode is 0o666.
In case the target is a named pipe or special device node, setting the
file mode can lead to unwanted side effects, like setting permissons on
/dev/stdoutor for root setting permissions on/dev/null.Not handling sparse files could fill up the users disk very quickly.
Fixes:
#26933
#37885
#58635