Skip to content

Commit f1e4c85

Browse files
author
Árni Dagur
committed
Add safety disclaimer for ::from_name() also
1 parent d9b04c5 commit f1e4c85

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/shadow.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ impl From<&libc::spwd> for Shadow {
101101

102102
impl Shadow {
103103
/// Gets a [`Shadow`] entry for the given username, or returns [`None`].
104+
///
105+
/// # Safety
106+
/// Care should be taken when this function is used in different threads
107+
/// without synchronization. This is because the underlying function used
108+
/// ([`getspnam()`][1]) is not thread safe.
109+
///
110+
/// [1]: http://man7.org/linux/man-pages/man3/shadow.3.html
104111
pub fn from_name(user: &str) -> Option<Shadow> {
105112
let c_user = CString::new(user).unwrap();
106113

0 commit comments

Comments
 (0)