This commit is contained in:
Adrian Heine 2017-01-15 13:18:41 +01:00
parent 9e3173507d
commit 27e6531119
8 changed files with 288 additions and 15 deletions

View file

@ -126,13 +126,29 @@ impl<'a> SystemUserAdder<'a> {
impl<'a> UserAdder for SystemUserAdder<'a> {
type SubE = IoError;
fn add_user(&self, user_name: &str) -> Result<(), UserAdderError<IoError>> {
let output = self.command_runner.run_with_args("adduser", &["--system", "--disabled-login", "--disabled-password", user_name]);
let output = self.command_runner.run_with_args(
"adduser",
&[
// "-m", // Necessary for Fedora, not accepted in Debian
"--system",
user_name
]);
match output {
Ok(output) => match output.status.code() {
Some(0) => Ok(()),
Some(1) => Err(UserAdderError::AlreadyExists),
Some(_) => Err(UserAdderError::UnknownError),
None => Err(UserAdderError::UnknownError),
Some(1) =>
{
println!("{:?}", output);
Err(UserAdderError::AlreadyExists)},
Some(_) =>
{
println!("{:?}", output);
Err(UserAdderError::UnknownError)
},
None => {
println!("{:?}", output);
Err(UserAdderError::UnknownError)
},
},
Err(e) => Err(UserAdderError::ImplError(e))
}