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