Changes for Debian Wheezy.
[usenet/INN.git] / filter / filter_nnrpd.pl
CommitLineData
8faa6b21
TH
1#
2# Do any initialization steps.
3#
4use Digest::MD5 qw(md5_base64);
121fcbc1 5use Digest::SHA();
8faa6b21
TH
6use Digest::HMAC_SHA1();
7use MIME::Base64();
8
9$CANCEL_LOCK = 'secretword';
10
11#
12# Filter
13#
14sub filter_post {
15 my $rval = "" ; # assume we'll accept.
16 $modify_headers = 1;
17
18 # Cancel-Lock / Cancel-Key
19 add_cancel_lock(\%hdr, $user);
20
21 if (exists( $hdr{"Control"} ) && $hdr{"Control"} =~ m/^cancel\s+(<[^>]+>)/i) {
22 my $key = calc_cancel_key($user, $1);
23 add_cancel_item(\%hdr, 'Cancel-Key', $key);
24 }
25 elsif (exists( $hdr{"Supersedes"} )) {
26 my $key = calc_cancel_key($user, $hdr{"Supersedes"});
27 add_cancel_item(\%hdr, 'Cancel-Key', $key);
121fcbc1 28 }
8faa6b21
TH
29
30 return $rval;
31}
32
33#
34# Cancel-Lock / Cancel-Key
35#
36sub add_cancel_item($$$) {
37 my ( $r_hdr, $name, $value ) = @_;
38 my $prefix = $r_hdr->{$name};
39 $prefix = defined($prefix) ? $prefix . ' sha1:' : 'sha1:';
40 $r_hdr->{$name} = $prefix . $value;
41}
42
43sub calc_cancel_key($$) {
44 my ( $user, $message_id ) = @_;
45 return MIME::Base64::encode(Digest::HMAC_SHA1::hmac_sha1($message_id, $user . $CANCEL_LOCK), '');
46}
47
48sub add_cancel_lock($$) {
49 my ( $r_hdr, $user ) = @_;
50 my $key = calc_cancel_key($user, $r_hdr->{'Message-ID'});
121fcbc1 51 my $lock = MIME::Base64::encode(Digest::SHA::sha1($key), '');
8faa6b21 52 add_cancel_item($r_hdr, 'Cancel-Lock', $lock);
121fcbc1 53}
This page took 0.011425 seconds and 4 git commands to generate.