I have this PHP code
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
if(!empty($_GET) && !empty($_GET['user']) && !empty($_GET['mem']) && !empty($_GET['id']) &&!empty($_GET['k'])) {
$user = $_GET['user'];
$mem = $_GET['mem'];
$id = $_GET['id'];
$pass = $_GET['k'];
$fullname= escapeshellarg($user."-".$id);
echo $user;
echo $mem;
echo $id;
echo $pass;
echo "<br/>";
mkdir("/home/servers/".$fullname, 0, true);
$outputuser = shell_exec("sudo useradd -d /home/$fullname $fullname");
$outputpass = shell_exec('echo -e '.$pass.'\n'.$pass.'\n" | sudo passwd '.$fullname);
echo $outputpass;
}
?>
the password isnt working right though. when i run it from the terminal i get
Enter new UNIX password: Retype new UNIX password: passwd: Authentication token manipulation errornow surely theres a better way of doing this without exposing both useradd AND passwd to not needing passwords in sudo?