I'm writing a cli-tool to automate the archlinux installation, that is based on toml config files.
Currently i have this problem: Once the base system is installed and configured, the next topic is creating the users and set their passwords.
Like this:
passwd $user
And this needs to get the password as prompt input
New password:
I'm trying make something like this with rust:
use std::process::Command;
struct User {
....
username: String
pwd: String
}
...
fn set_pwd(self) -> Result<()> {
Command::new("chroot")
.arg("/mnt")
.arg("passwd")
.arg(self.username)
.spawn()
}
...
The problem is that I don't understand, how to pass the password as prompt input to the bash process.
Update:
This question https://stackoverflow.coam/questions/21615188/how-to-send-input-to-a-program-through-stdin-in-rust is something similar, but the implementation is a little different. Because it is a version of the standard library from some time ago.