Handle hostnames with upper-case letters
[webmin.git] / sendmail / list_opts.cgi
1 #!/usr/local/bin/perl
2 # list_opts.cgi
3 # A form for editing options set with the 'O foo=bar' directive,
4 # and other things.
5
6 require './sendmail-lib.pl';
7 $access{'opts'} || &error($text{'opts_ecannot'});
8 &ui_print_header(undef, $text{'opts_title'}, "");
9
10 # Get config and start form
11 $conf = &get_sendmailcf();
12 $ver = &check_sendmail_version($conf);
13 $default = $text{'opts_default'};
14 print &ui_form_start("save_opts.cgi", "post");
15 print &ui_table_start($text{'opts_title'}, "width=100%", 4);
16
17 # Smart host for outgoing mail
18 ($dsstr, $ds) = &find_type2("D", "S", $conf);
19 print &ui_table_row(&hlink($text{'opts_ds'}, "opt_DS"),
20         &ui_opt_textbox("DS", $ds, 40, $text{'opts_direct'}), 3);
21
22 # Host for unqualified names
23 ($drstr, $dr) = &find_type2("D", "R", $conf);
24 print &ui_table_row(&hlink($text{'opts_dr'}, "opt_DR"),
25         &ui_opt_textbox("DR", $dr, 40, $text{'opts_local'}), 3);
26
27 # Host for local users
28 ($dhstr, $dh) = &find_type2("D", "H", $conf);
29 print &ui_table_row(&hlink($text{'opts_dh'}, "opt_DH"),
30         &ui_opt_textbox("DH", $dh, 40, $text{'opts_local'}), 3);
31
32 # Queuing / delivery mode
33 ($dmstr, $dm) = &find_option("DeliveryMode", $conf);
34 @dmodes = ('background', 'queue-only', 'interactive', 'deferred');
35 if ($dm) {
36         ($dmode) = grep { substr($_, 0, 1) eq substr($dm, 0, 1) } @dmodes;
37         }
38 print &ui_table_row(&hlink($text{'opts_dmode'}, "opt_dmode"),
39         &ui_radio("DeliveryMode", $dmode,
40                   [ [ '', $text{'default'} ],
41                     map { [ $_, $text{"opts_".$_} ] } @dmodes ]), 3);
42
43 # Sort mail queue by
44 ($qsostr, $qso) = &find_option("QueueSortOrder", $conf);
45 @qsmodes = ('priority', 'host', 'time');
46 if ($qso) {
47         ($qsorder) = grep { substr($_, 0, 1) eq substr($qso, 0, 1) } @qsmodes;
48         }
49 print &ui_table_row(&hlink($text{'opts_qso'}, "opt_qso"),
50         &ui_radio("QueueSortOrder", $qsorder,
51                   [ [ '', $text{'default'} ],
52                     map { [ $_, $text{"opts_".$_} ] } @qsmodes ]), 3);
53
54 &option_input($text{'opts_queuela'}, "QueueLA", $conf, $default, 6);
55 &option_input($text{'opts_refusela'}, "RefuseLA", $conf, $default,6);
56
57 &option_input($text{'opts_maxch'}, "MaxDaemonChildren",
58               $conf, $default, 6);
59 &option_input($text{'opts_throttle'}, "ConnectionRateThrottle",
60               $conf, $default, 6);
61
62 &option_input($text{'opts_minqueueage'}, "MinQueueAge",
63               $conf, $default, 6);
64 &option_input($text{'opts_runsize'}, "MaxQueueRunSize", $conf, $default, 8);
65
66 &option_input($text{'opts_queuereturn'}, "Timeout.queuereturn",
67               $conf, $default, 6);
68 &option_input($text{'opts_queuewarn'}, "Timeout.queuewarn",
69               $conf, $default, 6);
70
71 &option_input($text{'opts_queue'}, "QueueDirectory", $conf, $default, 35);
72
73 &option_input($text{'opts_postmaster'}, "PostMasterCopy",
74               $conf, "Postmaster", 35);
75
76 &option_input($text{'opts_forward'}, "ForwardPath", $conf, $default, 35);
77
78 &option_input($text{'opts_minfree'}, "MinFreeBlocks",
79               $conf, $default, 8, $text{'opts_blocks'});
80 &option_input($text{'opts_maxmessage'}, "MaxMessageSize",
81               $conf, $default, 10, $text{'opts_bytes'});
82
83 &option_input($text{'opts_loglevel'}, "LogLevel", $conf, $default, 4);
84 ($vstr, $v) = &find_option("SendMimeErrors", $conf);
85 print &ui_table_row(&hlink($text{'opts_mimebounce'}, "opt_SendMimeErrors"),
86         &ui_radio("SendMimeErrors", $v eq "True" ? "True" : "False",
87                   [ [ "True", $text{'yes'} ],
88                     [ "False", $text{'no'} ] ]));
89
90 ($gstr, $g) = &find_option("MatchGECOS", $conf);
91 print &ui_table_row(&hlink($text{'opts_gecos'}, "opt_MatchGECOS"),
92         &ui_radio("MatchGECOS", $v eq "True" ? "True" : "False",
93                   [ [ "True", $text{'yes'} ],
94                     [ "False", $text{'no'} ] ]));
95 &option_input($text{'opts_hops'}, "MaxHopCount", $conf, $default, 4);
96
97 if ($ver >= 10) {
98         &option_input($text{'opts_maxrcpt'}, "MaxRecipientsPerMessage",
99                       $conf, $default, 4);
100         &option_input($text{'opts_maxbad'}, "BadRcptThrottle",
101                       $conf, $default, 4);
102         }
103
104 ($bstr, $b) = &find_option("DontBlameSendmail", $conf);
105 print &ui_table_row(&hlink($text{'opts_blame'}, "opt_DontBlameSendmail"),
106         &ui_radio("DontBlameSendmail_def", $b ? 0 : 1,
107                   [ [ 1, $text{'default'} ],
108                     [ 0, $text{'opts_selected'} ] ])."<br>".
109         &ui_select("DontBlameSendmail",
110          [ split(/[\s,]+/, $b) ],
111          [ map { [ $_->[0],
112                    "$_->[0] (".(length($_->[1]) > 40 ? substr($_->[1], 0, 40)."..." : $_->[1]).")" ] } &list_dontblames() ],
113          5, 1, 1), 3);
114
115 print &ui_table_end();
116 print &ui_form_end([ [ undef, $text{'opts_save'} ] ]);
117
118 &ui_print_footer("", $text{'index_return'});
119
120 # option_input(desc, name, &config, default, size, units)
121 sub option_input
122 {
123 local ($vstr, $v) = &find_option($_[1], $_[2]);
124 print &ui_table_row(&hlink($_[0], "opt_".$_[1]),
125         &ui_opt_textbox($_[1], $v, $_[4], $_[3])." ".$_[5],
126         $_[4] > 20 ? 3 : 1);
127 }
128
129 # options_input(desc, name, &config, default, size, units)
130 sub options_input
131 {
132 local @vals = &find_options($_[1], $_[2]);
133 print &ui_table_row(&hlink($_[0], "opt_".$_[1]),
134         &ui_radio("$_[1]_def", @vals ? 0 : 1,
135                 [ [ 1, $_[3] ], [ 0, $text{'opts_below'} ] ])."<br>".
136         &ui_textarea($_[1], join("\n", map { $_->[1] } @vals), 3, $_[4]),
137         $_[4] > 20 ? 3 : 1);
138 }
139