diff --git a/src/main.rs b/src/main.rs index 2346bfd..bf4b3be 100755 --- a/src/main.rs +++ b/src/main.rs @@ -137,7 +137,7 @@ fn setup_user(username: String, password: String) { let username4 = &username; newser(username1.to_string()); pwd(username2.to_string(), password); - chroot(username3.to_string()); + chown_root(username3.to_string()); quota(username4.to_string()); } else { @@ -151,40 +151,6 @@ fn setup_user(username: String, password: String) { } } -// Set disk usage limit to the user by copying another user quota -fn quota(username: String) { - let output = Command::new("/usr/sbin/edquota") - .arg("-p") - .arg("testfract") - .arg(&username) - .output() - .expect("failed to execute process"); - print_output(output); -} - -// Chown /srv/ht/username to root:root -fn chroot(username: String) { - - let mut path = "/srv/ht/".to_string(); - - path += &username; - - let output = Command::new("/usr/bin/chown") - .arg("root:root") - .arg(&path) - .output() - .expect("Failed to chown /srv/ht/ to root:root"); - print_output(output); - - let output = Command::new("/usr/bin/chmod") - .arg("755") - .arg(path) - .output() - .expect("Failed to chmod /srv/ht/ to 755"); - print_output(output); - -} - // Creates a new user in the group 'ht', which is available only over SFTP fn newser(username: String) { let output = Command::new("/usr/sbin/useradd") @@ -232,6 +198,39 @@ fn pwd(username: String, password: String) { } } +// Chown /srv/ht/username to root:root +fn chown_root(username: String) { + + let mut path = "/srv/ht/".to_string(); + + path += &username; + + let output = Command::new("/usr/bin/chown") + .arg("root:root") + .arg(&path) + .output() + .expect("Failed to chown /srv/ht/ to root:root"); + print_output(output); + + let output = Command::new("/usr/bin/chmod") + .arg("755") + .arg(path) + .output() + .expect("Failed to chmod /srv/ht/ to 755"); + print_output(output); +} + +// Set disk usage limit to the user by copying another user quota +fn quota(username: String) { + let output = Command::new("/usr/sbin/edquota") + .arg("-p") + .arg("vase") + .arg(&username) + .output() + .expect("failed to execute process"); + print_output(output); +} + fn is_string_lowercase(stri: String) -> bool { let re = Regex::new("^[[:lower:]]+$").unwrap();