line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mail::IspMailGate::Filter::PGP; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require 5.004; |
7
|
2
|
|
|
2
|
|
1611
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1436
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Mail::IspMailGate::Filter; |
10
|
|
|
|
|
|
|
require MIME::Decoder::PGP; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
MIME::Decoder::PGP->install('x-pgp'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@Mail::IspMailGate::Filter::PGP::ISA = qw(Mail::IspMailGate::Filter::InOut); |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
|
sub getSign { "X-ispMailGate-PGP"; }; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
##################################################################### |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# Name: mustFilter |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
# Purpose: determines wether this message must be filtered and |
24
|
|
|
|
|
|
|
# allowed to modify $self the message and so on |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# Inputs: $self - This class |
27
|
|
|
|
|
|
|
# $entity - the whole message |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# Returns: 1 if it must be, else 0 |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
##################################################################### |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub mustFilter ($$) { |
34
|
0
|
|
|
0
|
1
|
|
my($self, $entity) = @_; |
35
|
0
|
0
|
|
|
|
|
if (!$self->SUPER::mustFilter($entity)) { |
36
|
0
|
|
|
|
|
|
return 0; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if ($self->{'recDirection'} eq 'pos') { |
40
|
0
|
0
|
|
|
|
|
if (!$self->{'uid'}) { |
41
|
0
|
|
|
|
|
|
return 0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} else { |
44
|
0
|
|
|
|
|
|
my($head) = $entity->head(); |
45
|
0
|
|
|
|
|
|
my($uid) = $head->mime_attr('X-ispMailGate-PGP.uid'); |
46
|
0
|
0
|
0
|
|
|
|
if (!$uid || !$self->{'passPhrases'}->{$uid}) { |
47
|
0
|
|
|
|
|
|
return 0; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return 1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
##################################################################### |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
# Name: filterFile |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
# Purpse: do the filter process for one file. Compress it or |
60
|
|
|
|
|
|
|
# uncompress it. the direction will be guessed, if this |
61
|
|
|
|
|
|
|
# fails the initial one will be used |
62
|
|
|
|
|
|
|
# If the direction is 'neg' the packer will |
63
|
|
|
|
|
|
|
# be guessed. Only if this fails the 'packer' attribute will |
64
|
|
|
|
|
|
|
# be tried |
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
# Inputs: $self - This class |
67
|
|
|
|
|
|
|
# $attr - hash-ref to filter attribute |
68
|
|
|
|
|
|
|
# 1. 'body' |
69
|
|
|
|
|
|
|
# 2. 'parser' |
70
|
|
|
|
|
|
|
# 3. 'head' |
71
|
|
|
|
|
|
|
# 4. 'globHead' |
72
|
|
|
|
|
|
|
# |
73
|
|
|
|
|
|
|
# Returns: error message, if any |
74
|
|
|
|
|
|
|
# |
75
|
|
|
|
|
|
|
##################################################################### |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub filterFile ($$) { |
78
|
0
|
|
|
0
|
1
|
|
my ($self, $attr) = @_; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my ($ret); |
81
|
0
|
0
|
|
|
|
|
if($ret = $self->SUPER::filterFile($attr)) { |
82
|
0
|
|
|
|
|
|
return $ret; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my($head) = $attr->{'head'}; |
86
|
0
|
|
|
|
|
|
$head->delete('Content-Transfer-Encoding'); |
87
|
0
|
0
|
|
|
|
|
if ($self->{'recDirection'} eq 'pos') { |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# All we do is setting the encoding type to x-pgp. |
90
|
|
|
|
|
|
|
# MIME::Decoder::PGP will do the rest. |
91
|
|
|
|
|
|
|
# |
92
|
0
|
|
|
|
|
|
$head->mime_attr("Content-Transfer-Encoding", "x-pgp"); |
93
|
0
|
|
|
|
|
|
$head->mime_attr("Content-Transfer-Encoding.uid", $self->{'uid'}); |
94
|
|
|
|
|
|
|
} else { |
95
|
|
|
|
|
|
|
# |
96
|
|
|
|
|
|
|
# All we do is resetting the encoding type. |
97
|
|
|
|
|
|
|
# |
98
|
0
|
|
|
|
|
|
my ($type) = split('/', $head->get("Content-Type")); |
99
|
0
|
0
|
0
|
|
|
|
if ($type eq 'text' || $type eq 'message') { |
100
|
0
|
|
|
|
|
|
$head->set('Content-Transfer-Encoding', 'quoted-printable'); |
101
|
|
|
|
|
|
|
} else { |
102
|
0
|
|
|
|
|
|
$head->set('Content-Transfer-Encoding', 'base64'); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
''; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub IsEq ($$) { |
111
|
0
|
|
|
0
|
1
|
|
my($self, $cmp) = @_; |
112
|
0
|
0
|
0
|
|
|
|
$self->SUPER::IsEq($cmp) && |
113
|
|
|
|
|
|
|
($self->{'direction'} eq 'neg' || |
114
|
|
|
|
|
|
|
$self->{'uid'} eq $cmp->{'uid'}); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub hookFilter ($$) { |
119
|
0
|
|
|
0
|
1
|
|
my($self, $entity) = @_; |
120
|
0
|
|
|
|
|
|
my($head) = $entity->head; |
121
|
0
|
0
|
|
|
|
|
if ($self->{'recDirection'} eq 'pos') { |
122
|
0
|
|
|
|
|
|
$head->mime_attr($self->getSign(), $self->{'recDirection'}); |
123
|
0
|
|
|
|
|
|
$head->mime_attr($self->getSign() . ".uid", $self->{'uid'}); |
124
|
|
|
|
|
|
|
} else { |
125
|
0
|
|
|
|
|
|
$head->delete($self->getSign()); |
126
|
|
|
|
|
|
|
} |
127
|
0
|
|
|
|
|
|
delete $self->{'recDirection'}; |
128
|
0
|
|
|
|
|
|
''; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub new ($$) { |
133
|
0
|
|
|
0
|
1
|
|
my($class, $attr) = @_; |
134
|
0
|
|
|
|
|
|
my($self) = $class->SUPER::new($attr); |
135
|
0
|
|
|
|
|
|
my $cfg = $Mail::IspMailGate::Config::config; |
136
|
0
|
0
|
|
|
|
|
if ($self) { |
137
|
0
|
0
|
|
|
|
|
if (!exists($self->{'uid'})) { |
138
|
0
|
|
|
|
|
|
$self->{'uid'} = $cfg->{'pgp'}->{'uid'}; |
139
|
|
|
|
|
|
|
} |
140
|
0
|
0
|
|
|
|
|
if (!exists($self->{'passPhrases'})) { |
141
|
0
|
|
|
|
|
|
$self->{'passPhrases'} = $cfg->{'pgp'}->{'uids'}; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
$self; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
__END__ |