/[smeserver]/rpms/smeserver-qpsmtpd/sme8/smeserver-qpsmtpd-1.2.1-disclaimer.patch2
ViewVC logotype

Contents of /rpms/smeserver-qpsmtpd/sme8/smeserver-qpsmtpd-1.2.1-disclaimer.patch2

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


Revision 1.2 - (show annotations) (download)
Sun Jun 17 15:29:49 2007 UTC (17 years, 4 months ago) by slords
Branch: MAIN
CVS Tags: smeserver-qpsmtpd-1_2_1-45_el5_sme, smeserver-qpsmtpd-1_2_1-51_el5_sme, smeserver-qpsmtpd-1_2_1-52_el5_sme, smeserver-qpsmtpd-1_2_1-47_el5_sme, smeserver-qpsmtpd-1_2_1-49_el5_sme, smeserver-qpsmtpd-1_2_1-57_el5_sme, smeserver-qpsmtpd-1_2_1-44_el5_sme, smeserver-qpsmtpd-1_2_1-55_el5_sme, smeserver-qpsmtpd-1_2_1-56_el5_sme, smeserver-qpsmtpd-1_2_1-53_el5_sme, smeserver-qpsmtpd-1_2_1-54_el5_sme, smeserver-qpsmtpd-1_2_1-50_el5_sme, smeserver-qpsmtpd-1_2_1-43_el5_sme, smeserver-qpsmtpd-1_2_1-46_el5_sme
Changes since 1.1: +10 -15 lines
Wrong patch

