2 require 'bind8-lib.pl';
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the bind8 module
8 local $m = $_[0]->{'zones'} eq '*' ? 1 :
9 $_[0]->{'zones'} =~ /^\!/ ? 2 : 0;
10 print "<tr> <td valign=top><b>$text{'acl_zones'}</b></td>\n";
11 print "<td colspan=3><table cellpadding=0 cellspacing=0> <tr><td valign=top>\n";
12 printf "<input type=radio name=zones_def value=1 %s> %s<br>\n",
13 $m == 1 ? 'checked' : '', $text{'acl_zall'};
14 printf "<input type=radio name=zones_def value=0 %s> %s<br>\n",
15 $m == 0 ? 'checked' : '', $text{'acl_zsel'};
16 printf "<input type=radio name=zones_def value=2 %s> %s</td>\n",
17 $m == 2 ? 'checked' : '', $text{'acl_znsel'};
19 print "<td><select name=zones multiple size=4 width=150>\n";
20 local $conf = &get_config();
21 local @zones = grep { $_->{'value'} ne "." }
23 local @views = &find("view", $conf);
26 push(@zones, grep { $_->{'value'} ne "." }
27 &find("zone", $v->{'members'}));
30 map { $zcan{$_}++ } split(/\s+/, $_[0]->{'zones'});
31 foreach $z (sort { $a->{'value'} cmp $b->{'value'} } @zones) {
32 printf "<option value='%s' %s>%s\n",
34 $zcan{$z->{'value'}} ? "selected" : "",
35 &arpa_to_ip($z->{'value'});
37 foreach $v (sort { $a->{'value'} cmp $b->{'value'} } @views) {
38 printf "<option value='%s' %s>%s\n",
39 'view_'.$v->{'value'},
40 $zcan{'view_'.$v->{'value'}} ? "selected" : "",
41 &text('acl_inview', $v->{'value'});
43 print "</select></td> </tr></table></td></tr>\n";
45 print "<tr> <td><b>$text{'acl_types'}</b></td> <td colspan=3>\n";
46 printf "<input type=radio name=types_def value=1 %s> %s\n",
47 $_[0]->{'types'} ? "" : "checked", $text{'acl_types1'};
48 printf "<input type=radio name=types_def value=0 %s> %s\n",
49 $_[0]->{'types'} ? "checked" : "", $text{'acl_types0'};
50 printf "<input name=types size=40 value='%s'></td> </tr>\n",
53 print "<tr> <td valign=top><b>$text{'acl_dir'}</b></td>\n";
54 printf "<td colspan=3><input name=dir size=30 value='%s'> %s<br>\n",
55 $_[0]->{'dir'}, &file_chooser_button("dir", 1);
56 printf "<input type=checkbox name=dironly value=1 %s> %s</td> </tr>\n",
57 $_[0]->{'dironly'} ? "checked" : "", $text{'acl_dironly'};
59 print "<tr> <td><b>$text{'acl_defaults'}</b></td> <td nowrap>\n";
60 printf "<input type=radio name=defaults value=1 %s> $text{'yes'}\n",
61 $_[0]->{'defaults'} ? "checked" : "";
62 printf "<input type=radio name=defaults value=0 %s> $text{'no'}</td> </tr>\n",
63 $_[0]->{'defaults'} ? "" : "checked";
65 print "<tr> <td><b>$text{'acl_ztypes'}</b></td> <td colspan=3>\n";
66 foreach $t ("master", "slave", "forward", "delegation") {
67 printf "<input type=checkbox name=%s %s> %s\n",
68 $t, $_[0]->{$t} ? "checked" : "", $text{'acl_ztypes_'.$t};
70 print "</td> </tr>\n";
72 print "<tr> <td><b>$text{'acl_reverse'}</b></td> <td nowrap>\n";
73 printf "<input type=radio name=reverse value=1 %s> $text{'yes'}\n",
74 $_[0]->{'reverse'} ? "checked" : "";
75 printf "<input type=radio name=reverse value=0 %s> $text{'no'}</td>\n",
76 $_[0]->{'reverse'} ? "" : "checked";
78 print "<td><b>$text{'acl_multiple'}</b></td> <td nowrap>\n";
79 printf "<input type=radio name=multiple value=1 %s> $text{'yes'}\n",
80 $_[0]->{'multiple'} ? "checked" : "";
81 printf "<input type=radio name=multiple value=0 %s> $text{'no'}</td> </tr>\n",
82 $_[0]->{'multiple'} ? "" : "checked";
84 print "<tr> <td><b>$text{'acl_ro'}</b></td> <td nowrap>\n";
85 printf "<input type=radio name=ro value=1 %s> $text{'yes'}\n",
86 $_[0]->{'ro'} ? "checked" : "";
87 printf "<input type=radio name=ro value=0 %s> $text{'no'}</td>\n",
88 $_[0]->{'ro'} ? "" : "checked";
90 print "<td><b>$text{'acl_apply'}</b></td> <td nowrap>\n";
91 print &ui_select("apply", $_[0]->{'apply'},
92 [ [ 1, $text{'yes'} ],
93 [ 2, $text{'acl_applyonly'} ],
94 [ 3, $text{'acl_applygonly'} ],
95 [ 0, $text{'no'} ] ]),"</td> </tr>\n";
97 print "<tr> <td><b>$text{'acl_file'}</b></td> <td nowrap>\n";
98 printf "<input type=radio name=file value=1 %s> $text{'yes'}\n",
99 $_[0]->{'file'} ? "checked" : "";
100 printf "<input type=radio name=file value=0 %s> $text{'no'}</td>\n",
101 $_[0]->{'file'} ? "" : "checked";
103 print "<td><b>$text{'acl_params'}</b></td> <td nowrap>\n";
104 printf "<input type=radio name=params value=1 %s> $text{'yes'}\n",
105 $_[0]->{'params'} ? "checked" : "";
106 printf "<input type=radio name=params value=0 %s> $text{'no'}</td> </tr>\n",
107 $_[0]->{'params'} ? "" : "checked";
109 print "<tr> <td><b>$text{'acl_opts'}</b></td> <td nowrap>\n";
110 printf "<input type=radio name=opts value=1 %s> $text{'yes'}\n",
111 $_[0]->{'opts'} ? "checked" : "";
112 printf "<input type=radio name=opts value=0 %s> $text{'no'}</td>\n",
113 $_[0]->{'opts'} ? "" : "checked";
115 print "<td><b>$text{'acl_delete'}</b></td> <td nowrap>\n";
116 printf "<input type=radio name=delete value=1 %s> $text{'yes'}\n",
117 $_[0]->{'delete'} ? "checked" : "";
118 printf "<input type=radio name=delete value=0 %s> $text{'no'}</td> </tr>\n",
119 $_[0]->{'delete'} ? "" : "checked";
121 print "<tr> <td><b>$text{'acl_gen'}</b></td> <td nowrap>\n";
122 printf "<input type=radio name=gen value=1 %s> $text{'yes'}\n",
123 $_[0]->{'gen'} ? "checked" : "";
124 printf "<input type=radio name=gen value=0 %s> $text{'no'}</td>\n",
125 $_[0]->{'gen'} ? "" : "checked";
127 print "<td><b>$text{'acl_whois'}</b></td> <td nowrap>\n";
128 printf "<input type=radio name=whois value=1 %s> $text{'yes'}\n",
129 $_[0]->{'whois'} ? "checked" : "";
130 printf "<input type=radio name=whois value=0 %s> $text{'no'}</td> </tr>\n",
131 $_[0]->{'whois'} ? "" : "checked";
133 print "<tr> <td><b>$text{'acl_findfree'}</b></td> <td nowrap>\n";
134 printf "<input type=radio name=findfree value=1 %s> $text{'yes'}\n",
135 $_[0]->{'findfree'} ? "checked" : "";
136 printf "<input type=radio name=findfree value=0 %s> $text{'no'}</td>\n",
137 $_[0]->{'findfree'} ? "" : "checked";
139 print "<td><b>$text{'acl_remote'}</b></td> <td nowrap>\n";
140 printf "<input type=radio name=remote value=1 %s> $text{'yes'}\n",
141 $_[0]->{'remote'} ? "checked" : "";
142 printf "<input type=radio name=remote value=0 %s> $text{'no'}</td> </tr>\n",
143 $_[0]->{'remote'} ? "" : "checked";
145 print "<tr> <td><b>$text{'acl_slaves'}</b></td> <td nowrap>\n";
146 printf "<input type=radio name=slaves value=1 %s> $text{'yes'}\n",
147 $_[0]->{'slaves'} ? "checked" : "";
148 printf "<input type=radio name=slaves value=0 %s> $text{'no'}</td>\n",
149 $_[0]->{'slaves'} ? "" : "checked";
153 print "<tr> <td><b>$text{'acl_views'}</b></td> <td colspan=3>\n";
154 printf "<input type=radio name=views value=1 %s> $text{'yes'}\n",
155 $_[0]->{'views'} == 1 ? "checked" : "";
156 printf "<input type=radio name=views value=2 %s> $text{'acl_edonly'}\n",
157 $_[0]->{'views'} == 2 ? "checked" : "";
158 printf "<input type=radio name=views value=0 %s> $text{'no'}</td> </tr>\n",
159 $_[0]->{'views'} ? "" : "checked";
162 local $m = $_[0]->{'vlist'} eq '*' ? 1 :
163 $_[0]->{'vlist'} =~ /^\!/ ? 2 :
164 $_[0]->{'vlist'} eq '' ? 3 : 0;
165 print "<tr> <td valign=top><b>$text{'acl_vlist'}</b></td>\n";
166 print "<td colspan=3><table cellpadding=0 cellspacing=0> <tr><td valign=top>\n";
167 printf "<input type=radio name=vlist_def value=1 %s> %s<br>\n",
168 $m == 1 ? 'checked' : '', $text{'acl_vall'};
169 printf "<input type=radio name=vlist_def value=0 %s> %s<br>\n",
170 $m == 0 ? 'checked' : '', $text{'acl_vsel'};
171 printf "<input type=radio name=vlist_def value=2 %s> %s<br>\n",
172 $m == 2 ? 'checked' : '', $text{'acl_vnsel'};
173 printf "<input type=radio name=vlist_def value=3 %s> %s</td>\n",
174 $m == 3 ? 'checked' : '', $text{'acl_vnone'};
176 print "<td><select name=vlist multiple size=4 width=150>\n";
178 map { $vcan{$_}++ } split(/\s+/, $_[0]->{'vlist'});
179 foreach $v (sort { $a->{'value'} cmp $b->{'value'} } @views) {
180 printf "<option value='%s' %s>%s\n",
182 $vcan{$v->{'value'}} ? "selected" : "", $v->{'value'};
184 print "</select></td> </tr></table></td></tr>\n";
188 # acl_security_save(&options)
189 # Parse the form for security options for the bind8 module
190 sub acl_security_save
192 if ($in{'zones_def'} == 1) {
193 $_[0]->{'zones'} = "*";
195 elsif ($in{'zones_def'} == 2) {
196 $_[0]->{'zones'} = join(" ", "!", split(/\0/, $in{'zones'}));
199 $_[0]->{'zones'} = join(" ", split(/\0/, $in{'zones'}));
201 $_[0]->{'types'} = $in{'types_def'} ? undef : $in{'types'};
202 $_[0]->{'master'} = $in{'master'} || 0;
203 $_[0]->{'slave'} = $in{'slave'} || 0;
204 $_[0]->{'forward'} = $in{'forward'} || 0;
205 $_[0]->{'delegation'} = $in{'delegation'} || 0;
206 $_[0]->{'defaults'} = $in{'defaults'};
207 $_[0]->{'reverse'} = $in{'reverse'};
208 $_[0]->{'multiple'} = $in{'multiple'};
209 $_[0]->{'ro'} = $in{'ro'};
210 $_[0]->{'apply'} = $in{'apply'};
211 $_[0]->{'dir'} = $in{'dir'};
212 $_[0]->{'dironly'} = $in{'dironly'};
213 $_[0]->{'file'} = $in{'file'};
214 $_[0]->{'params'} = $in{'params'};
215 $_[0]->{'opts'} = $in{'opts'};
216 $_[0]->{'delete'} = $in{'delete'};
217 $_[0]->{'findfree'} = $in{'findfree'};
218 $_[0]->{'slaves'} = $in{'slaves'};
219 $_[0]->{'views'} = $in{'views'};
220 $_[0]->{'remote'} = $in{'remote'};
221 $_[0]->{'gen'} = $in{'gen'};
222 $_[0]->{'whois'} = $in{'whois'};
223 $_[0]->{'vlist'} = $in{'vlist_def'} == 1 ? "*" :
224 $in{'vlist_def'} == 3 ? "" :
225 $in{'vlist_def'} == 2 ? join(" ", "!",split(/\0/, $in{'vlist'}))
226 : join(" ", split(/\0/, $in{'vlist'}));