Commit 52bbdc73 authored by Leigh Stoller's avatar Leigh Stoller

Fix last revision, and turn all the "opens" into "system" calls.

parent c2cc818d
#!/usr/local/bin/perl -wT
### $Id: mkacct-ctrl.in,v 1.3 2001-01-04 23:22:54 newbold Exp $
#
# XXX Need to deal with errors!
#
use English;
use Mysql;
......@@ -146,32 +148,26 @@ sub dowork() {
#
# Create group on paper.
#
print "Adding group $project to paper.\n";
open(ADDGROUPP, "/usr/sbin/pw groupadd $project -g $group_number 2>&1 |");
while (<ADDGROUPP>) { print "$_"; }
close(ADDGROUPP);
#
system("/usr/sbin/pw groupadd $project -g $group_number") == 0 or
die("Could not add group $project with gid $group_number to paper");
#
# Make user on paper. We don't give them a password.
#
print "Adding user $user to paper.\n";
my $cmd = "/usr/sbin/pw useradd $user -u $user_number " .
"-n '$fullname' ".
"-k /usr/share/skel -m " .
"-d /users/$user -g $project " .
"-s $PBAG";
open(PWADDP, "$cmd 2>&1 |") or die "$0: Could not open pw useradd on paper.";
while (<PWADDP>) { print "$_"; }
close(PWADDP);
system("/usr/sbin/pw useradd $user -u $user_number -c \"$fullname\" ".
"-k /usr/share/skel -m -d /users/$user -g $project -s $PBAG") == 0
or die("Could not add user $user to paper");
#
# Make group on control node.
#
print "Adding group $project to $control_node.\n";
open(ADDGROUP, "/usr/local/bin/sshtb $control_node /usr/sbin/pw groupadd $project -g $group_number 2>&1 |");
while (<ADDGROUP>) { print "$_"; }
close(ADDGROUP);
system("/usr/local/bin/sshtb $control_node /usr/sbin/pw ".
"groupadd $project -g $group_number") == 0 or
die("Could not add group $project with gid $group_number to ".
"$control_node");
#
# Make user on control node. Note that we cannot get back any output from
......@@ -180,21 +176,15 @@ sub dowork() {
# change the password.
#
print "Adding user $user to $control_node.\n";
$cmd = "/usr/local/bin/sshtb $control_node " .
"/usr/sbin/pw useradd $user -u $user_number " .
"-n '$fullname' ".
"-d /users/$user -g $project -s /bin/tcsh";
open(PWADD, "$cmd 2>&1 |") or die "$0: Could not open pw useradd.";
while (<PWADD>) { print "$_"; }
# Old attempt at password setting
#$cmd = "/usr/local/bin/sshtb $control_node " .
# "/usr/sbin/pw usermod $user -h 0";
close(PWADD);
open(CHPASS, "/usr/local/bin/sshtb $control_node " .
"/usr/bin/chpass -p $pswd $user 2>&1 |");
while (<CHPASS>) { print "$_"; }
close(CHPASS);
system("/usr/local/bin/sshtb $control_node " .
"/usr/sbin/pw useradd $user -u $user_number -c '\"$fullname\"' ".
"-k /usr/share/skel -m -d /users/$user -g $project ".
"-s /bin/tcsh") == 0
or die("Could not add user $user to $control_node.");
system("/usr/local/bin/sshtb $control_node ".
"/usr/bin/chpass -p $pswd $user") == 0
or die("Could not change password for user $user on $control_node.");
#
# Set up the ssh key
......
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