change password to take hashed password

axtloss/rework-partitioning
axtlos 3 years ago
parent 2f9b42e11a
commit ef4159978d
No known key found for this signature in database
GPG Key ID: A468AFD71DD51D4A

@ -9,6 +9,8 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
String::from("-m"), String::from("-m"),
String::from("-s"), String::from("-s"),
String::from("/bin/bash"), String::from("/bin/bash"),
String::from("-p"),
String::from(password),
String::from(username), String::from(username),
], ],
), ),
@ -36,19 +38,6 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
"Add pwfeedback to sudoers", "Add pwfeedback to sudoers",
); );
} }
exec_eval(
exec_chroot(
"bash",
vec![
String::from("-c"),
format!(
r#"'usermod --password $(echo {} | openssl passwd -1 -stdin) {}'"#,
password, username
),
],
),
format!("Set password for user {}", username).as_str(),
);
} }
pub fn root_pass(root_pass: &str) { pub fn root_pass(root_pass: &str) {
@ -58,8 +47,7 @@ pub fn root_pass(root_pass: &str) {
vec![ vec![
String::from("-c"), String::from("-c"),
format!( format!(
r#"'usermod --password $(echo {} | openssl passwd -1 -stdin) root'"#, r#"'usermod --password {root_pass} root'"#
root_pass
), ),
], ],
), ),

@ -119,7 +119,7 @@ fn main() {
) )
.arg( .arg(
Arg::with_name("password") Arg::with_name("password")
.help("The password to set") .help("The password to set. NOTE: Takes hashed password, use `openssl passwd -1 <password>` to generate the hash.")
.required(true), .required(true),
) )
) )
@ -128,7 +128,7 @@ fn main() {
.about("Set the root password") .about("Set the root password")
.arg( .arg(
Arg::with_name("rootPass") Arg::with_name("rootPass")
.help("The root password to set") .help("The password to set. NOTE: Takes hashed password, use `openssl passwd -1 <password>` to generate the hash._")
.required(true), .required(true),
), ),
) )

Loading…
Cancel
Save