#!/usr/bin/perl use strict; my ($mailname,$uid) = @ARGV; if (!$mailname || !$uid) { print "Usage: mail_add \n"; print " Create the mail for the alternc account having uid number \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;