temp #2
@ -3,7 +3,12 @@ extern crate lazy_static;
|
||||
|
||||
extern crate log;
|
||||
|
||||
pub mod api;
|
||||
pub mod group;
|
||||
pub mod passwd;
|
||||
pub mod shadow;
|
||||
pub mod userlib;
|
||||
pub mod userlib_error;
|
||||
pub use group::Group;
|
||||
pub use passwd::{Gecos, Gid, HomeDir, Passwd, Password, ShellPath, Uid, Username};
|
||||
pub use shadow::Shadow;
|
||||
|
@ -57,6 +57,7 @@ impl<'a> TryFrom<&'a str> for Username<'a> {
|
||||
pub enum Password<'a> {
|
||||
Encrypted(EncryptedPassword<'a>),
|
||||
Shadow(crate::shadow::Shadow<'a>),
|
||||
Disabled,
|
||||
}
|
||||
|
||||
impl Display for Password<'_> {
|
||||
@ -64,6 +65,7 @@ impl Display for Password<'_> {
|
||||
match self {
|
||||
Password::Encrypted(EncryptedPassword { password }) => write!(f, "{}", password,),
|
||||
Password::Shadow(_) => write!(f, "x"),
|
||||
Password::Disabled => write!(f, "x"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -380,6 +382,7 @@ impl<'a> Passwd<'a> {
|
||||
match self.password {
|
||||
Password::Encrypted(EncryptedPassword { password }) => password,
|
||||
Password::Shadow(crate::shadow::Shadow { ref password, .. }) => password.password,
|
||||
Password::Disabled => "x",
|
||||
}
|
||||
}
|
||||
#[must_use]
|
||||
|
@ -122,6 +122,7 @@ impl<'a> Shadow<'a> {
|
||||
}
|
||||
|
||||
const SECONDS_PER_DAY: i64 = 86400;
|
||||
|
||||
fn date_since_epoch(days_since_epoch: &str) -> Option<chrono::NaiveDateTime> {
|
||||
if days_since_epoch.is_empty() {
|
||||
None
|
||||
@ -141,7 +142,7 @@ fn duration_for_days(days_source: &str) -> Option<chrono::Duration> {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_since_epoch() {
|
||||
fn test_parse_and_back_identity() {
|
||||
println!("Test");
|
||||
let line = "test:!!$6$/RotIe4VZzzAun4W$7YUONvru1rDnllN5TvrnOMsWUD5wSDUPAD6t6/Xwsr/0QOuWF3HcfAhypRkGa8G1B9qqWV5kZSnCb8GKMN9N61:18260:0:99999:7:::";
|
||||
let line2 = Shadow::new_from_string(line).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user