Commit fbc98121 authored by fred's avatar fred

run mail handling commands via ssh

parent 142e45f2
......@@ -4,6 +4,8 @@ use strict;
my ($mailname,$uid) = @ARGV;
my $M_PATH = "/usr/bin/ssh -i /etc/alternc/ssh/id_rsa-mailadd -F /etc/alternc/ssh/ssh_config lucie.domainepublic.lan /usr/local/lib/alternc/mail_add";
if (!$mailname || !$uid) {
print "Usage: mail_add <mailname> <uid>\n";
print " Create the mail <mailname> for the alternc account having uid number <uid>\n";
......@@ -13,32 +15,12 @@ if (!$mailname || !$uid) {
$ENV{PATH} = "";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
if (!($mailname =~ /^([a-z0-9_\+\-][a-z0-9_\+\.\-]+\_[a-z0-9\.-]+)$/)) {
die "Email is incorrect.";
}
$mailname=$1;
if (!($uid =~ /^([0-9]+)$/)) {
die "uid is incorrect.";
sub escapeshellarg {
my ($st) = @_;
$st =~ s/\'/\'\\\'\'/;
return "'".$st."'";
}
$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($_);
chown(33, $uid, $_);
}
exec($M_PATH." ".escapeshellarg($mailname)." ".escapeshellarg($uid));
0;
......@@ -4,6 +4,8 @@ use strict;
my ($mailname) = @ARGV;
my $M_PATH = "/usr/bin/ssh -i /etc/alternc/ssh/id_rsa-maildel -F /etc/alternc/ssh/ssh_config lucie.domainepublic.lan /usr/local/lib/alternc/mail_del";
if (!$mailname) {
print "Usage: mail_del <mailname>\n";
print " Destroy pop account <mailname>\n";
......@@ -13,15 +15,12 @@ if (!$mailname) {
$ENV{PATH} = "";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
if (!($mailname =~ /^([a-z0-9_\+-][a-z0-9_\+\.-]+\_[a-z0-9\.-]+)$/)) {
die "Email is incorrect.";
sub escapeshellarg {
my ($st) = @_;
$st =~ s/\'/\'\\\'\'/;
return "'".$st."'";
}
$mailname=$1;
$< = $>;
$( = $);
system("/bin/rm -rf '/var/alternc/mail/".substr($mailname,0,1)."/".$mailname."'");
exec($M_PATH." ".escapeshellarg($mailname));
0;
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