summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Process
diff options
context:
space:
mode:
authorfukachan <fukachan>2008-06-08 13:13:09 +0000
committerfukachan <fukachan>2008-06-08 13:13:09 +0000
commit87f2f797e57e2631675635040e3cb23dff092b2b (patch)
tree21da5e864d0efa4f2c6b9c0326766c9b27765e10 /fml/lib/FML/Process
parente92d44deb4ce083071ffb9b05edc084d2bcab077 (diff)
downloadfml8-87f2f797e57e2631675635040e3cb23dff092b2b.tar.gz
fml8-87f2f797e57e2631675635040e3cb23dff092b2b.tar.bz2
fml8-87f2f797e57e2631675635040e3cb23dff092b2b.zip
restrict who can create a new ML.
Diffstat (limited to 'fml/lib/FML/Process')
-rw-r--r--fml/lib/FML/Process/CreateOnPost.pm77
1 files changed, 76 insertions, 1 deletions
diff --git a/fml/lib/FML/Process/CreateOnPost.pm b/fml/lib/FML/Process/CreateOnPost.pm
index 47fb4d11..5315152f 100644
--- a/fml/lib/FML/Process/CreateOnPost.pm
+++ b/fml/lib/FML/Process/CreateOnPost.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2006,2008 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: CreateOnPost.pm,v 1.4 2006/07/09 12:11:13 fukachan Exp $
+# $FML: CreateOnPost.pm,v 1.5 2008/06/08 03:09:13 fukachan Exp $
#
package FML::Process::CreateOnPost;
@@ -421,6 +421,12 @@ sub _run_createonpost
}
}
+ # stop ASAP. longjmp.
+ if ($curproc->is_refused()) {
+ $curproc->logwarn("ignore this request");
+ return;
+ }
+
# 2. generate address list to subscribe.
ADDR:
for my $addr (@permit_list) {
@@ -436,6 +442,12 @@ sub _run_createonpost
# 2.1 save user list on shared memory.
$curproc->_save_user_list(\@process_list);
+ # stop ASAP. longjmp.
+ if ($curproc->is_refused()) {
+ $curproc->logwarn("ignore this request");
+ return;
+ }
+
# 3. run distribute processes.
for my $ml (@$cop_list) {
# XXX bound for elena (NOT elena-ctl NOR elena-admin).
@@ -535,12 +547,75 @@ sub _create_ml
{
my ($curproc, $ml_addr) = @_;
+ # check the sender credential.
+ if ($curproc->_is_sender_allowed_to_create_ml()) {
+ $curproc->log("sender allowed to create a new ML");
+ }
+ else {
+ $curproc->logerror("sender not allowed to create a new ML");
+ $curproc->stop_this_process();
+ return;
+ }
+
use FML::CreateOnPost;
my $cop = new FML::CreateOnPost $curproc;
$cop->create_ml($ml_addr);
}
+# Descriptions: check if the sender is allowed to create a new ML.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: NUM(1 or 0)
+sub _is_sender_allowed_to_create_ml
+{
+ my ($curproc) = @_;
+ my $ml_domain = $curproc->default_domain();
+ my $config = $curproc->config();
+ my $cred = $curproc->credential();
+ my $header = $curproc->incoming_message_header();
+ my $from = $header->address_cleanup( $header->get('from') );
+ my $status = 0;
+ my $map_count = 0;
+
+ # 1. check $createonpost_maintainer_maps.
+ my $maintainer_maps =
+ $config->get_as_array_ref('createonpost_maintainer_maps') || [];
+
+ # sanity
+ return 0 unless defined $maintainer_maps;
+
+ # check if from: address is contained in either map.
+ MAP:
+ for my $map (@$maintainer_maps) {
+ if (defined $map) {
+ my $is_valid = $cred->is_valid_map($map, $config);
+ if ($is_valid) {
+ $map_count++;
+ $status = $cred->has_address_in_map($map, $config, $from);
+ last MAP if $status;
+ }
+ else {
+ $curproc->logdebug("invalid map: $map");
+ }
+ }
+ }
+
+ # 2. try the default naive restriction if no valid map.
+ unless ($map_count) {
+ $curproc->logdebug("no valid map: createonpost_maintainer_maps");
+
+ # ok if same domain (user@domain == ml@domain).
+ if ($from =~ /\@$ml_domain$/i) {
+ $curproc->log("from address is our domain <$ml_domain>");
+ return 1;
+ }
+ }
+
+ return $status;
+}
+
+
=head1 CODING STYLE
See C<http://www.fml.org/software/FNF/> on fml coding style guide.