From 7eba5709baa65bcc34ac444f7b79909c55908909 Mon Sep 17 00:00:00 2001 From: amy Date: Sun, 23 Jan 2022 18:53:21 +0100 Subject: [PATCH] a third attempt at setting the password --- src/functions/users.rs | 14 ++++---------- src/main.rs | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/functions/users.rs b/src/functions/users.rs index 94e67cf..129e97f 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -56,16 +56,10 @@ pub fn root_pass(root_pass: &str) { "bash", vec![ String::from("-c"), - String::from("'usermod"), - String::from("--password"), - String::from("$(echo"), - String::from(root_pass), - String::from("|"), - String::from("openssl"), - String::from("passwd"), - String::from("-1"), - String::from("-stdin)"), - String::from("root'"), + format!( + "'usermod --password $(echo {} | openssl passwd -1 -stdin) root'", + root_pass + ), ], ), "set root password", diff --git a/src/main.rs b/src/main.rs index 18dfd88..13230a8 100755 --- a/src/main.rs +++ b/src/main.rs @@ -179,8 +179,6 @@ fn main() { app.value_of("password").unwrap(), ); } else if let Some(app) = app.subcommand_matches("rootPass") { - let rootpass = app.value_of("rootPass").unwrap(); - println!("{}", rootpass); users::root_pass(app.value_of("rootPass").unwrap()); } } else if let Some(app) = app.subcommand_matches("desktops") {