ogham / rust-users

Library for Unix users and groups in Rust.
https://crates.io/crates/users
MIT License
99 stars 37 forks source link

Please use thread-safe (_r) versions of getpwent #34

Closed fabianfreyer closed 5 years ago

fabianfreyer commented 5 years ago

Please use getpwnam_r, getpwuid_r, getgrgid_r and getgrnam_r etc. instead of the non-threadsafe versions. The non-threadsafe versions can cause issues such as https://github.com/fubarnetes/rctl/issues/1 (See e.g. https://github.com/fubarnetes/rctl/pull/5 for an example how to use the threadsafe functions).

ogham commented 5 years ago

Thanks for pointing this out. In commits https://github.com/ogham/rust-users/compare/12b517283cd57e42d9d79160cae7b5a40612c974...5bda684ad2911d0f05823b293ba93251c01ba527 I change all the functions to use the _r variants.

(With the exception of all_users, which doesn’t use getpwent_r because only one instance of that function should be running at a time anyway.)