update signup.php to work with userqueue changes to help race condition #32
|
@ -9,13 +9,10 @@ $interest = $_GET['interest'];
|
|||
$pubkey = $_GET['pubkey'];
|
||||
$tv = $_GET['tv'];
|
||||
|
||||
// username passed lowercased
|
||||
$username = strtolower($username);
|
||||
|
||||
// strip new line characters from the end
|
||||
$pubkey = trim($pubkey);
|
||||
|
||||
$from = 'From: www-data <www-data@thunix.net>';
|
||||
$from = 'From: www-data <www-data@thunix.net>';
|
||||
$destination_addr = "newuser@thunix.net";
|
||||
$subject = "New User Registration";
|
||||
$mailbody = "A new user has tried to register.
|
||||
|
@ -25,38 +22,33 @@ Email Address: $email
|
|||
Interest: $interest
|
||||
Pubkey: $pubkey";
|
||||
|
||||
// In the future, here, we *should* be able to build a process that
|
||||
// somehow auto-verifies the user, and instead of email, it'll kick off the new user process here
|
||||
|
||||
$user_queue = '/dev/shm/userqueue';
|
||||
$user_file = $user_queue . '/' . $username;
|
||||
|
||||
// Spam attempt
|
||||
$success = 'success1';
|
||||
if ( $tv == "tildeverse" )
|
||||
{
|
||||
// Success!
|
||||
$success = 'success2';
|
||||
|
||||
// Check if username already taken
|
||||
exec("id $username 2>&1", $null, $retval);
|
||||
if($retval == 0)
|
||||
$success = 'success3';
|
||||
if ($tv == "tildeverse") {
|
||||
$success = 'success2';
|
||||
|
||||
// Check SSH public key format:
|
||||
exec("echo $pubkey | ssh-keygen -l -f - 2>&1", $null, $retval);
|
||||
if($retval != 0)
|
||||
$success = 'success4';
|
||||
// Check if username already taken
|
||||
exec("id $username 2>&1", $null, $retval);
|
||||
if ($retval == 0)
|
||||
$success = 'success3';
|
||||
|
||||
if ( $success == "success2" )
|
||||
{
|
||||
mail($destination_addr, $subject, $mailbody, $from);
|
||||
$fp = fopen($user_queue, 'a');
|
||||
fwrite($fp, "'$username','$email','$pubkey'\n");
|
||||
fclose($fp);
|
||||
}
|
||||
// Check SSH public key format:
|
||||
exec("echo $pubkey | ssh-keygen -l -f - 2>&1", $null, $retval);
|
||||
if ($retval != 0)
|
||||
$success = 'success4';
|
||||
|
||||
if ($success == "success2") {
|
||||
mail($destination_addr, $subject, $mailbody, $from);
|
||||
|
||||
// Use a file for each username to avoid race conditions
|
||||
$fp = fopen($user_file, 'w');
|
||||
fwrite($fp, "'$username','$email','$pubkey'\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: $site_root/?page=$success");
|
||||
die();
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user