Answer the question
In order to leave comments, you need to log in
Why is the system user not being created?
Hello! Prompt, why the system user can not be created?
Here is the function
protected function create(array $data)
{
//создаем пользователя в базе данных
$user= User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'role'=>'customer',
]);
//получаем его ID
$id = $user->id;
$pass = $data['password'];
//создаем пользователя в Linux
shell_exec("useradd -d /home/u$id/ u$id");
shell_exec("echo u$id:$pass | chpasswd");
//возвратить экземпляр класса User
return $user;
}
user ALL=(ALL) NOPASSWD:ALL
Answer the question
In order to leave comments, you need to log in
shell_exec returns the output of the running command as the result of the function.
To begin with, do var_dump(shell_exec())
and see what's the matter, what the team swears at (if it swears).
In general, I would recommend exec()
checking the status code of the result of the command, because the second command does not need to be executed if the first one fails with an error.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question