3 # Display a list of addresses for outgoing address mapping
5 require './sendmail-lib.pl';
6 require './generics-lib.pl';
8 $access{'omode'} || &error($text{'generics_cannot'});
9 &ui_print_header(undef, $text{'generics_title'}, "");
11 $conf = &get_sendmailcf();
12 $gfile = &generics_file($conf);
13 ($gdbm, $gdbmtype) = &generics_dbm($conf);
15 # No Kgenerics directive in sendmail.cf
16 print "<b>",&text('generics_efeature', 'list_features.cgi'),"</b><p>\n";
17 &ui_print_footer("", $text{'index_return'});
22 print "<b>",&text('generics_efile', "<tt>$gfile</tt>",
23 "<tt>$gdbm</tt>", "$gconfig{'webprefix'}/config.cgi?$module_name"),"</b> <p>\n";
24 print "<b>",&text('virtusers_createfile',
25 'create_file.cgi?mode=generics'),"</b><p>\n";
26 &ui_print_footer("", $text{'index_return'});
30 # Get list of outgoing mappings, limited to those the user can edit
31 @gens = &list_generics($gfile);
32 if ($access{'omode'} == 2) {
33 @gens = grep { $_->{'from'} =~ /$access{'oaddrs'}/i ||
34 $_->{'to'} =~ /$access{'oaddrs'}/i } @gens;
40 # Restrict to search results
41 @gens = grep { $_->{'from'} =~ /$in{'search'}/ } @gens;
43 elsif ($config{'max_records'} && @gens > $config{'max_records'}) {
45 print $text{'generics_toomany'},"<br>\n";
46 print "<form action=list_generics.cgi>\n";
47 print "<input type=submit value='$text{'generics_go'}'>\n";
48 print "<input name=search size=20></form>\n";
54 if ($config{'sort_mode'} == 1) {
55 @gens = sort sort_by_domain @gens;
58 # render table of generics
59 print &ui_form_start("delete_generics.cgi", "post");
60 @links = ( &select_all_link("d", 1),
61 &select_invert_link("d", 1) );
62 print &ui_links_row(\@links);
63 if ($config{'columns'} == 2) {
64 $mid = int((@gens+1)/2);
65 print "<table width=100%> <tr><td width=50% valign=top>\n";
66 &gens_table(@gens[0..$mid-1]);
67 print "</td><td width=50% valign=top>\n";
68 if ($mid < @gens) { &gens_table(@gens[$mid..$#gens]); }
69 print "</td></tr> </table><br>\n";
74 print &ui_links_row(\@links);
75 print &ui_form_end([ [ "delete", $text{'generics_delete'} ] ]);
77 if ($access{'omode'} == 1 && $access{'manual'}) {
78 print "<a href='edit_file.cgi?mode=generics'>",
79 &text('file_edit', "<tt>$gfile</tt>"),"</a><p>\n";
82 print $text{'generics_desc1'},"<p>\n";
83 print &text('generics_desc2', "list_cgs.cgi"),"<br>\n";
85 &ui_print_footer("", $text{'index_return'});
89 local @tds = ( "width=5" );
90 print &ui_columns_start([ "",
91 $text{'generics_from'},
93 $config{'show_cmts'} ? ( $text{'virtusers_cmt'} )
94 : ( ) ], 100, 0, \@tds);
97 push(@cols, "<a href=\"edit_generic.cgi?num=$g->{'num'}\">".
98 "<tt>".&html_escape($g->{'from'})."</tt></a>");
99 push(@cols, &html_escape($g->{'to'}));
100 push(@cols, &html_escape($g->{'cmt'})) if ($config{'show_cmts'});
101 print &ui_checked_columns_row(\@cols, \@tds, "d", $g->{'from'});
103 print &ui_columns_end();
106 # Notes - The G class lists domains for which outgoing-address translation
107 # is done. If a mapping for an address like 'foo' exists, it applied for
108 # from addresses like 'foo' or 'foo@anything'. However, a mapping for
109 # 'foo@foo.com' applies only for that exact address
110 # By default, the G class contains only the full local hostname
111 # (like florissa.home). Sendmail automatically adds the full hostname
112 # to unqualified addresses sent locally or through smtp (so <foo> becomes
113 # <foo@florissa.home>
114 # The G class can be defined by CG statements in sendmail.cf, or by a
115 # FG/path line to use an external file..
117 # If there is a generics mapping from an unqualified name, then it will
118 # apply for all domains in the G class.