ACL-Regex

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Changes
Changes.PL
examples/postifx-policy-server.pl
lib/ACL/Regex.pm
Makefile.PL
MANIFEST
MANIFEST.SKIP
README
t/001.t
t/acl.permit.txt
t/acl.reject.txt
t/action.txt
t/actions.txt

README  view on Meta::CPAN

This ACL system provides a light framework for supplying regex-style, sys-admin
friendly access control to any kind of application.

Any application can make use of the module, the example application is a perl
service that takes postfix style policy server declarations, converts them
into a native format, and checks them against a database of ACLs.

Note, that this intended for use strictly with Postfix systems, but rather
any system that requires an ACL: web-application, mail application, etc.

Installation:

 $ perl Makefile.PL && make test install

examples/postifx-policy-server.pl  view on Meta::CPAN

use Sys::Syslog qw( :DEFAULT setlogsock);

use Data::Dumper;
use lib( "./" );
use ACL;

# Global config settings
my $TC = 1;
my $debug = 1;
my $port = 12345;
our $pidfile = "/var/run/postfix-policy-server.pid";
our %redirectmap;

# Param1: Client socket
# Param2: hash_ref
sub parse_postfix_input( $$ ) {
	my ($socket,$hashref) = @_;

	local $/ = "\r\n";
	while( my $line = <$socket> ){
		chomp( $line );
		$line =~ s/\r//g;
		$line =~ s/\n//g;

		return if $line =~ /^(\r|\n)*$/;
		#print "DEBUG: $line" if $debug;

examples/postifx-policy-server.pl  view on Meta::CPAN


sub process_client($){
	my ($socket) = @_;

	# Create some stuff
	my $accept_acl = ACL->new->generate_required( 'required.txt' )->parse_acl_from_file( { Filename => "acl.permit.txt" } );
	my $reject_acl = ACL->new->generate_required( 'required.txt' )->parse_acl_from_file( { Filename => "acl.reject.txt" } );

	ACCEPT: while( my $client = $socket->accept() ){
		my $hash_ref = {};
		parse_postfix_input( $client, $hash_ref );

		my $action = convert_hashref_to_acl( $hash_ref );

		print "Action: " . Dumper($action) . "\n";

		my ($rc,$regex,$comment) = $reject_acl->match( $action );
		print Dumper( $rc ) . Dumper( $regex ) . Dumper( $comment ) . "\n";

		if( $rc ){
			print $client "action=reject $comment\n\n";



( run in 0.696 second using v1.01-cache-2.11-cpan-5a3173703d6 )