/[smeserver]/rpms/smeserver-qpsmtpd/sme8/smeserver-qpsmtpd-1.2.1-peers_plugin.patch
ViewVC logotype

Annotation of /rpms/smeserver-qpsmtpd/sme8/smeserver-qpsmtpd-1.2.1-peers_plugin.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Tue Oct 7 15:06:54 2008 UTC (16 years ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New streams

1 slords 1.1 diff -Nur -x '*.orig' -x '*.rej' smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/peers mezzanine_patched_smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/peers
2     --- smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/peers 1969-12-31 19:00:00.000000000 -0500
3     +++ mezzanine_patched_smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/peers 2006-09-08 10:40:49.000000000 -0400
4     @@ -0,0 +1,70 @@
5     +# this plugin checks the peers directory for config
6     +# file most closely matching the client IP address
7     +# and loads it if found.
8     +#
9     +# Note that init() borrows some internals from Qpsmtpd.pm - I
10     +# didn't see a suitable public interface.
11     +
12     +sub init {
13     + my $self = shift;
14     + my $qp = shift;
15     + my $plugins_list_file = shift;
16     + my @plugins = $qp->config($plugins_list_file);
17     + my $dir = $qp->plugin_dir;
18     +
19     + for my $plugin (@plugins) {
20     + my $plugin_name = $plugin;
21     + $plugin =~ s/:\d+$//; # after this point, only used for filename
22     +
23     + # Escape everything into valid perl identifiers
24     + $plugin_name =~ s/([^A-Za-z0-9_\/])/sprintf("_%2x",unpack("C",$1))/eg;
25     +
26     + # second pass cares for slashes and words starting with a digit
27     + $plugin_name =~ s{
28     + (/+) # directory
29     + (\d?) # package's first character
30     + }[
31     + "::" . (length $2 ? sprintf("_%2x",unpack("C",$2)) : "")
32     + ]egx;
33     +
34     + my $package = "Qpsmtpd::Plugin::$plugin_name";
35     +
36     + # don't reload plugins if they are already loaded
37     + unless ( defined &{"${package}::plugin_name"} ) {
38     + Qpsmtpd::Plugin->compile($plugin_name,
39     + $package, "$dir/$plugin", $self->{_test_mode});
40     + $self->log(LOGDEBUG, "Compiling $plugin")
41     + unless $plugin =~ /logging/;
42     + }
43     + }
44     +
45     + return 1;
46     +}
47     +sub _peer_plugins {
48     + my $qp = shift;
49     + my $config = shift;
50     + my @plugins = $qp->config($config);
51     + $qp->log(LOGNOTICE, "loading plugins @plugins from $config");
52     +
53     + return $qp->_load_plugins($qp->plugin_dir, @plugins);
54     +}
55     +
56     +sub hook_connect {
57     + my ($self, $transaction) = @_;
58     + my $qp = $self->qp;
59     + my $connection = $qp->connection;
60     +
61     + my $client_ip = $qp->connection->remote_ip;
62     + while ($client_ip) {
63     + if (-f "config/peers/$client_ip") {
64     + _peer_plugins($qp, "peers/$client_ip");
65     + return (DECLINED);
66     + }
67     + $client_ip =~ s/\.+\d+\.?$//; # strip off another 8 bits
68     + }
69     + if (-f "config/peers/0") {
70     + _peer_plugins($qp, "peers/0");
71     + return (DECLINED);
72     + }
73     + return (DENY);
74     +}

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed