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'];
$name = $user."-".$id;
$directory = "/home/servers/".$name;
$salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));
echo "User: ".$user;
echo "<br/>";
echo "Memory: ".$mem;
echo "<br/>";
echo "ID: ".$id;
echo "<br/>";
echo "Pass: ".$pass;
echo "<br/>";
echo "Directory: ".$directory;
echo "<br/>";
echo "<br/>";
echo "name: ".$name;
echo "<br/>";
if (!file_exists($directory)) {
mkdir($directory, 0, true);
}
else {
echo "Dir already exists?";
}
$outputuser = shell_exec("sudo useradd -s /bin/false -d ".escapeshellarg($directory)." -p ".crypt($pass,$salt)." ".escapeshellarg($servername));
}
?>
now when i run the page i get this output
User: trotski94 Memory: 1024 ID: 1 Pass: test Directory: /home/servers/trotski94-1 name: trotski94-1 Dir already exists?
which is expected. but when i go to login on the ubuntu machine it says there is no home directory, using / as home instead, why is the -d flag not setting the home directory?
check user directory by: cat /etc/passwd | grep trotski94
mayby escapeshellarg may spoil something