]> andersk Git - sql-web.git/blobdiff - batch/signup.php
signup: lower minimum UIDs
[sql-web.git] / batch / signup.php
index 357efcd14bbe0e51049b6864126109c7f3f8f56f..50041296f75041e1d943c9ff7722046961c5405b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/php -q
 <?php
 
 require_once(dirname(__FILE__).'/../mitsql.cfg.php');
@@ -6,21 +6,20 @@ require_once('mitsql.lib.php');
 
 require_once('batch.inc.php');
 
-$callingUnix = posix_getpwuid(posix_getuid());
-
-$myUsername = escapeshellcmd($callingUnix['name']);
-$hesinfo = explode(':', trim(`hesinfo $myUsername passwd`));
+$myUsername = $argv[1];
+$myUID = $argv[3];
+$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);
+$myPassword = substr(md5(uniqid()),0,8);
 
-if ($myUID<1000) exit;
+if ($myUID<100) exit('bad UID');
 
 $Login = new Login($myUsername);
 if (!$Login->exists() && !empty($myUsername)) {
@@ -29,9 +28,8 @@ 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);
 }
 
 ?>
This page took 0.239916 seconds and 4 git commands to generate.