Commit 1c47fd11 authored by Leigh Stoller's avatar Leigh Stoller

* Crude attempt at disallowing overlap of new uids with existing CS

  accounts. If the email address is not a cs.utah.edu address, then
  cross check the uid against the cslogins DB in /usr/testbed/etc.
  The DB is created with /users/stoller/cslogins.pl like this:

    ypcat passwd | awk -F : '{print $1}' | cslogins.pl cslogins

  This creates cslogins.db, which I then copied to /usr/testbed/etc.

  As soon as I get a clear idea of whether ypcat is going to work
  in the future, I will automate this part.
* Also added some sanity checking to make sure the email address looks
  reasonable (since I needed the domain anyway).
parent fd118acd
......@@ -81,6 +81,21 @@ if (strlen($proj_head_uid) > $TBDB_UIDLEN) {
"Please select another.", 1);
}
#
# Check that email address looks reasonable. We need the domain for
# below anyway.
#
$email_domain = strstr($usr_email, "@");
if (! $email_domain ||
strcmp($usr_email, $email_domain) == 0 ||
strlen($email_domain) <= 1 ||
! strstr($email_domain, ".")) {
USERERROR("The email address `$usr_email' looks invalid!. Please ".
"go back and fix it up", 1);
}
$email_domain = substr($email_domain, 1);
$email_user = substr($usr_email, 0, strpos($usr_email, "@", 0));
#
# Certain of these values must be escaped or otherwise sanitized.
#
......@@ -132,6 +147,23 @@ if ($returning) {
}
}
else {
#
# Check new username against CS logins so that external people do
# not pick names that overlap with CS names.
#
if (! strstr($email_domain, "cs.utah.edu")) {
$dbm = dbmopen($TBCSLOGINS, "r");
if (! $dbm) {
TBERROR("Could not dbmopen $TBCSLOGINS from newproject.php3\n", 1);
}
if (dbmexists($dbm, $proj_head_uid)) {
dbmclose($dbm);
USERERROR("The username '$proj_head_uid' is already in use. ".
"Please go back and choose another.", 1);
}
dbmclose($dbm);
}
if (strcmp($password1, $password2)) {
USERERROR("You typed different passwords in each of the two password ".
"entry fields. <br> Please go back and correct them.",
......
......@@ -45,6 +45,21 @@ if (strlen($uid) > $TBDB_UIDLEN) {
"Please select another.", 1);
}
#
# Check that email address looks reasonable. We need the domain for
# below anyway.
#
$email_domain = strstr($usr_email, "@");
if (! $email_domain ||
strcmp($usr_email, $email_domain) == 0 ||
strlen($email_domain) <= 1 ||
! strstr($email_domain, ".")) {
USERERROR("The email address `$usr_email' looks invalid!. Please ".
"go back and fix it up", 1);
}
$email_domain = substr($email_domain, 1);
$email_user = substr($usr_email, 0, strpos($usr_email, "@", 0));
#
# Certain of these values must be escaped or otherwise sanitized.
#
......@@ -75,7 +90,7 @@ else {
#
if ($returning) {
if (CHECKLOGIN($uid) != 1) {
USERERROR("The Username '$proj_head_uid' is in use. ".
USERERROR("The Username '$uid' is in use. ".
"If you already have an Emulab account, please go back ".
"and login before trying to join a new project.<br><br>".
"If you are a <em>new</em> Emulab user trying to join ".
......@@ -84,6 +99,23 @@ if ($returning) {
}
}
else {
#
# Check new username against CS logins so that external people do
# not pick names that overlap with CS names.
#
if (! strstr($email_domain, "cs.utah.edu")) {
$dbm = dbmopen($TBCSLOGINS, "r");
if (! $dbm) {
TBERROR("Could not dbmopen $TBCSLOGINS from usradded.php3\n", 1);
}
if (dbmexists($dbm, $uid)) {
dbmclose($dbm);
USERERROR("The username '$uid' is already in use. ".
"Please go back and choose another.", 1);
}
dbmclose($dbm);
}
if (strcmp($password1, $password2)) {
USERERROR("You typed different passwords in each of the two password ".
"entry fields. <br> Please go back and correct them.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment