#! /usr/local/bin/perl -wT # Display a message in a user's log directory # Copyright (c) 2006 by Rhyolite Software, LLC # # This agreement is not applicable to any entity which sells anti-spam # solutions to others or provides an anti-spam solution as part of a # security solution sold to other entities, or to a private network # which employs the DCC or uses data provided by operation of the DCC # but does not provide corresponding data to other users. # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # Parties not eligible to receive a license under this agreement can # obtain a commercial license to use DCC and permission to use # U.S. Patent 6,330,590 by contacting Commtouch at http://www.commtouch.com/ # or by email to nospam@commtouch.com. # # A commercial license would be for Distributed Checksum and Reputation # Clearinghouse software. That software includes additional features. This # free license for Distributed ChecksumClearinghouse Software does not in any # way grant permision to use Distributed Checksum and Reputation Clearinghouse # software # # THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC # BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE. # Rhyolite Software DCC 1.3.50-1.28 $Revision$ # Generated automatically from list-msg.in by configure. # This file must protected with an equivalent to httpd.conf lines # in the README file. use strict 'subs'; # get DCC parameters do('/usr/local/dcc/cgi-bin/common') || die("could not get DCC configuration: $!\n"); # 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 "Expires: Thu, 01 Dec 1994 16:00:00 GMT\n"; print "pragma: no-cache\n\n"; print $buf while (read(MSG, $buf, 4*1024)); exit; } # find the previous and next messages local(%msgs_cache, @msgs_num, $msg_first); my($msg) = $query{msg}; my($path) = msg2path($msg, ""); get_log_msgs($msg, 0, 1); $msg = $msgs_num[$#msgs_num] if (!$msg && $#msgs_num >= 0); 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); $newest_msg = ""; if ($#msgs_num < 0) { $oldest_msg = ""; } else { $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${url_ques}msg=$newest_msg\">Newest"; html_head("Message $msg_num for $user"); common_buttons(); print <$newest_link $newer_link $older_link $oldest_link

Message $msg_num for $user

$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($sight) = `/usr/local/dcc/libexec/dccsight -G "$query{greywhite}" 2>&1`; my($log) = '. /usr/local/dcc/dcc_conf; $DCC_LOGGER '; $log .= "$ENV{SCRIPT_NAME} $user $msg; dccsight -G $query{greywhite}: "; $log .= "$sight\""; `$log >/dev/null 2>&1`; print "\n

\ngreylist passing $query{greywhite}: $sight"; } local($msg_date, $msg_helo, $msg_env_from, @msg_env_to, $msg_client_name, $msg_ip, $msg_mail_host, $msg_hdrs, $msg_body, $msg_cksums); @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 = `/usr/local/dcc/libexec/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\">"; 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\">$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; }