#! @PERL@ -wT -I@cgibin@ # Display a message in a user's log directory # --S-LICENSE-- # $Revision: 1.41 $ # @configure_input@ # This file must protected with an equivalent to httpd.conf lines # in the README file. use strict 'subs'; use common; # display the message literally if asked if ($query{literal}) { my($buf, $msg, $path); # punt to directory listing if no message specified punt2("no message specified for listing", $list_log_url) if (!$query{msg}); punt2("bad message $query{msg} specified for listing", $list_log_url) if ($query{msg} !~ /^([a-zA-Z\d][a-zA-Z\d]{5}[a-zA-Z\d.]{0,4})$/); $msg = $1; $path = msg2path($msg); if (!open(MSG, $path)) { html_head("Message $msg for $user"); print "

Cannot open $path: $!\n"; html_footer(); print "\n"; exit; } print "Content-type: text/plain\n"; print "Cache-Control: max-age=0, must-revalidate\n\n"; print $buf while (read(MSG, $buf, 4*1024)); exit; } # find the previous and next messages get_log_msgs($query{msg}, 0); $query{msg} = $msgs_num[$#msgs_num] if (!$query{msg} && $#msgs_num >= 0); my $msg = $query{msg} || ''; my $path = msg2path($msg, ''); if (!$msg || !$msgs_cache{$msg}) { punt2("message $msg has disappeared", $list_log_url) } else { my($msg_num, $older_msg, $oldest_msg, $newer_msg, $newest_msg); if ($#msgs_num < 0) { $newest_msg = ""; $oldest_msg = ""; } else { $newest_msg = "$msgs_num[$#msgs_num]"; $oldest_msg = $msgs_num[0]; } if (!defined($msg_first) || $msgs_num[$msg_first] ne $msg) { $msg_num = ""; $newer_msg = $newest_msg; $older_msg = $oldest_msg; } else { $msg_num = "#" . ($msg_first+1); if ($msg_first < $#msgs_num) { $newer_msg = $msgs_num[$msg_first+1] } else { $newer_msg = $newest_msg; } if ($msg_first > 0) { $older_msg = $msgs_num[$msg_first-1]; } else { $older_msg = $oldest_msg; } } $oldest_link = "$list_msg_link${url_ques}msg=$oldest_msg\">Oldest"; $older_link = "$list_msg_link${url_ques}msg=$older_msg\">Older"; $newer_link = "$list_msg_link${url_ques}msg=$newer_msg\">Newer"; $newest_link = "$list_msg_link\">Newest"; html_head("Message $msg_num of " . ($#msgs_num+1) . " for $user"); common_buttons(); print <$newest_link $newer_link $older_link $oldest_link

$list_msg_link${url_ques}msg=$msg&literal=yes" TARGET="DCC literal log file">Literal log file $path contents for reporting or analysis. EOF } # pass a greylist triple if ($query{greywhite}) { my($cksum, $sight); html_whine("bogus greywhite checksum \"$query{greywhite}\"") if ($query{greywhite} !~ /^([a-z0-9 ]+)$/); $cksum = $1; $sight = `@libexecdir@/dccsight -G '$cksum' 2>&1`; if ($sight =~ /^(Pass|Embargo Ended)\s*$/i){ print "\n

\ngreylist embargo ended"; } else { print "\n

\n@libexecdir@/dccsight -G '$cksum': $sight"; } } @error = parse_log_msg($msg); if (defined $error[0]) { print "

$error[0]: $error[1]\n"; html_footer(); print "\n\n"; exit; } print <


Envelope

EOF print "
 \n $msg_date\n"; print_envelope_link(1, "IP address", "IP", $msg_client_name, $msg_ip); print_envelope_link(scalar "helo" =~ /^($sub_hdrs)$/i, "HELO", "substitute HELO", "", $msg_helo); print_envelope_link(1, "env_From", "env_From", "", $msg_env_from); print_envelope_link(scalar "mail_host" =~ /^($sub_hdrs)$/i, "mail_host", "substitute mail_host", "", $msg_mail_host); map print_envelope_link(1, "env_To", "env_To", "", html_str_encode($_)), @msg_env_to; # make links for whitelisting the body checksusm $msg_cksums =~ s/(Body|Fuz1|Fuz2):\s+(\S{8}\s\S{8}\s\S{8}\s\S{8}\s)/make_hex_link($1,$2)/eig; # make whitelisting links for greylist checksums with active embargos while ($msg_cksums =~ /^\s+([a-z0-9]{8}(?: [a-z0-9]{8}){3}) Embargo[\s#0-9]*$/mi) { my($sum, $sight, $link, $text); $sum = $1; $sight = `@libexecdir@/dccsight -QG "$sum" 2>&1`; if ($sight =~ /Embargo.*/) { $link = make_greywhite_link($sum); $text = " select checksum to end greylist embargo of sender\n"; } else { $link = "$sum"; $text = " current value: " . html_str_encode($sight); } $msg_cksums =~ s/(^\s+)$sum(.*$)\n/$1$link$2\n$1$text/m; } print <


Headers

$msg_hdrs

Body

$msg_body


Checksums

$msg_cksums
EOF html_footer(); print "\n\n"; exit; ############################################################################# sub print_envelope_link { my($enable, $label, $type, $text, $value) = @_; # skip the row if the value is absent return if (! $value); print "
"; print html_str_encode($label) if ($label); print ":  \n "; if (! $enable) { print html_str_encode($text . $value); print "\n"; return; } if ($text) { print $text; print " "; } print $edit_link; print "${url_ques}type="; print url_encode($type); print "&val="; print url_encode($value); print "&msg=$query{msg}" if ($query{msg}); print "&auto=1#cur_key\">"; print html_str_encode($value); print "\n"; } sub make_hex_link { my($type, $sum) = @_; my($str); # cannot whitelist missing fuz2 place keepers return "$type: $sum" if ($sum =~ /^[ 0]+$/); $str = "$edit_link${url_ques}type="; $str .= url_encode("hex $type"); $str .= "&val="; $str .= url_encode($sum); $str .= "&msg=$msg&auto=1#cur_key\">$type: $sum"; return $str; } sub make_greywhite_link { my($sum) = @_; my($str); $str = "$list_msg_link${url_ques}msg=$msg&greywhite="; $str .= url_encode($sum); $str .= "\">$sum"; return $str; }