Handle hostnames with upper-case letters
[webmin.git] / sendmail / acl_security.pl
1
2 require 'sendmail-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the sendmail module
6 sub acl_security_form
7 {
8 print "<tr> <td><b>$text{'acl_opts'}</b></td> <td>\n";
9 printf "<input type=radio name=opts value=1 %s> $text{'yes'}\n",
10         $_[0]->{'opts'} ? "checked" : "";
11 printf "<input type=radio name=opts value=0 %s> $text{'no'}</td>\n",
12         $_[0]->{'opts'} ? "" : "checked";
13
14 print "<td><b>$text{'acl_cws'}</b></td> <td>\n";
15 printf "<input type=radio name=cws value=1 %s> $text{'yes'}\n",
16         $_[0]->{'cws'} ? "checked" : "";
17 printf "<input type=radio name=cws value=0 %s> $text{'no'}</td> </tr>\n",
18         $_[0]->{'cws'} ? "" : "checked";
19
20 print "<tr> <td><b>$text{'acl_masq'}</b></td> <td>\n";
21 printf "<input type=radio name=masq value=1 %s> $text{'yes'}\n",
22         $_[0]->{'masq'} ? "checked" : "";
23 printf "<input type=radio name=masq value=0 %s> $text{'no'}</td>\n",
24         $_[0]->{'masq'} ? "" : "checked";
25
26 print "<td><b>$text{'acl_trusts'}</b></td> <td>\n";
27 printf "<input type=radio name=trusts value=1 %s> $text{'yes'}\n",
28         $_[0]->{'trusts'} ? "checked" : "";
29 printf "<input type=radio name=trusts value=0 %s> $text{'no'}</td> </tr>\n",
30         $_[0]->{'trusts'} ? "" : "checked";
31
32 print "<tr> <td><b>$text{'acl_cgs'}</b></td> <td>\n";
33 printf "<input type=radio name=cgs value=1 %s> $text{'yes'}\n",
34         $_[0]->{'cgs'} ? "checked" : "";
35 printf "<input type=radio name=cgs value=0 %s> $text{'no'}</td>\n",
36         $_[0]->{'cgs'} ? "" : "checked";
37
38 print "<td><b>$text{'acl_relay'}</b></td> <td>\n";
39 printf "<input type=radio name=relay value=1 %s> $text{'yes'}\n",
40         $_[0]->{'relay'} ? "checked" : "";
41 printf "<input type=radio name=relay value=0 %s> $text{'no'}</td> </tr>\n",
42         $_[0]->{'relay'} ? "" : "checked";
43
44 print "<tr> <td><b>$text{'acl_mailers'}</b></td> <td>\n";
45 printf "<input type=radio name=mailers value=1 %s> $text{'yes'}\n",
46         $_[0]->{'mailers'} ? "checked" : "";
47 printf "<input type=radio name=mailers value=0 %s> $text{'no'}</td>\n",
48         $_[0]->{'mailers'} ? "" : "checked";
49
50 print "<td><b>$text{'acl_access'}</b></td> <td>\n";
51 printf "<input type=radio name=access value=1 %s> $text{'yes'}\n",
52         $_[0]->{'access'} ? "checked" : "";
53 printf "<input type=radio name=access value=0 %s> $text{'no'}</td> </tr>\n",
54         $_[0]->{'access'} ? "" : "checked";
55
56 print "<tr> <td><b>$text{'acl_domains'}</b></td> <td>\n";
57 printf "<input type=radio name=domains value=1 %s> $text{'yes'}\n",
58         $_[0]->{'domains'} ? "checked" : "";
59 printf "<input type=radio name=domains value=0 %s> $text{'no'}</td>\n",
60         $_[0]->{'domains'} ? "" : "checked";
61
62 print "<td><b>$text{'acl_stop'}</b></td> <td>\n";
63 printf "<input type=radio name=stop value=1 %s> $text{'yes'}\n",
64         $_[0]->{'stop'} ? "checked" : "";
65 printf "<input type=radio name=stop value=0 %s> $text{'no'}</td> </tr>\n",
66         $_[0]->{'stop'} ? "" : "checked";
67
68 print "<tr> <td><b>$text{'acl_manual'}</b></td> <td>\n";
69 printf "<input type=radio name=manual value=1 %s> $text{'yes'}\n",
70         $_[0]->{'manual'} ? "checked" : "";
71 printf "<input type=radio name=manual value=0 %s> $text{'no'}</td>\n",
72         $_[0]->{'manual'} ? "" : "checked";
73
74 print "<td><b>$text{'acl_mailq'}</b></td> <td><select name=mailq>\n";
75 printf "<option value=2 %s> $text{'acl_viewdel'}\n",
76         $_[0]->{'mailq'} == 2 ? "selected" : "";
77 printf "<option value=1 %s> $text{'acl_view'}\n",
78         $_[0]->{'mailq'} == 1 ? "selected" : "";
79 printf "<option value=0 %s> $text{'no'}\n",
80         $_[0]->{'mailq'} == 0 ? "selected" : "";
81 print "</select></td> </tr>\n";
82
83 print "<tr> <td><b>$text{'acl_qdoms'}</b></td> <td colspan=3>\n";
84 printf "<input type=radio name=qdoms_def value=1 %s> %s\n",
85         $_[0]->{'qdoms'} ? "" : "checked", $text{'acl_all'};
86 printf "<input type=radio name=qdoms_def value=0 %s> %s\n",
87         $_[0]->{'qdoms'} ? "checked" : "", $text{'acl_matching'};
88 printf "<input name=qdoms size=40 value='%s'></td> </tr>\n",
89         $_[0]->{'qdoms'};
90
91 print "<tr> <td><b>$text{'acl_qdomsmode'}</b></td> <td colspan=3>\n";
92 foreach $m (0 .. 2) {
93         printf "<input type=radio name=qdomsmode value=%s %s> %s\n",
94                 $m, $_[0]->{'qdomsmode'} == $m ? "checked" : "",
95                 $text{'acl_qdomsmode'.$m};
96         }
97 print "</td> </tr>\n";
98
99 print "<tr> <td><b>$text{'acl_flushq'}</b></td> <td>\n";
100 printf "<input type=radio name=flushq value=1 %s> $text{'yes'}\n",
101         $_[0]->{'flushq'} ? "checked" : "";
102 printf "<input type=radio name=flushq value=0 %s> $text{'no'}</td>\n",
103         $_[0]->{'flushq'} ? "" : "checked";
104
105 print "<td><b>$text{'acl_ports'}</b></td> <td>\n";
106 printf "<input type=radio name=ports value=1 %s> $text{'yes'}\n",
107         $_[0]->{'ports'} ? "checked" : "";
108 printf "<input type=radio name=ports value=0 %s> $text{'no'}</td>\n",
109         $_[0]->{'ports'} ? "" : "checked";
110
111 # Virtusers
112 print "<tr> <td colspan=4><hr></td> </tr>\n";
113
114 print "<tr> <td valign=top><b>$text{'acl_virtusers'}</b></td> <td colspan=3>\n";
115 printf "<input type=radio name=vmode value=0 %s> $text{'acl_none'}\n",
116         $_[0]->{'vmode'} == 0 ? "checked" : "";
117 printf "<input type=radio name=vmode value=1 %s> $text{'acl_all'}\n",
118         $_[0]->{'vmode'} == 1 ? "checked" : "";
119 printf "<input type=radio name=vmode value=3 %s> $text{'acl_vsame'}<br>\n",
120         $_[0]->{'vmode'} == 3 ? "checked" : "";
121 printf "<input type=radio name=vmode value=2 %s> $text{'acl_matching'}\n",
122         $_[0]->{'vmode'} == 2 ? "checked" : "";
123 printf "<input name=vaddrs size=40 value='%s'></td> </tr>\n",
124         $_[0]->{'vaddrs'};
125
126 print "<tr> <td><b>$text{'acl_vtypes'}</b></td>\n";
127 print "<td colspan=3>\n";
128 for($n=0; $n<3; $n++) {
129         printf "<input type=checkbox name=vedit_%s value=1 %s> %s\n",
130                 $n, $_[0]->{"vedit_$n"} ? "checked" : "", $text{"acl_vtype$n"};
131         }
132 print "</td> </tr>\n";
133
134 print "<tr> <td><b>$text{'acl_vmax'}</b></td>\n";
135 printf "<td><input type=radio name=vmax_def value=1 %s> %s\n",
136         $_[0]->{'vmax'} ? "" : "checked", $text{'acl_unlimited'};
137 printf "<input type=radio name=vmax_def value=0 %s>\n",
138         $_[0]->{'vmax'} ? "checked" : "";
139 printf "<input name=vmax size=5 value='%s'></td>\n",
140         $_[0]->{'vmax'};
141
142 print "<td><b>$text{'acl_vcatchall'}</b></td>\n";
143 print "<td>",&ui_yesno_radio("vcatchall",
144                              int($_[0]->{'vcatchall'})),"</td> </tr>\n";
145
146 # Aliases
147 print "<tr> <td colspan=4><hr></td> </tr>\n";
148
149 print "<tr> <td valign=top><b>$text{'acl_aliases'}</b></td> <td colspan=3>\n";
150 printf "<input type=radio name=amode value=0 %s> $text{'acl_none'}\n",
151         $_[0]->{'amode'} == 0 ? "checked" : "";
152 printf "<input type=radio name=amode value=1 %s> $text{'acl_all'}\n",
153         $_[0]->{'amode'} == 1 ? "checked" : "";
154 printf "<input type=radio name=amode value=3 %s> $text{'acl_asame'}<br>\n",
155         $_[0]->{'amode'} == 3 ? "checked" : "";
156 printf "<input type=radio name=amode value=2 %s> $text{'acl_matching'}\n",
157         $_[0]->{'amode'} == 2 ? "checked" : "";
158 printf "<input name=aliases size=40 value='%s'></td> </tr>\n",
159         $_[0]->{'aliases'};
160
161 print "<tr> <td><b>$text{'acl_atypes'}</b></td> <td colspan=3>\n";
162 for($n=1; $n<=6; $n++) {
163         printf "<input type=checkbox name=aedit_%s value=1 %s> %s\n",
164                 $n, $_[0]->{"aedit_$n"} ? "checked" : "",
165                 $text{"acl_atype$n"};
166         }
167 print "</td> </tr>\n";
168
169 print "<tr> <td><b>$text{'acl_amax'}</b></td>\n";
170 printf "<td colspan=3><input type=radio name=amax_def value=1 %s> %s\n",
171         $_[0]->{'amax'} ? "" : "checked", $text{'acl_unlimited'};
172 printf "<input type=radio name=amax_def value=0 %s>\n",
173         $_[0]->{'amax'} ? "checked" : "";
174 printf "<input name=amax size=5 value='%s'></td> </tr>\n",
175         $_[0]->{'amax'};
176
177 print "<tr> <td><b>$text{'acl_apath'}</b></td>\n";
178 printf "<td colspan=3><input name=apath size=40 value='%s'> %s</td> </tr>\n",
179         $_[0]->{'apath'}, &file_chooser_button("apath", 1);
180
181 # Outgoing address mappings
182 print "<tr> <td colspan=4><hr></td> </tr>\n";
183
184 print "<tr> <td valign=top><b>$text{'acl_outgoing'}</b></td> <td colspan=3>\n";
185 printf "<input type=radio name=omode value=0 %s> $text{'acl_none'}\n",
186         $_[0]->{'omode'} == 0 ? "checked" : "";
187 printf "<input type=radio name=omode value=1 %s> $text{'acl_all'}<br>\n",
188         $_[0]->{'omode'} == 1 ? "checked" : "";
189 printf "<input type=radio name=omode value=2 %s> $text{'acl_matching'}\n",
190         $_[0]->{'omode'} == 2 ? "checked" : "";
191 printf "<input name=oaddrs size=40 value='%s'></td> </tr>\n",
192         $_[0]->{'oaddrs'};
193
194 # Spam control rules
195 print "<tr> <td colspan=4><hr></td> </tr>\n";
196
197 print "<tr> <td valign=top><b>$text{'acl_spam'}</b></td> <td colspan=3>\n";
198 printf "<input type=radio name=smode value=1 %s> $text{'acl_all'}\n",
199         $_[0]->{'smode'} == 1 ? "checked" : "";
200 printf "<input type=radio name=smode value=2 %s> $text{'acl_matching'}\n",
201         $_[0]->{'smode'} == 2 ? "checked" : "";
202 printf "<input name=saddrs size=40 value='%s'></td> </tr>\n",
203         $_[0]->{'saddrs'};
204 }
205
206 # acl_security_save(&options)
207 # Parse the form for security options for the sendmail module
208 sub acl_security_save
209 {
210 $_[0]->{'opts'} = $in{'opts'};
211 $_[0]->{'ports'} = $in{'ports'};
212 $_[0]->{'cws'} = $in{'cws'};
213 $_[0]->{'masq'} = $in{'masq'};
214 $_[0]->{'trusts'} = $in{'trusts'};
215 $_[0]->{'cgs'} = $in{'cgs'};
216 $_[0]->{'relay'} = $in{'relay'};
217 $_[0]->{'manual'} = $in{'manual'};
218 $_[0]->{'mailq'} = $in{'mailq'};
219 $_[0]->{'qdoms'} = $in{'qdoms_def'} ? undef : $in{'qdoms'};
220 $_[0]->{'qdomsmode'} = $in{'qdomsmode'};
221 $_[0]->{'mailers'} = $in{'mailers'};
222 $_[0]->{'access'} = $in{'access'};
223 $_[0]->{'domains'} = $in{'domains'};
224 $_[0]->{'stop'} = $in{'stop'};
225 $_[0]->{'vmode'} = $in{'vmode'};
226 $_[0]->{'vaddrs'} = $in{'vmode'} == 2 ? $in{'vaddrs'} : "";
227 $_[0]->{'vmax'} = $in{'vmax_def'} ? undef : $in{'vmax'};
228 foreach $i (0..2) {
229         $_[0]->{"vedit_$i"} = $in{"vedit_$i"};
230         }
231 $_[0]->{'vcatchall'} = $in{'vcatchall'};
232 $_[0]->{'amode'} = $in{'amode'};
233 $_[0]->{'aliases'} = $in{'amode'} == 2 ? $in{'aliases'} : "";
234 $_[0]->{'amax'} = $in{'amax_def'} ? undef : $in{'amax'};
235 $_[0]->{'apath'} = $in{'apath'};
236 foreach $i (1..6) {
237         $_[0]->{"aedit_$i"} = $in{"aedit_$i"};
238         }
239 $_[0]->{'omode'} = $in{'omode'};
240 $_[0]->{'oaddrs'} = $in{'omode'} == 2 ? $in{'oaddrs'} : "";
241 $_[0]->{'flushq'} = $in{'flushq'};
242 $_[0]->{'smode'} = $in{'smode'};
243 $_[0]->{'saddrs'} = $in{'smode'} == 2 ? $in{'saddrs'} : "";
244 }
245