AlternC/src/mem_add

36 lines
605 B
Plaintext
Raw Normal View History

#!/usr/bin/perl
use strict;
my ($name,$uid) = @ARGV;
if (!$name || !$uid) {
print "Usage: mem_add <name> <uid>\n";
print " Create the AlternC account <name> having uid number <uid>\n";
exit(1);
}
$ENV{PATH} = "";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
if (!($name =~ /^([a-z0-9]+)$/)) {
die "Account name is incorrect.";
}
$name=$1;
if (!($uid =~ /^([0-9]+)$/)) {
die "uid is incorrect.";
}
$uid=$1;
$< = $>;
$( = $);
my $PTH="/var/alternc/html/".substr($name,0,1)."/".$name;
mkdir($PTH);
system("/bin/chown 33:$uid '$PTH'");
system("/bin/chmod 02770 '$PTH'");
0;