Crate shadow

Source
Expand description

This modules provides a wrapper around the libc functions in shadow.h for handling the /etc/shadow file, which stores encrypted password for users.

It should work under Linux and some other Unix variants. Root permission is necessary to access the shadow file.

Since the relevant functions in libc are not thread-safe, this library is not either.

§Examples

Print all shadow entries:

for i in shadow::Shadow::iter_all() {
    println!("{:?}", i);
}

Verify password is correct (requires pwhash):

let hash = shadow::Shadow::from_name("username").unwrap();
let correct = pwhash::unix::verify("password", &hash.password);
println!("Password correct: {}", correct); 

Structs§

Shadow
Represents an entry in /etc/shadow
ShadowIter
Iterator over Shadow entries