]> git.deb.at Git - pkg/t-prot.git/blob - contrib/t-prot-r1.51-debug.diff
Imported Upstream version 0.54.1
[pkg/t-prot.git] / contrib / t-prot-r1.51-debug.diff
1 --- t-prot      2002-03-25 02:15:50.000000000 +0100
2 +++ t-prot-d    2002-03-28 16:27:02.000000000 +0100
3 @@ -9,12 +9,13 @@
4         $EX_OK $EX_USAGE $EX_DATAERR $EX_UNAVAILABLE $EX_BOUNCE
5         $ad $ads $boun $cr $diff $elli $footers $hdrs $indent $lsig $maxsig
6         $mda $ml $ms $mua $ofile $sendmail $sig $sysl $trad $trsp
7 +       $dc $debugpath
8  );
9  
10  
11  # Version info
12  $VER                   = '0.54';
13 -$REV                   = '';
14 +$REV                   = '-debug';
15  $REL                   = q$Revision: 1.51 $; chop($REL);
16  # From <sysexits.h>
17  # (you might have to adjust those if not using GNU libc)
18 @@ -29,6 +30,10 @@
19  $sendmail              = '/usr/sbin/sendmail -oi'; # MTA expecting mail on STDIN
20  $boun                  = "Blocked by $0: This user does not accept TOFUed email. Please see <http://learn.to/edit_messages/> and <http://www.escape.de/users/tolot/mutt/> for more info. Have a nice day!\n";
21  $ofile                 = '-';  # use STDOUT if nothing is specified
22 +$dc                            = 0;    # debug dump counter
23 +$debugpath             = '/tmp';
24 +                                               # this should better be changed by command line for
25 +                                               # confidential messages
26  # end of user adjusted vals
27  
28  
29 @@ -39,6 +44,7 @@
30    -A=DIRECTORY    ad footer directory, treat ad footers as signature
31    -c              merge multiple blank lines
32    -d, --debug     print notice to syslog when bouncing; requires -p
33 +  --debugpath=DIR where to dump debug info
34    --diff          tolerate diffs appended *after* the signature
35    -e              force ellipsis for excessive punctuation
36    -h, --help      show this short help and exit
37 @@ -64,9 +70,30 @@
38  # version(): print version info and exit with appropriate exit code
39  sub version {
40      print "$0 v$VER$REV ($REL), Jochen Striepe <t-prot\@tolot.escape.de>
41 +This is a debugging version. DO NOT INSTALL THIS VERSION FOR DAILY USE!
42  Get the latest version at <http://www.escape.de/users/tolot/mutt/>\n";
43      exit($EX_OK);
44  }
45 +  
46 +# write useful debugging output
47 +# usage: debug_dump('/tmp/foo', $foo, $bar, @klotz);
48 +sub debug_dump {
49 +       if (scalar(@_)<2) { die "bad parameters"; }
50 +       my $f = shift;
51 +       if (-l $f) { die "We won't write to $f for security reasons"; }
52 +
53 +       open(DBG, ">$f") || die "Could not open $f: $!";
54 +       my $foo;
55 +       while (@_) {
56 +               $foo = shift; 
57 +               chomp($foo);
58 +               $^W = 0;
59 +               print DBG "$foo\n"; 
60 +               $^W = 1;
61 +       }
62 +       close DBG;
63 +}
64 +
65  
66  # remove_footers(): remove any trailing appearance of footers contained
67  # in the given directory.
68 @@ -139,6 +166,7 @@
69         for ($x=0; $x<$#$lines; $x++) { if (@$lines[$x] =~ /^$/) { last; }; }
70         @hdr = @$lines[0..$x];
71         splice(@$lines, 0, $x+1);
72 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
73  
74         # See if we have a multipart content type. If yes, see if it is already
75         # ripped (e.g. by mutt(1)), otherwise only leave the first part if it
76 @@ -240,6 +268,7 @@
77                                 last;
78                         }
79                 }
80 +               debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
81  
82                 # Pipe message/rfc822 parts to another instance of process_msg()
83                 # for further processing.
84 @@ -267,12 +296,15 @@
85                         }
86                 }
87         }
88 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
89  
90         # Remove ML footers:
91         remove_footers($lines, \@ftr, $footers, undef);
92 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
93  
94         # Remove ad footers:
95         remove_footers($lines, \@ads, $ads, undef);
96 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
97  
98         # Remove signature:
99         if (scalar(@$lines)) { 
100 @@ -307,6 +339,7 @@
101                         }
102                 }
103         }
104 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
105  
106         # Now care about TOFU.
107         # One common mispractice is M$ style TOFU:
108 @@ -331,6 +364,7 @@
109                 $j = scalar(@$lines)-$x;
110                 splice(@$lines, $x); 
111         }
112 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
113  
114         # Nothing? Then try traditional TOFU:
115         if ($trad && (!$j) && !$vrb[$#$lines]) {
116 @@ -345,6 +379,7 @@
117                         pop(@$lines);
118                 }
119         }
120 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
121  
122         # OK, if we found TOFU, we will leave a message that we were here...
123         if ($j) { 
124 @@ -368,6 +403,7 @@
125  
126         push(@$lines, "[---=| TOFU protection by $0: $j lines snipped |=---]\n");
127         }
128 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
129  
130  
131         # Care for trailing whitespaces:
132 @@ -376,6 +412,7 @@
133                         if (!$vrb[$x]) { $$lines[$x] =~ s/[\ \t]+$//; }
134                 }
135         }
136 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
137  
138         # Care for punctuation abuse:
139         if ($elli) {
140 @@ -383,6 +420,7 @@
141                 if (!$vrb[$x]) { $$lines[$x] =~ s/([.?!])(\1{2})\1+/$1 . $2/eg; }
142             }
143         }
144 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
145  
146         # (Nearly) at last care for multiple blank lines. (Do not do this
147         # earlier -- the way it is done right now would screw up the verbatim
148 @@ -396,6 +434,7 @@
149                         else { $t = 0; }
150             }
151         }
152 +       debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
153  
154         # Everything changing the body is done now. Time to fix the line count
155         # header so naive clients do not get confused. Just to be sure, append
156 @@ -428,12 +467,13 @@
157  # get command line params:
158  $0 =~ s!^.*/!!;
159  Getopt::Mixed::init('a A=s c d e h i=s L=s l m M=s o=s P=s p=s r S:i'.
160 -       ' s t v w debug>d diff help>h mua>M version>v');
161 +       ' s t v w debug>d debugpath diff help>h mua>M version>v');
162  while (my ($opt, $val, $pretty) = nextOption()) {
163         if    ($opt eq 'a')     { $ad = 1; }
164         elsif ($opt eq 'A')     { $ads = $val; }
165      elsif ($opt eq 'c')        { $cr = 1; }
166      elsif ($opt eq 'd')        { $sysl = 1; }
167 +       elsif ($opt eq 'debugpath') { $debugpath = $val; }
168      elsif ($opt eq 'diff')     { $diff = 1; }
169      elsif ($opt eq 'e')        { $elli = 1; }
170      elsif ($opt eq 'i')        { $ifile = $val; }
171 @@ -454,17 +494,26 @@
172  }
173  Getopt::Mixed::cleanup();
174  if (($ml && $footers eq '')||($ad && $ads eq '')) { help(); }
175 -
176 +$debugpath .= '/t-prot-d';
177  
178  # Read message:
179  open(IN, $ifile) || die "Could not open $ifile: $!";
180  my @message = <IN>;
181  close IN;
182 +debug_dump($debugpath.'_'.$$.'_'.$dc++, 
183 +       $VER.$REV, $REL,
184 +       "ad=$ad", "ads=$ads", "cr=$cr", "sysl=$sysl", "elli=$elli", "ml=$ml",
185 +       "ms=$ms", "mda=$mda", "mua=$mua", "hdrs=$hdrs", "lsig=$lsig", "sig=$sig",
186 +       "trad=$trad", "trsp=$trsp", "footers=$footers", "ifile=$ifile",
187 +       "ofile=$ofile", "maxsig=$maxsig", "indent=$indent", "sendmail=$sendmail",
188 +       "boun=$boun");
189 +debug_dump($debugpath.'_'.$$.'_'.$dc++, @message);
190  
191  # this should be self-explanatory:
192  process_msg(\@message);
193  
194  # Finally, print clean lines:
195  write_msg(($mda?"|$sendmail $mda":">$ofile"), \@message);
196 +debug_dump($debugpath.'_'.$$.'_'.$dc++, @message);
197  
198  # eof