Reduce use of `unsafe` by using `libc` crate
martinvonz opened this issue · 3 comments
I see that whoami
used to depend on libc
until commit 12d9910, but the commit doesn't explain why. Are you open to a PR that adds back a dependency on libc
to avoid unsafe
and reimplementations of its functions?
The original reason was so that whoami has no dependencies outside of std
. Which admittedly may not be the best reason. I am not super happy with the idea of adding libc
as a dependency, since they don't have a policy for MSRV yet (although this is already a problem with the required dependencies on wasm):
The minimum supported Rust toolchain version is currently Rust 1.13.0. (libc does not currently have any policy regarding changes to the minimum supported Rust version; such policy is a work in progress.)
That said, I don't expect libc's MSRV to exceed 1.40.0 before I'll stop updating/supporting the 1.0.0 track (2018 edition) and only update the 2.0.0 track (2021 edition) in 2024.
Also, adding libc
as a dependency would not get rid of unsafe
. That would require a dependency on nix
, but that would have to be whoami version 2.0.0, since whoami doesn't upgrade MSRV without a major version bump. I'm a bit hesitant to add that crate as well, since it would increase the amount of maintenance I have to do on this crate (for every minor version bump, and quickly for security vulnerabilities found in that crate/dependencies that require a minor version bump - which could bump MSRV).
Okay, it sounds like we'll have to live with the unsafe
blocks then. Feel free to close.
Might revisit using nix
in the future, but closing for now.