diff options
| author | fukachan <fukachan> | 2004-04-30 13:38:05 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-04-30 13:38:05 +0000 |
| commit | 7d8c4dee4c08ce870b8e0240736ec2aef27e8f48 (patch) | |
| tree | 550972c4ad1f5babd67e7c1758301f19e021d68d /fml/lib/FML/Command | |
| parent | 8cf3342dc0773e309f80a73057d77cfd1bbd1569 (diff) | |
| download | fml8-7d8c4dee4c08ce870b8e0240736ec2aef27e8f48.tar.gz fml8-7d8c4dee4c08ce870b8e0240736ec2aef27e8f48.tar.bz2 fml8-7d8c4dee4c08ce870b8e0240736ec2aef27e8f48.zip | |
more restrict error checks.
Diffstat (limited to 'fml/lib/FML/Command')
| -rw-r--r-- | fml/lib/FML/Command/Admin/digest.pm | 80 | ||||
| -rw-r--r-- | fml/lib/FML/Command/Admin/off.pm | 27 | ||||
| -rw-r--r-- | fml/lib/FML/Command/Admin/on.pm | 29 |
3 files changed, 123 insertions, 13 deletions
diff --git a/fml/lib/FML/Command/Admin/digest.pm b/fml/lib/FML/Command/Admin/digest.pm index ba8647ba..159aece4 100644 --- a/fml/lib/FML/Command/Admin/digest.pm +++ b/fml/lib/FML/Command/Admin/digest.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: digest.pm,v 1.18 2004/02/15 04:38:28 fukachan Exp $ +# $FML: digest.pm,v 1.19 2004/04/28 04:10:36 fukachan Exp $ # package FML::Command::Admin::digest; @@ -157,9 +157,11 @@ sub process sub _digest_on { my ($self, $curproc, $command_args, $dargs) = @_; - my $address = $dargs->{ address }; - my $recipient_map = $dargs->{ primary_recipient_map }; - my $digest_recipient_map = $dargs->{ primary_digest_recipient_map }; + my $config = $curproc->config(); + my $cred = $curproc->{ credential }; + my $address = $dargs->{ address }; + my $recipient_map = $dargs->{ primary_recipient_map }; + my $digest_recipient_map = $dargs->{ primary_digest_recipient_map }; # move $address from normal $recipient_map to $digest_recipient_map my $uc_normal_args = { @@ -172,8 +174,34 @@ sub _digest_on maplist => [ $digest_recipient_map ], }; - $self->_userdel($curproc, $command_args, $uc_normal_args); - $self->_useradd($curproc, $command_args, $uc_digest_args); + my $msg_args = { + _arg_address => $address, + }; + + # 1. remove address from $recipient_map (normal delivery recipients). + # we should remove address if $recipient_map conatins it. + if ($cred->has_address_in_map($recipient_map, $config, $address)) { + $self->_userdel($curproc, $command_args, $uc_normal_args); + } + else { + my $r = "no such recipient"; + $curproc->reply_message_nl('error.no_such_recipient', $r, $msg_args); + $curproc->logerror($r); + croak($r); + } + + # 2. add address into $digest_recipient_map + if ($cred->has_address_in_map($digest_recipient_map, $config, $address)) { + my $r = "already digest recipient"; + $curproc->reply_message_nl('error.already_digest_recipient', + $r, + $msg_args); + $curproc->logerror($r); + croak($r); + } + else { + $self->_useradd($curproc, $command_args, $uc_digest_args); + } } @@ -185,9 +213,11 @@ sub _digest_on sub _digest_off { my ($self, $curproc, $command_args, $dargs) = @_; - my $address = $dargs->{ address }; - my $recipient_map = $dargs->{ primary_recipient_map }; - my $digest_recipient_map = $dargs->{ primary_digest_recipient_map }; + my $config = $curproc->config(); + my $cred = $curproc->{ credential }; + my $address = $dargs->{ address }; + my $recipient_map = $dargs->{ primary_recipient_map }; + my $digest_recipient_map = $dargs->{ primary_digest_recipient_map }; # move $address from normal $digest_recipient_maps to $prmary_recipient_map my $uc_normal_args = { @@ -200,8 +230,36 @@ sub _digest_off maplist => [ $digest_recipient_map ], }; - $self->_userdel($curproc, $command_args, $uc_digest_args); - $self->_useradd($curproc, $command_args, $uc_normal_args); + my $msg_args = { + _arg_address => $address, + }; + + # 1. remove address from digest_recipient_map. + # we should remove address if $digest_recipient_map contains it. + if ($cred->has_address_in_map($digest_recipient_map, $config, $address)) { + $self->_userdel($curproc, $command_args, $uc_digest_args); + } + else { + my $r = "no such digest recipient"; + $curproc->reply_message_nl('error.no_such_digest_recipient', + $r, + $msg_args); + $curproc->logerror($r); + croak($r); + } + + # 2. add address into normal recipient map. + if ($cred->has_address_in_map($recipient_map, $config, $address)) { + my $r = "already recipient"; + $curproc->reply_message_nl('error.already_recipient', + $r, + $msg_args); + $curproc->logerror($r); + croak($r); + } + else { + $self->_useradd($curproc, $command_args, $uc_normal_args); + } } diff --git a/fml/lib/FML/Command/Admin/off.pm b/fml/lib/FML/Command/Admin/off.pm index aa87e34e..703f8133 100644 --- a/fml/lib/FML/Command/Admin/off.pm +++ b/fml/lib/FML/Command/Admin/off.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: off.pm,v 1.17 2004/02/15 04:38:29 fukachan Exp $ +# $FML: off.pm,v 1.18 2004/04/28 04:10:36 fukachan Exp $ # package FML::Command::Admin::off; @@ -81,6 +81,7 @@ sub process { my ($self, $curproc, $command_args) = @_; my $config = $curproc->config(); + my $cred = $curproc->{ credential }; my $options = $command_args->{ options }; my $address = $command_args->{ command_data } || $options->[ 0 ]; @@ -105,6 +106,30 @@ sub process }; my $r = ''; + # diag: $recipient_map should have this user. + my $symmetric_mode = 1; # XXX NOT YET IMPLEMENTD; + my $msg_args = { + _arg_address => $address, + }; + if ($symmetric_mode) { + my $member_map = $config->{ primary_member_map }; + unless ($cred->has_address_in_map($member_map, $config, $address)) { + my $r = "no such member"; + $curproc->reply_message_nl('error.no_such_member', + $r, + $msg_args); + $curproc->logerror($r); + croak($r); + } + + unless ($cred->has_address_in_map($recipient_map, $config, $address)) { + my $r = "no such user in \$recipient_map"; + $curproc->reply_message_nl('error.no_such_member', $r); + $curproc->logerror($r); + croak($r); + } + } + eval q{ use FML::User::Control; my $obj = new FML::User::Control; diff --git a/fml/lib/FML/Command/Admin/on.pm b/fml/lib/FML/Command/Admin/on.pm index d5c43072..d9e551ca 100644 --- a/fml/lib/FML/Command/Admin/on.pm +++ b/fml/lib/FML/Command/Admin/on.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: on.pm,v 1.17 2004/02/15 04:38:29 fukachan Exp $ +# $FML: on.pm,v 1.18 2004/04/28 04:10:37 fukachan Exp $ # package FML::Command::Admin::on; @@ -81,6 +81,7 @@ sub process { my ($self, $curproc, $command_args) = @_; my $config = $curproc->config(); + my $cred = $curproc->{ credential }; my $options = $command_args->{ options }; my $address = $command_args->{ command_data } || $options->[ 0 ]; @@ -106,6 +107,32 @@ sub process }; my $r = ''; + # diag: $recipient_map should not have this user. + my $symmetric_mode = 1; # XXX NOT YET IMPLEMENTD; + my $msg_args = { + _arg_address => $address, + }; + if ($symmetric_mode) { + my $member_map = $config->{ primary_member_map }; + unless ($cred->has_address_in_map($member_map, $config, $address)) { + my $r = "no such member"; + $curproc->reply_message_nl('error.no_such_member', + $r, + $msg_args); + $curproc->logerror($r); + croak($r); + } + + if ($cred->has_address_in_map($recipient_map, $config, $address)) { + my $r = "already recipient"; + $curproc->reply_message_nl('error.already_recipient', + $r, + $msg_args); + $curproc->logerror($r); + croak($r); + } + } + eval q{ use FML::User::Control; my $obj = new FML::User::Control; |
