/[smeserver]/rpms/qpsmtpd-plugins/sme7/check_goodrcptto_dos2unix.patch
ViewVC logotype

Contents of /rpms/qpsmtpd-plugins/sme7/check_goodrcptto_dos2unix.patch

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


Revision 1.1 - (show annotations) (download)
Tue Jun 12 17:17:24 2007 UTC (17 years, 5 months ago) by slords
Branch: MAIN
CVS Tags: qpsmtpd-plugins-0_0_1-3_el4_sme, HEAD
Import on branch sme7 of package qpsmtpd-plugins-0.0.1-3.el4.sme.src.rpm

1 diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-plugins-openfusion-20050429/plugins/check_goodrcptto mezzanine_patched_qpsmtpd-plugins-openfusion-20050429/plugins/check_goodrcptto
2 --- qpsmtpd-plugins-openfusion-20050429/plugins/check_goodrcptto 2007-04-12 09:49:31.000000000 -0600
3 +++ mezzanine_patched_qpsmtpd-plugins-openfusion-20050429/plugins/check_goodrcptto 2007-04-12 09:49:13.000000000 -0600
4 @@ -1,95 +1,95 @@
5 -=head1 NAME
6 -
7 -check_goodrcptto
8 -
9 -=head1 DESCRIPTION
10 -
11 -This plugin denies all recipients except those in the goodrcptto config file
12 -(i.e. like badrcptto, but whitelisting). It supports recipient username
13 -extension stripping, and both domain ('@domain.com') and username (bare
14 -'postmaster') wildcard entries in the config file.
15 -
16 -Useful where something like check_delivery is overkill or not an option
17 -(e.g. relays, bastion hosts).
18 -
19 -=head1 CONFIG
20 -
21 -The following parameters can be passed to check_goodrcptto:
22 -
23 -=over 4
24 -
25 -=item extn <char>
26 -
27 -If set, check_goodrcptto does its checks using both the username as given and
28 -the username stripped of any extensions beginning with <char>.
29 -
30 -=item deny_note <name>
31 -
32 -If set, check_goodrcptto will set a connection note with the given name when
33 -denying a recipient. If <name> is of the form 'name=value', then the specified
34 -value will be used instead of the default '1'. If the connection note already
35 -exists, the value will be incremented (if numeric), instead of set.
36 -
37 -
38 -=back
39 -
40 -=cut
41 -
42 -my $VERSION = 0.03;
43 -
44 -sub register {
45 - my ($self, $qp, %arg) = @_;
46 - $self->register_hook("rcpt", "check_goodrcptto");
47 - $self->{_extn} = $arg{extn} if $arg{extn};
48 - $self->{_deny_note} = $arg{deny_note} if $arg{deny_note};
49 -}
50 -
51 -sub check_goodrcptto {
52 - my ($self, $transaction, $recipient) = @_;
53 - return (DECLINED) if $self->qp->connection->relay_client;
54 - $self->log(LOGINFO, "stripping '$self->{_extn}' extensions") if $self->{_extn};
55 - my @goodrcptto = $self->qp->config("goodrcptto") or return (DECLINED);
56 - my $host = lc $recipient->host;
57 - my $user = lc $recipient->user;
58 - return (DECLINED) unless $host && $user;
59 - # Setup users and address stripped of extensions
60 - my (@parts, @users, @addresses);
61 - my $extn = $self->{_extn};
62 - if ($extn) {
63 - @parts = split /$extn/, $user;
64 - foreach (0..$#parts) {
65 - push @users, join $extn, @parts[0..$_];
66 - }
67 - $self->log(LOGDEBUG, "address includes extn '$extn', checking users: " . (join ' ', @users));
68 - } else {
69 - push @users, $user;
70 - }
71 - @addresses = map { $_ . "@" . $host } @users;
72 - for my $good (@goodrcptto) {
73 - $good =~ s/^\s*(\S+).*/\L$1/;
74 - foreach (@addresses) {
75 - return (DECLINED) if $good eq $_;
76 - }
77 - # Allow wildcard '@domain.com' entries
78 - return (DECLINED) if substr($good,0,1) eq '@' && $good eq "\@$host";
79 - # Allow wildcard bare 'username' entries e.g. 'postmaster'
80 - if (index($good,'@') < 0) {
81 - foreach (@users) {
82 - return (DECLINED) if $good eq $_;
83 - }
84 - }
85 - }
86 - $self->log(LOGWARN, "recipient $addresses[$#addresses] denied");
87 - # Set/increment the specified deny_note, if applicable
88 - if ($self->{_deny_note}) {
89 - my ($name, $value) = ($self->{_deny_note} =~ m/^([-\w]+)(?:=([\d.]+))?/);
90 - $value ||= 1;
91 - $self->qp->connection->notes($name, ($self->qp->connection->notes($name) || 0) + $value)
92 - if $name;
93 - $self->log(LOGDEBUG, "deny_note: $name=" . $self->qp->connection->notes($name));
94 - }
95 - return (DENY, "invalid recipient $addresses[$#addresses]");
96 -}
97 -
98 -# arch-tag: 2d2195a5-27b0-465d-a68f-f425efae2cc0
99 -
100 +=head1 NAME
101 +
102 +check_goodrcptto
103 +
104 +=head1 DESCRIPTION
105 +
106 +This plugin denies all recipients except those in the goodrcptto config file
107 +(i.e. like badrcptto, but whitelisting). It supports recipient username
108 +extension stripping, and both domain ('@domain.com') and username (bare
109 +'postmaster') wildcard entries in the config file.
110 +
111 +Useful where something like check_delivery is overkill or not an option
112 +(e.g. relays, bastion hosts).
113 +
114 +=head1 CONFIG
115 +
116 +The following parameters can be passed to check_goodrcptto:
117 +
118 +=over 4
119 +
120 +=item extn <char>
121 +
122 +If set, check_goodrcptto does its checks using both the username as given and
123 +the username stripped of any extensions beginning with <char>.
124 +
125 +=item deny_note <name>
126 +
127 +If set, check_goodrcptto will set a connection note with the given name when
128 +denying a recipient. If <name> is of the form 'name=value', then the specified
129 +value will be used instead of the default '1'. If the connection note already
130 +exists, the value will be incremented (if numeric), instead of set.
131 +
132 +
133 +=back
134 +
135 +=cut
136 +
137 +my $VERSION = 0.03;
138 +
139 +sub register {
140 + my ($self, $qp, %arg) = @_;
141 + $self->register_hook("rcpt", "check_goodrcptto");
142 + $self->{_extn} = $arg{extn} if $arg{extn};
143 + $self->{_deny_note} = $arg{deny_note} if $arg{deny_note};
144 +}
145 +
146 +sub check_goodrcptto {
147 + my ($self, $transaction, $recipient) = @_;
148 + return (DECLINED) if $self->qp->connection->relay_client;
149 + $self->log(LOGINFO, "stripping '$self->{_extn}' extensions") if $self->{_extn};
150 + my @goodrcptto = $self->qp->config("goodrcptto") or return (DECLINED);
151 + my $host = lc $recipient->host;
152 + my $user = lc $recipient->user;
153 + return (DECLINED) unless $host && $user;
154 + # Setup users and address stripped of extensions
155 + my (@parts, @users, @addresses);
156 + my $extn = $self->{_extn};
157 + if ($extn) {
158 + @parts = split /$extn/, $user;
159 + foreach (0..$#parts) {
160 + push @users, join $extn, @parts[0..$_];
161 + }
162 + $self->log(LOGDEBUG, "address includes extn '$extn', checking users: " . (join ' ', @users));
163 + } else {
164 + push @users, $user;
165 + }
166 + @addresses = map { $_ . "@" . $host } @users;
167 + for my $good (@goodrcptto) {
168 + $good =~ s/^\s*(\S+).*/\L$1/;
169 + foreach (@addresses) {
170 + return (DECLINED) if $good eq $_;
171 + }
172 + # Allow wildcard '@domain.com' entries
173 + return (DECLINED) if substr($good,0,1) eq '@' && $good eq "\@$host";
174 + # Allow wildcard bare 'username' entries e.g. 'postmaster'
175 + if (index($good,'@') < 0) {
176 + foreach (@users) {
177 + return (DECLINED) if $good eq $_;
178 + }
179 + }
180 + }
181 + $self->log(LOGWARN, "recipient $addresses[$#addresses] denied");
182 + # Set/increment the specified deny_note, if applicable
183 + if ($self->{_deny_note}) {
184 + my ($name, $value) = ($self->{_deny_note} =~ m/^([-\w]+)(?:=([\d.]+))?/);
185 + $value ||= 1;
186 + $self->qp->connection->notes($name, ($self->qp->connection->notes($name) || 0) + $value)
187 + if $name;
188 + $self->log(LOGDEBUG, "deny_note: $name=" . $self->qp->connection->notes($name));
189 + }
190 + return (DENY, "invalid recipient $addresses[$#addresses]");
191 +}
192 +
193 +# arch-tag: 2d2195a5-27b0-465d-a68f-f425efae2cc0
194 +

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