]> xenbits.xensource.com Git - people/aperard/emesinae.git/commitdiff
control: simple access control
authorIan Campbell <ijc@hellion.org.uk>
Thu, 1 Nov 2012 10:30:57 +0000 (11:30 +0100)
committerIan Campbell <ijc@hellion.org.uk>
Thu, 1 Nov 2012 10:31:51 +0000 (11:31 +0100)
config.pl
control.pl
insertmail.pl

index 9b2fefcecd6240f5bcdef2e1421885451398f530..2c14a728e2d4ae8c440697241f73686c833e7503 100644 (file)
--- a/config.pl
+++ b/config.pl
@@ -9,3 +9,5 @@ $c{StyleSheet} = "/css/style.css";
 $c{AltArchive} = "http://marc.info/?i=<MSGID>";
 
 $c{ControlAddress} = "control@foobugs.example.com";
+
+$c{ControlAllow} = qw/ijc@hellion.org.uk/;
index fee71312f61ec99748be08cd2de532cf57c202dd..f3ebccb2a4d8fe6e636806133b40f61338cc8fdc 100755 (executable)
@@ -20,6 +20,23 @@ print "Message from ".$head->get('from');
 print "Subject: ".$head->get('subject');
 print "\n";
 
+sub validate_from {
+    my $allowed = 0;
+    my @addresses = Mail::Field::AddrList->extract('from', $head )->addresses;
+
+    return 1 if not $c{ControlAllow};
+
+    for my $addr ( @addresses ) {
+       if ( $addr ~~ $c{ControlAllow} ) {
+           $allowed = 1; last;
+       }
+    }
+
+    die unless $allowed;
+}
+
+validate_from;
+
 our @reply;
 
 our @bugs;
index 762559e39f2b295efe20771b2418c81318c6a12f..b300747bf6e58adcba6b85f11fa382ccda4ccf87 100755 (executable)
@@ -6,7 +6,7 @@ use warnings;
 use Mail::Header;
 
 use Bugs::Message;
-use Bugs::Common qw(readconfig opendb);
+use Bugs::Common qw(readconfig opendb c);
 
 our @hdrs;