36 lines
641 B
Plaintext
36 lines
641 B
Plaintext
|
#!/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 '".quotemeta($PTH)."'");
|
||
|
system("/bin/chmod 02770 '".quotemeta($PTH)."'");
|
||
|
|
||
|
0;
|
||
|
|