#!/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"; print "\n"; print "
\n"; undef(@gens); } if (@gens) { # sort if needed if ($config{'sort_mode'} == 1) { @gens = sort sort_by_domain @gens; } # render table of generics print &ui_form_start("delete_generics.cgi", "post"); @links = ( &select_all_link("d", 1), &select_invert_link("d", 1) ); print &ui_links_row(\@links); if ($config{'columns'} == 2) { $mid = int((@gens+1)/2); print "
\n"; &gens_table(@gens[0..$mid-1]); print "\n"; if ($mid < @gens) { &gens_table(@gens[$mid..$#gens]); } print "

\n"; } else { &gens_table(@gens); } print &ui_links_row(\@links); print &ui_form_end([ [ "delete", $text{'generics_delete'} ] ]); } if ($access{'omode'} == 1 && $access{'manual'}) { print "", &text('file_edit', "$gfile"),"

\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 becomes # # The G class can be defined by CG statements in sendmail.cf, or by a # FG/path line to use an external file.. # If there is a generics mapping from an unqualified name, then it will # apply for all domains in the G class.