-#!/usr/bin/php
+#!/usr/bin/php -q
<?php
require_once(dirname(__FILE__).'/../mitsql.cfg.php');
require_once('batch.inc.php');
-$callingUnix = posix_getpwuid(posix_getuid());
+if (isset($argv) && count($argv)>=4) {
+ $myUsername = $argv[1];
+ $myUID = $argv[3];
+ if ($myUID<100) exit('bad UID');
+} elseif (defined('SIGNUP_PW') && strlen(SIGNUP_PW) && (isset($_SERVER['HTTP_AUTHORIZATION']) || isset($_SERVER['PHP_AUTH_PW'])) && SIGNUP_PW == $_SERVER['PHP_AUTH_PW']) {
+ $myUsername = $i_u;
+} else {
+ exit;
+}
-$myUsername = escapeshellcmd($callingUnix['name']);
-$hesinfo = explode(':', trim(`hesinfo $myUsername passwd`));
+if (empty($myUsername)) exit('bad User');
+$hescmd = "hesinfo $myUsername passwd";
+$hesinfo = explode(':', trim(exec($hescmd)));
if (count($hesinfo)>=4) {
$myName = explode(',', $hesinfo[4]);
$myName = array_shift($myName);
} else {
$myName = $myUsername;
}
-$myUID = $callingUnix['uid'];
$myEmail = $myUsername.'@mit.edu';
-$myPassword = substr(uniqid(),0,7);
-
-if ($myUID<1000) exit;
+$myPassword = trim(exec(dirname(__FILE__).'/../bin/nicepass.py'));
+if (empty($myPassword)) exit('bad Password');
$Login = new Login($myUsername);
if (!$Login->exists() && !empty($myUsername)) {
}
if ($Login->canSignup()) {
$User = new User($Login->getUserId());
- echo $User->signup($myPassword);
- echo "signup\n";
- die($myPassword);
+ $User->signup($myPassword);
+ exit($myPassword);
}
?>