Parsing the passwd file

This commit is contained in:
2020-09-21 09:05:38 +02:00
commit cd19cb7115
6 changed files with 242 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
extern crate adduser;
use adduser::passwd::Passwd;
use std::fs::File;
use std::io::{self, prelude::*, BufReader};
fn main() {
let mut file = File::open("/etc/passwd").unwrap();
let reader = BufReader::new(file);
for line in reader.lines() {
println!("{}", Passwd::new_from_string(&line.unwrap()).unwrap());
}
// let pwd = Passwd::default();
// let pwd2 =
// Passwd::new_from_string("howdy:notencrypted:1001:1001:not done:/home/test:/bin/bash");
// println!("Test struct: {}", pwd);
// assert_eq!(pwd, pwd2.unwrap())
}