wheel group

This commit is contained in:
JMARyA 2025-01-10 09:28:03 +01:00
parent 33a8fed192
commit 05cf6cf9da
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 20 additions and 17 deletions

View file

@ -1,7 +1,5 @@
use crate::{
config::UserConfig,
linux::{arch_chroot, install_file},
print_status,
config::UserConfig, linux::{arch_chroot, install_file}, pkg::install_pkgs, print_status
};
pub fn change_passwd(user: &str, pw: &str) {
@ -10,7 +8,10 @@ pub fn change_passwd(user: &str, pw: &str) {
/// Setup the users of the system
pub fn setup_users(conf: &[UserConfig]) {
let mut doas_conf = String::new();
if !conf.is_empty() {
install_pkgs(&["doas"]);
install_file("/mnt/etc/doas.conf", "permit persist :wheel as root", 0o644);
}
for user in conf {
let mut cmd = vec!["useradd"];
@ -45,11 +46,13 @@ pub fn setup_users(conf: &[UserConfig]) {
change_passwd(&user.name, &user.password);
if user.doas_root.unwrap_or_default() {
print_status(&format!("Allowing root doas for {}", user.name));
doas_conf.push_str(&format!("permit {} as root\n", user.name));
if user.wheel.unwrap_or_default() {
print_status(&format!("Adding {} to wheel", user.name));
arch_chroot(
&vec!["usermod", "-a", "-G", "wheel", user.name.as_str()],
None,
false,
);
}
}
install_file("/mnt/etc/doas.conf", &doas_conf, 0o644);
}