28 lines
793 B
Rust
28 lines
793 B
Rust
use crate::{config::UserConfig, print_status, run_command};
|
|
|
|
use super::str_vec;
|
|
|
|
pub fn setup_users(conf: &[UserConfig]) {
|
|
let mut doas_conf = String::new();
|
|
|
|
for user in conf {
|
|
run_command(
|
|
&str_vec(vec!["arch-chroot", "/mnt", "useradd", "-m", &user.name]),
|
|
None,
|
|
false,
|
|
);
|
|
|
|
run_command(
|
|
&str_vec(vec!["arch-chroot", "/mnt", "passwd", &user.name]),
|
|
Some(&format!("{}\n{}\n", user.password, user.password)),
|
|
false,
|
|
);
|
|
|
|
if user.doas_root {
|
|
print_status(&format!("Allowing root doas for {}", user.name));
|
|
doas_conf.push_str(&format!("permit {} as root\n", user.name));
|
|
}
|
|
}
|
|
|
|
std::fs::write("/mnt/etc/doas.conf", doas_conf).unwrap();
|
|
}
|