#!/usr/local/bin/perl # list_generics.cgi # Display a list of addresses for outgoing address mapping require './sendmail-lib.pl'; require './generics-lib.pl'; &ReadParse(); $access{'omode'} || &error($text{'generics_cannot'}); &ui_print_header(undef, $text{'generics_title'}, ""); $conf = &get_sendmailcf(); $gfile = &generics_file($conf); ($gdbm, $gdbmtype) = &generics_dbm($conf); if (!$gdbm) { # No Kgenerics directive in sendmail.cf print "",&text('generics_efeature', 'list_features.cgi'),"
\n"; &ui_print_footer("", $text{'index_return'}); exit; } if (!-r $gfile) { # Text file not found print "",&text('generics_efile', "$gfile", "$gdbm", "$gconfig{'webprefix'}/config.cgi?$module_name"),"
\n"; print "",&text('virtusers_createfile', 'create_file.cgi?mode=generics'),"
\n";
&ui_print_footer("", $text{'index_return'});
exit;
}
# Get list of outgoing mappings, limited to those the user can edit
@gens = &list_generics($gfile);
if ($access{'omode'} == 2) {
@gens = grep { $_->{'from'} =~ /$access{'oaddrs'}/i ||
$_->{'to'} =~ /$access{'oaddrs'}/i } @gens;
}
&generic_form();
if ($in{'search'}) {
# Restrict to search results
@gens = grep { $_->{'from'} =~ /$in{'search'}/ } @gens;
}
elsif ($config{'max_records'} && @gens > $config{'max_records'}) {
# Show search form
print $text{'generics_toomany'},"
\n";
print "
\n"; &gens_table(@gens[0..$mid-1]); print " | \n"; if ($mid < @gens) { &gens_table(@gens[$mid..$#gens]); } print " |
\n"; } print $text{'generics_desc1'},"
\n";
print &text('generics_desc2', "list_cgs.cgi"),"
\n";
&ui_print_footer("", $text{'index_return'});
sub gens_table
{
local @tds = ( "width=5" );
print &ui_columns_start([ "",
$text{'generics_from'},
$text{'generics_to'},
$config{'show_cmts'} ? ( $text{'virtusers_cmt'} )
: ( ) ], 100, 0, \@tds);
foreach $g (@_) {
local @cols;
push(@cols, "{'num'}\">".
"".&html_escape($g->{'from'})."");
push(@cols, &html_escape($g->{'to'}));
push(@cols, &html_escape($g->{'cmt'})) if ($config{'show_cmts'});
print &ui_checked_columns_row(\@cols, \@tds, "d", $g->{'from'});
}
print &ui_columns_end();
}
# Notes - The G class lists domains for which outgoing-address translation
# is done. If a mapping for an address like 'foo' exists, it applied for
# from addresses like 'foo' or 'foo@anything'. However, a mapping for
# 'foo@foo.com' applies only for that exact address
# By default, the G class contains only the full local hostname
# (like florissa.home). Sendmail automatically adds the full hostname
# to unqualified addresses sent locally or through smtp (so