#! @PERL@ -wT -I@cgibin@ # display and edit a DCC whitelist file # --S-LICENSE-- # $Revision: 1.74 $ # @configure_input@ # This file must protected with an equivalent to httpd.conf lines # in the README file. use strict 'subs'; use POSIX qw(strftime); use common; my($main_whiteclnt); # path to the main whiteclnt file my(@file); # list representation of the file my(%dict); # dictionary of checksums and options my(%def_options); # option settings from main whiteclnt file my($have_entry_form, $form_marked, $cur_pos, $cur_key, $cur_entry, $cur_index); my $form_num = 0; # display the file literally if ($query{literal}) { my($buf); open(WHITECLNT, "< $whiteclnt") or html_whine("open($whiteclnt): $!"); print "Content-type: text/plain\n"; print "Cache-Control: max-age=0, must-revalidate\n\n"; print $buf while (read(WHITECLNT, $buf, 4*1024)); print "\n"; close(WHITECLNT); exit; } # lock, read and parse the whiteclnt file read_whiteclnt(\@file, \%dict); # get option defaults from the main whiteclnt file read_whitedefs(\%def_options); # get current position for the entry editing form $cur_pos = $query{pos}; # find a whitecnt file entry to edit if ($query{key}) { $cur_key = $query{key}; } elsif ($query{auto} && $query{type} && $query{val}) { my @new_entry = ck_new_white_entry("", "ok", $query{type}, $query{val}); $cur_key = $new_entry[0] if (defined($new_entry[1])); } $cur_entry = $dict{$cur_key} if ($cur_key); html_head("DCC Whitelist for $user at $hostname"); common_buttons(); print "
$query{result}\n" : ""); ############################################################################# # display the whiteclnt file with the option setting form and and quit sub print_form_file { my($result) = @_; # "" or some kind of error message close(WHITECLNT); my $locked = ($whiteclnt_lock =~ /\blocked/) ? " disabled" : ""; # display any error message from the previous action print $result ? $result : "
\n"; # generate table of forms to control option lines print "
\n
", "", "");
print "\t ";
undo_form($locked);
print "\t \n";
# two HTML forms for the '#webuser...' line
$whiteclnt_notify =~ /$whiteclnt_notify_pat/;
my $notify_cur = $2;
my $notifybox = $4;
my $notify_on_locked = ($notify_cur eq "on") ? " disabled" : $locked;
my $notify_off_locked = ($notify_cur eq "off") ? " disabled" : $locked;
print_form_start(" | |||
", "", " ");
print <
EOF
print_form_start(" | ", "", " ");
print_button("\t", "notify", $notify_on_locked, "on");
print_button("\t", "notify", $notify_off_locked, "off");
print "\t \n";
table_row_form("dccenable", "DCC", $locked, "dcc-off", "dcc-on");
if ($DCCM_ARGS =~ /-G/ || $DCCIFD_ARGS =~ /-G/
|| (defined($GREY_CLIENT_ARGS) && $GREY_CLIENT_ARGS ne "")) {
table_row_form("greyfilter", "greylist filter", $locked,
"greylist-off", "greylist-on");
table_row_form("greylog", "greylist log", $locked,
"greylist-log-off", "greylist-log-on");
}
table_row_form("mtafirst", "check MTA blacklist", $locked,
"MTA-last", "MTA-first", "last", "first");
table_row_form("rep", "DCC Reputations", $locked,
"DCC-rep-off", "DCC-rep-on");
# ask about DNSBLs if they are available
my $args = "$DNSBL_ARGS $DCCM_ARGS $DCCIFD_ARGS";
if ($args =~ /-B/) {
if (!defined($dict{dnsbl2}) && !defined($dict{dnsbl3})
&& !defined($dict{dnsbl4})
&& $args !~ /-B\s*set:group=\d+/i) {
# only one question if there are no groups
table_row_form("dnsbl1", "DNS list checking", $locked);
} else {
table_row_form("dnsbl1", "DNS list #1 checking", $locked);
table_row_form("dnsbl2", "DNS list #2 checking", $locked);
table_row_form("dnsbl3", "DNS list #3 checking", $locked)
if (defined($dict{dnsbl3})|| defined($dict{dnsbl4})
|| $args =~ /-B\s*set:group=[34]/i);
table_row_form("dnsbl4", "DNS list #4 checking", $locked)
if (defined($dict{dnsbl4})
|| $args =~ /-B\s*set:group=4/i);
}
}
table_row_form("logall", "debug logging", $locked,
"log-normal", "log-all");
table_row_form("discardok",
" also addressed to others",
$locked, "no-forced-discard", "forced-discard-ok",
"delay mail", "discard spam");
# forms for checksum thresholds
foreach my $ck (split(/,/, $thold_cks)) {
my($cur_val, $sw_val, $nm, $def_label, $bydef,
$dis_field, $dis_def, $dis_never);
$nm = "thold-" . $ck;
# construct label for the default button from default value
$def_label = $def_options{$nm};
$def_label =~ s/.*([^<]+)<.*/Default ($1)/;
if (defined($dict{$nm})) {
$cur_val = $dict{$nm}[2];
$cur_val =~ s/.*,([-_a-z0-9%]+)\s+$/$1/i;
$bydef = '';
$sw_val = $cur_val;
} else {
$cur_val = $def_options{$nm};
$cur_val =~ s@(.*)(.*)@$1@;
$bydef = $2;
$sw_val = 'Default';
}
$dis_field = $locked;
$dis_def = $locked;
$dis_never = $locked;
$dis_def = " class=selected disabled" if ($sw_val eq "Default");
$dis_never = " class=selected disabled" if ($sw_val eq "Never");
# changing reputation thresholds ought to affect tagging
# even if reputation checking is turned off
print_form_start("", "", " | ");
print <
EOF
print_form_start(" ", "", " | ");
print_button("\t", $nm, $dis_def, $def_label);
print_button("\t", $nm, $dis_never, "Never");
# "many" makes no sense for either reputation threshold
print_button("\t", $nm,
$sw_val =~ /^many$/i ? " disabled" : $locked,
"MANY")
if ($ck !~ /^rep/i);
print "\t \n";
}
print " |
\n"; # display a form for a new entry before the file if we have not # been given a position or an entry to modify print_entry_form($locked, $result) if (!$cur_key && !defined($cur_pos)); print_whiteclnt_file($result, $locked); } # display the common start of forms sub print_form_start { my($before, # HTML before start of form $tag, # tag on action $after # HTML after start of form ) = @_; print $before if ($before); print "