diff --git a/src/functions/network.rs b/src/functions/network.rs index fe2403d..60e7afa 100755 --- a/src/functions/network.rs +++ b/src/functions/network.rs @@ -2,8 +2,8 @@ use crate::internal::*; pub fn set_hostname(hostname: &str) { println!("Setting hostname to {}", hostname); - files::create_file("/etc/hostname"); - let return_val = files::append_file("/etc/hostname", hostname); + files::create_file("/mnt/etc/hostname"); + let return_val = files::append_file("/mnt/etc/hostname", hostname); match return_val { Ok(_) => { log(format!("Set hostname to {}", hostname)); @@ -19,7 +19,7 @@ pub fn set_hostname(hostname: &str) { pub fn enable_ipv6(ipv6: bool) { if ipv6 { - let return_val = files::append_file("/etc/hosts", "::1 localhost"); + let return_val = files::append_file("/mnt/etc/hosts", "::1 localhost"); match return_val { Ok(_) => { log("Enabled IPv6".to_string()); diff --git a/src/functions/users.rs b/src/functions/users.rs index a4afab5..1890937 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -2,7 +2,7 @@ use crate::internal::exec::*; use crate::internal::*; pub fn new_user(username: &str, hasroot: bool, password: &str) { - let return_val = exec( + let return_val = exec_chroot( "useradd", vec![ String::from("-m"), @@ -23,7 +23,7 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) { } } if hasroot { - let return_val = exec( + let return_val = exec_chroot( "usermod", vec![ String::from("-a"), @@ -41,11 +41,9 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) { } } } - let return_val = exec( - "arch-chroot", + let return_val = exec_chroot( + "usermod", vec![ - String::from("/mnt"), - String::from("usermod"), String::from("--password"), String::from("$(echo"), String::from(format!("${}", password)), @@ -72,11 +70,9 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) { pub fn root_pass(root_pass: &str) { println!("Setting root password to '{}'", root_pass); - let return_val = exec( - "arch-chroot", + let return_val = exec_chroot( + "usermod", vec![ - String::from("/mnt"), - String::from("usermod"), String::from("--password"), String::from("$(echo"), String::from(format!("${{{}}}", root_pass)), diff --git a/src/internal/exec.rs b/src/internal/exec.rs index 3728edf..ab49093 100755 --- a/src/internal/exec.rs +++ b/src/internal/exec.rs @@ -5,6 +5,11 @@ pub fn exec(command: &str, args: Vec) -> Result) -> Result { + let returncode = Command::new("arch-chroot").args(&["/mnt", command]).args(args).output(); + returncode +} + pub fn exec_workdir(command: &str, workdir: &str, args: Vec,) -> Result { let returncode = Command::new(command).args(args).current_dir(workdir).output(); returncode