summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-04-10 04:31:09 +0000
committerfukachan <fukachan>2002-04-10 04:31:09 +0000
commit8a7e4160b8c068ca1c59da9f5603bfa02f7513e4 (patch)
treeb6f4523ec8251f6bb60332d06633c06d444e1700
parente808d50da996d1f7fca80e879a677188ed3b58c9 (diff)
downloadfml8-8a7e4160b8c068ca1c59da9f5603bfa02f7513e4.tar.gz
fml8-8a7e4160b8c068ca1c59da9f5603bfa02f7513e4.tar.bz2
fml8-8a7e4160b8c068ca1c59da9f5603bfa02f7513e4.zip
enable filtering.
implement access methods to control filtering. o $curproc->refuse_further_processing() o $curproc->is_refused()
-rw-r--r--fml/lib/FML/Process/Distribute.pm26
-rw-r--r--fml/lib/FML/Process/Kernel.pm36
2 files changed, 59 insertions, 3 deletions
diff --git a/fml/lib/FML/Process/Distribute.pm b/fml/lib/FML/Process/Distribute.pm
index 7e28d692..b84c4a05 100644
--- a/fml/lib/FML/Process/Distribute.pm
+++ b/fml/lib/FML/Process/Distribute.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Distribute.pm,v 1.66 2002/03/30 13:48:26 fukachan Exp $
+# $FML: Distribute.pm,v 1.67 2002/03/31 03:39:14 fukachan Exp $
#
package FML::Process::Distribute;
@@ -107,12 +107,31 @@ sub verify_request
$curproc->verify_sender_credential();
$curproc->simple_loop_check();
+ $curproc->_check_filter($args);
$eval = $config->get_hook( 'distribute_verify_request_end_hook' );
if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
+sub _check_filter
+{
+ my ($curproc, $args) = @_;
+ my $config = $curproc->{ config };
+
+ use FML::Filter;
+ my $filter = new FML::Filter;
+ $filter->check($curproc, $args);
+
+ # filter traps this message.
+ if ($filter->error()) {
+ # we should stop this process ASAP.
+ $curproc->refuse_further_processing();
+ Log("mail loop detected");
+ }
+}
+
+
=head2 C<run($args>)
Firstly it locks (giant lock) the current process.
@@ -141,7 +160,7 @@ sub run
if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
$curproc->lock();
- {
+ unless ($curproc->is_refused()) {
if ($curproc->permit_post($args)) {
$curproc->_distribute($args);
}
@@ -149,6 +168,9 @@ sub run
Log("deny article submission");
}
}
+ else {
+ LogError("ignore this request.");
+ }
$curproc->unlock();
$eval = $config->get_hook( 'distribute_run_end_hook' );
diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm
index 414e1306..b098dcf4 100644
--- a/fml/lib/FML/Process/Kernel.pm
+++ b/fml/lib/FML/Process/Kernel.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: Kernel.pm,v 1.81 2002/03/17 06:24:31 fukachan Exp $
+# $FML: Kernel.pm,v 1.82 2002/03/31 12:11:26 fukachan Exp $
#
package FML::Process::Kernel;
@@ -368,6 +368,8 @@ sub simple_loop_check
}
if ($match) {
+ # we should stop this process ASAP.
+ $curproc->refuse_further_processing();
Log("mail loop detected for $match");
}
}
@@ -511,6 +513,38 @@ sub _check_resitrictions
}
+=head2 refuse_further_processing($reason)
+
+Set "we should refuse this processing now" flag.
+We should stop this process as soon as possible.
+
+=head2 is_refused()
+
+We should stop this process as soon as possible due to something
+invalid conditions by such as filtering.
+
+=cut
+
+
+sub refuse_further_processing
+{
+ my ($curproc, $reason) = @_;
+ $curproc->{ __this_process_is_invalid } = 1;
+}
+
+
+sub is_refused
+{
+ my ($curproc, $reason) = @_;
+
+ if (defined $curproc->{ __this_process_is_invalid }) {
+ return $curproc->{ __this_process_is_invalid };
+ }
+
+ return 0;
+}
+
+
=head1 MESSAGE HANDLING
=head2 C<reply_message($msg)>