1 diff -Nur -x '*.orig' -x '*.rej' smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/disclaimer mezzanine_patched_smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/disclaimer
2 --- smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/disclaimer 2007-06-17 09:21:13.000000000 -0600
3 +++ mezzanine_patched_smeserver-qpsmtpd-1.2.1/root/usr/share/qpsmtpd/plugins/disclaimer 2007-06-17 09:19:45.000000000 -0600
4 @@ -1,83 +1,98 @@
5 use MIME::Parser;
6 use MIME::Entity;
7
8 +sub register {
9 + my ($self, $qp, @args) = @_;
10 +
11 + $self->log(LOGERROR, "Bad parameters for the disclaimer plugin")
12 + if @_ % 2;
13 +
14 + %{$self->{_args}} = @args;
15 +}
16 +
17 sub hook_data_post {
18 my ($self, $transaction) = @_;
19
20 - if ($transaction->data_size > 10 * 1024 * 1024) {
21 - $self->log(LOGWARN, "Message too large to sign");
22 - return DECLINED;
23 - } elsif ( $transaction->header->get('X-Qpsmtp-Disclaimer') ) {
24 + if ( $transaction->header->get('X-Qpsmtp-Disclaimer') ) {
25 $self->log(LOGNOTICE, "Message already has disclaimer attached");
26 return DECLINED;
27 }
28
29 $self->qp->version =~ m/([\.\d]+).*/;
30 my $versionnum = $1;
31 - my @rcpt_hosts = ($self->qp->config("me"), $self->qp->config("rcpthosts"));
32
33 + my @rcpt_hosts = ($self->qp->config("me"), $self->qp->config("rcpthosts"));
34 my $fromhost = $transaction->sender->host;
35 - my $fromlocal = 0;
36 -
37 - for my $allowed (@rcpt_hosts) {
38 - $allowed =~ s/^\s*(\S+)/$1/;
39 - ($fromlocal = 1, last) if (($fromhost eq lc $allowed) or (substr($allowed,0,1) eq "." and
40 - $fromhost =~ m/\Q$allowed\E$/i));
41 - }
42 -
43 - if (($versionnum >= 0.26) and ($fromlocal == 0)) {
44 - my $more_rcpt_hosts = $self->qp->config('morercpthosts', 'map');
45 - $fromlocal = 1 if exists $more_rcpt_hosts->{$fromhost};
46 - }
47 -
48 - unless ($fromlocal) {
49 - $self->log(LOGDEBUG, "Not from local domain");
50 - return DECLINED;
51 - }
52 -
53 - my $toexternal=0;
54 - foreach my $rcpt ( $transaction->recipients ) {
55 - my $local = 0;
56 - my $host = $rcpt->host;
57 + unless ( $self->{_args}->{tag_all} ) {
58 + my $fromlocal = 0;
59
60 for my $allowed (@rcpt_hosts) {
61 $allowed =~ s/^\s*(\S+)/$1/;
62 - ($local = 1, last) if (($host eq lc $allowed) or (substr($allowed,0,1) eq "." and
63 - $host =~ m/\Q$allowed\E$/i));
64 + ($fromlocal = 1, last) if (($fromhost eq lc $allowed) or (substr($allowed,0,1) eq "." and
65 + $fromhost =~ m/\Q$allowed\E$/i));
66 }
67
68 - if (($versionnum >= 0.26) and ($local == 0)) {
69 + if (($versionnum >= 0.26) and ($fromlocal == 0)) {
70 my $more_rcpt_hosts = $self->qp->config('morercpthosts', 'map');
71 - $local = 1 if exists $more_rcpt_hosts->{$host};
72 + $fromlocal = 1 if exists $more_rcpt_hosts->{$fromhost};
73 }
74
75 - ($toexternal = 1, last) unless $local;
76 - }
77 -
78 - unless ($toexternal) {
79 - $self->log(LOGDEBUG, "Not from local domain");
80 - return DECLINED;
81 + unless ($fromlocal) {
82 + $self->log(LOGDEBUG, "Not from local domain");
83 + return DECLINED;
84 + }
85 }
86
87 - my $parser = new MIME::Parser;
88 - $parser->output_under( $self->spool_dir() );
89 - $parser->extract_uuencode(1);
90 - my $ent = $parser->parse_open( $transaction->body_filename() );
91 -
92 + my $specific = 0;
93 my @lines;
94 if ( @lines = $self->qp->config("disclaimer_$fromhost") ) {
95 $self->log(LOGDEBUG, "Found disclaimer for domain: $fromhost");
96 + $specific = 1;
97 } elsif ( @lines = $self->qp->config("disclaimer") ) {
98 $self->log(LOGDEBUG, "Found general disclaimer");
99 } else {
100 $self->log(LOGERROR, "No disclaimer found for domain: $fromhost");
101 return DECLINED;
102 }
103 - $ent->make_multipart( 'mixed', Force => 1 ) if $ent->parts == 2 && $ent->mime_type eq 'multipart/alternative';
104 +
105 + unless ( $self->{_args}->{tag_all} ) {
106 + my $toexternal=0;
107 + foreach my $rcpt ( $transaction->recipients ) {
108 + my $local = 0;
109 + my $host = $rcpt->host;
110 +
111 + ($toexternal = 1, last) if ( $specific && $host ne $fromhost);
112 +
113 + for my $allowed (@rcpt_hosts) {
114 + $allowed =~ s/^\s*(\S+)/$1/;
115 + ($local = 1, last) if (($host eq lc $allowed) or (substr($allowed,0,1) eq "." and
116 + $host =~ m/\Q$allowed\E$/i));
117 + }
118 +
119 + if (($versionnum >= 0.26) and ($local == 0)) {
120 + my $more_rcpt_hosts = $self->qp->config('morercpthosts', 'map');
121 + $local = 1 if exists $more_rcpt_hosts->{$host};
122 + }
123 +
124 + ($toexternal = 1, last) unless $local;
125 + }
126 +
127 + unless ($toexternal) {
128 + $self->log(LOGDEBUG, "Not to any external domain");
129 + return DECLINED;
130 + }
131 + }
132 +
133 + my $parser = new MIME::Parser;
134 + $parser->output_under( $self->spool_dir() );
135 + $parser->extract_uuencode(1);
136 + my $ent = $parser->parse_open( $transaction->body_filename() );
137 +
138 + $ent->make_multipart( 'mixed', Force => 1 ) if $ent->mime_type ne 'multipart/mixed';
139 $ent->attach( Data => join("\n", @lines),
140 - Encoding => '-SUGGEST',
141 - Filename => 'disclaimer.txt',
142 - Type => 'text/plain');
143 + Encoding => $self->{_args}->{mime_encoding} || '-SUGGEST',
144 + Filename => $self->{_args}->{mime_filename} || 'disclaimer.txt',
145 + Type => $self->{_args}->{mime_type} || 'text/plain');
146 if ($ent->parts <= 2) {
147 $transaction->header->empty();
148 $transaction->header($ent->head());

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