45 lines
810 B
Perl
Executable File
45 lines
810 B
Perl
Executable File
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
my ($mailname,$uid) = @ARGV;
|
|
|
|
if (!$mailname || !$uid) {
|
|
print "Usage: mail_add <mailname> <uid>\n";
|
|
print " Create the mail <mailname> for the alternc account having uid number <uid>\n";
|
|
exit(1);
|
|
}
|
|
|
|
$ENV{PATH} = "";
|
|
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
|
|
|
|
if (!($mailname =~ /^([a-z0-9_\+\.-]+\_[a-z0-9\.-]+)$/)) {
|
|
die "Email is incorrect.";
|
|
}
|
|
$mailname=$1;
|
|
if (!($uid =~ /^([0-9]+)$/)) {
|
|
die "uid is incorrect.";
|
|
}
|
|
$uid=$1;
|
|
|
|
$< = $>;
|
|
$( = $);
|
|
|
|
my $PTH="/var/alternc/mail/".substr($mailname,0,1)."/".$mailname;
|
|
|
|
my @todo=(
|
|
$PTH,
|
|
$PTH."/Maildir",
|
|
$PTH."/Maildir/cur",
|
|
$PTH."/Maildir/new",
|
|
$PTH."/Maildir/tmp",
|
|
);
|
|
|
|
foreach(@todo) {
|
|
mkdir($_);
|
|
system("/bin/chown 33:$uid '".quotemeta($_)."'");
|
|
}
|
|
|
|
0;
|
|
|