📄 acl_security.pl
字号:
#! /usr/bin/perl## B9DDNS - BIND 9 dynamic DNS webmin module.# Copyright (C) 2003 John Horne. <john.horne@plymouth.ac.uk># Copyright (C) 2004 John Horne. <john.horne@plymouth.ac.uk>## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.#use strict;no strict 'vars';require 'b9ddns-lib.pl';## Output HTML for editing security options.## acl_security_form(&options)#sub acl_security_form { my $zone_sel = my $view_sel = 0; my $zone = my $conf = my $view = my $disabled = ''; my @zones = my @views = (); my %zcan = my %vcan = (); my $no = $text{'no'}; my $yes = $text{'yes'}; $zone_sel = ($_[0]->{'zones'} eq '*') ? 1 : ($_[0]->{'zones'} =~ /^\!/o) ? 2 : 0; print '<tr><td valign=top><b>', $text{'acl_zones'}, '</b></td>'; print '<td colspan=3><table cellpadding=0 cellspacing=0><tr><td valign=top>'; printf "<input type=radio name=zones_def value=1 %s> %s<br>\n", &checked($zone_sel == 1), $text{'acl_zall'}; printf "<input type=radio name=zones_def value=0 %s> %s<br>\n", &checked($zone_sel == 0), $text{'acl_zsel'}; printf "<input type=radio name=zones_def value=2 %s> %s </td>\n", &checked($zone_sel == 2), $text{'acl_znsel'}; print '<td><select name=zones multiple size=4>'; $conf = &get_config(); @zones = grep { $_->{'value'} ne '.' } &find('zone', $conf); @views = &find('view', $conf); foreach $view (@views) { push(@zones, grep { $_->{'value'} ne '.' } &find('zone', $view->{'members'})); } map { $zcan{lc($_)}++ } split(/\s+/, $_[0]->{'zones'}); foreach $zone (sort { $a->{'value'} cmp $b->{'value'} } @zones) { $zone->{'value'} = lc($zone->{'value'}); $zone->{'value'} =~ s/\.$//o unless ($zone->{'value'} eq '.'); printf "<option value='%s' %s>%s\n", $zone->{'value'}, $zcan{$zone->{'value'}} ? 'selected' : '', &arpa_to_ip(&ip6arpa_to_net($zone->{'value'})); } foreach $view (sort { $a->{'value'} cmp $b->{'value'} } @views) { $view->{'value'} = $view->{'value'}; printf "<option value='%s' %s>%s\n", 'view_' . $view->{'value'}, $zcan{'view_' . $view->{'value'}} ? 'selected' : '', &text('acl_inview', $view->{'value'}); } print '</select></td></tr></table></td></tr>'; if (@views) { $view_sel = ($_[0]->{'vlist'} eq '*') ? 1 : ($_[0]->{'vlist'} =~ /^!/o) ? 2 : 0; print '<tr><td></td></tr>'; print '<tr><td valign=top><b>', $text{'acl_vlist'}, '</b></td>'; print '<td colspan=3><table cellpadding=0 cellspacing=0><tr><td valign=top>'; printf '<input type=radio name=vlist_def value=1 %s> %s<br>', &checked($view_sel == 1), $text{'acl_vall'}; printf '<input type=radio name=vlist_def value=0 %s> %s<br>', &checked($view_sel == 0), $text{'acl_vsel'}; printf '<input type=radio name=vlist_def value=2 %s> %s </td>', &checked($view_sel == 2), $text{'acl_vnsel'}; print '<td><select name=vlist multiple size=4>'; map { $vcan{$_}++ } split(/\s+/, $_[0]->{'vlist'}); foreach $view (sort { $a->{'value'} cmp $b->{'value'} } @views) { printf "<option value='%s' %s>%s\n", $view->{'value'}, $vcan{$view->{'value'}} ? 'selected' : '', $view->{'value'}; } print '</select></td></tr></table></td></tr>'; } print '<tr><td><br></td></tr>'; print '<tr><td valign=top><b>', $text{'acl_dir'}, '</b></td>'; printf "<td colspan=3><input name=dir size=45 value='%s'> %s<br>\n", $_[0]->{'dir'}, &file_chooser_button('dir', 1); printf "<input type=checkbox name=dironly value=1 %s> %s</td></tr>\n", &checked($_[0]->{'dironly'}), $text{'acl_dironly'}; print '<tr><td><br></td></tr>'; print '<tr><td><b>', $text{'acl_master'}, '</b></td><td nowrap>'; printf "<input type=radio name=master value=1 %s> $yes\n", &checked($_[0]->{'master'}); printf "<input type=radio name=master value=0 %s> $no</td>\n", &checked(! $_[0]->{'master'}); print '<td><b>', $text{'acl_slave'}, '</b></td><td nowrap>'; printf "<input type=radio name=slave value=1 %s> $yes\n", &checked($_[0]->{'slave'}); printf "<input type=radio name=slave value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'slave'}); print '<tr><td><b>', $text{'acl_forward'}, '</b></td><td nowrap>'; printf "<input type=radio name=forward value=1 %s> $yes\n", &checked($_[0]->{'forward'}); printf "<input type=radio name=forward value=0 %s> $no</td>\n", &checked(! $_[0]->{'forward'}); print '<td><b>', $text{'acl_defaults'}, '</b></td><td nowrap>'; printf "<input type=radio name=defaults value=1 %s> $yes\n", &checked($_[0]->{'defaults'}); printf "<input type=radio name=defaults value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'defaults'}); print '<tr><td><b>', $text{'acl_reverse'}, '</b></td><td nowrap>'; printf "<input type=radio name=reverse value=1 %s> $yes\n", &checked($_[0]->{'reverse'}); printf "<input type=radio name=reverse value=0 %s> $no</td>\n", &checked(! $_[0]->{'reverse'}); print '<td><b>', $text{'acl_ro'}, '</b></td><td nowrap>'; printf "<input type=radio name=ro value=1 %s> $yes\n", &checked($_[0]->{'ro'}); printf "<input type=radio name=ro value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'ro'}); print '<tr><td><b>', $text{'acl_rev_updt_must'}, '</b></td><td nowrap>'; printf "<input type=radio name=rev_updt_must value=1 %s> $yes\n", &checked($_[0]->{'rev_updt_must'}); printf "<input type=radio name=rev_updt_must value=0 %s> $no</td>\n", &checked(! $_[0]->{'rev_updt_must'}); print '<td><b>', $text{'acl_params'}, '</b></td><td nowrap>'; printf "<input type=radio name=params value=1 %s> $yes\n", &checked($_[0]->{'params'}); printf "<input type=radio name=params value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'params'}); print '<tr><td><b>', $text{'acl_file'}, '</b></td><td nowrap>'; printf "<input type=radio name=file value=1 %s> $yes\n", &checked($_[0]->{'file'}); printf "<input type=radio name=file value=0 %s> $no</td>\n", &checked(! $_[0]->{'file'}); print '<td><b>', $text{'acl_delete'}, '</b></td><td nowrap>'; printf "<input type=radio name=delete value=1 %s> $yes\n", &checked($_[0]->{'delete'}); printf "<input type=radio name=delete value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'delete'}); print '<tr><td><b>', $text{'acl_opts'}, '</b></td><td nowrap>'; printf "<input type=radio name=opts value=1 %s> $yes\n", &checked($_[0]->{'opts'}); printf "<input type=radio name=opts value=0 %s> $no</td>\n", &checked(! $_[0]->{'opts'}); $disabled = (&bind_version(0) < 9.23) ? 'disabled' : ''; print '<td><b>', $text{'acl_dyn_as_static'}, '</b></td><td nowrap>'; printf "<input type=radio $disabled name=dyn_as_static value=1 %s> $yes\n", &checked($_[0]->{'dyn_as_static'}); printf "<input type=radio $disabled name=dyn_as_static value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'dyn_as_static'}); print '<tr><td><b>', $text{'acl_gen'}, '</b></td><td nowrap>'; printf "<input type=radio name=gen value=1 %s> $yes\n", &checked($_[0]->{'gen'}); printf "<input type=radio name=gen value=0 %s> $no</td>\n", &checked(! $_[0]->{'gen'}); print '<td><b>', $text{'acl_remote'}, '</b></td><td nowrap>'; printf "<input type=radio name=remote value=1 %s> $yes\n", &checked($_[0]->{'remote'}); printf "<input type=radio name=remote value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'remote'}); print '<tr><td><b>', $text{'acl_findfree'}, '</b></td><td nowrap>'; printf "<input type=radio name=findfree value=1 %s> $yes\n", &checked($_[0]->{'findfree'}); printf "<input type=radio name=findfree value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'findfree'}); $disabled = (&bind_version(0) < 9.1) ? 'disabled' : ''; print '<tr><td><br></td></tr>'; print '<tr><td width=40%><b>', $text{'acl_apply'}, '</b></td><td nowrap>'; printf "<input type=radio name=apply value=1 %s> $yes\n", &checked($_[0]->{'apply'} == 1); printf "<input type=radio name=apply $disabled value=2 %s> %s\n", &checked($_[0]->{'apply'} == 2), $text{'acl_applyonly'}; printf "<input type=radio name=apply value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'apply'}); print '<tr><td width=40%><b>', $text{'acl_multiple'}, '</b></td><td nowrap>'; printf "<input type=radio name=no_multiple value=0 %s> $yes\n", &checked(! $_[0]->{'no_multiple'}); printf "<input type=radio name=no_multiple value=2 %s> %s\n", &checked($_[0]->{'no_multiple'} == 2), $text{'acl_multiple_rev'}; printf "<input type=radio name=no_multiple value=1 %s> $no</td></tr>\n", &checked($_[0]->{'no_multiple'} == 1); print '<tr><td width=40%><b>', $text{'acl_tld'}, '</b></td><td nowrap>'; printf "<input type=radio name=tld value=1 %s> $yes\n", &checked($_[0]->{'tld'} == 1); printf "<input type=radio name=tld value=2 %s> %s\n", &checked($_[0]->{'tld'} == 2), $text{'acl_tld_masters'}; printf " <input type=radio name=tld value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'tld'}); print '<tr><td width=40% valign=top><b>', $text{'acl_sd'}, '</b></td><td colspan=3>'; printf "<input type=radio name=sd value=1 %s> $yes\n", &checked($_[0]->{'sd'} == 1); printf "<input type=radio name=sd value=2 %s> %s\n", &checked($_[0]->{'sd'} == 2), $text{'acl_tld_masters'}; printf " <input type=radio name=sd value=0 %s> $no<br>\n", &checked(! $_[0]->{'sd'}); printf "%s<input type=checkbox name=sd2 value=1 %s> %s</td></tr>\n", ' ' x 8, &checked($_[0]->{'sd2'}), $text{'acl_sd2'}; print '<tr><td width=40%><b>', $text{'acl_views'}, '</b></td><td colspan=3>'; printf "<input type=radio name=views value=1 %s> $yes\n", &checked($_[0]->{'views'} == 1); printf "<input type=radio name=views value=2 %s> %s\n", &checked($_[0]->{'views'} == 2), $text{'acl_edonly'}; printf "<input type=radio name=views value=0 %s> $no</td></tr>\n", &checked(! $_[0]->{'views'}); return;}## Parse the form for security options.## acl_security_save(&options)#sub acl_security_save { if ($in{'zones_def'} == 1) { $_[0]->{'zones'} = '*'; } elsif ($in{'zones_def'} == 2) { $_[0]->{'zones'} = join(' ', '!', split(/\0/, $in{'zones'})); } else { $_[0]->{'zones'} = join(' ', split(/\0/, $in{'zones'})); } $_[0]->{'vlist'} = ($in{'vlist_def'} == 1) ? '*' : ($in{'vlist_def'} == 2) ? join(' ', '!', split(/\0/, $in{'vlist'})) : join(' ', split(/\0/, $in{'vlist'})); $in{'dir'} = '/' unless ($in{'dir'}); $_[0]->{'master'} = $in{'master'}; $_[0]->{'slave'} = $in{'slave'}; $_[0]->{'forward'} = $in{'forward'}; $_[0]->{'defaults'} = $in{'defaults'}; $_[0]->{'reverse'} = $in{'reverse'}; $_[0]->{'rev_updt_must'} = ($in{'reverse'}) ? 0 : $in{'rev_updt_must'}; $_[0]->{'ro'} = $in{'ro'}; $_[0]->{'apply'} = $in{'apply'}; $_[0]->{'dir'} = $in{'dir'}; $_[0]->{'dironly'} = $in{'dironly'}; $_[0]->{'file'} = $in{'file'}; $_[0]->{'params'} = $in{'params'}; $_[0]->{'opts'} = $in{'opts'}; $_[0]->{'delete'} = $in{'delete'}; $_[0]->{'findfree'} = $in{'findfree'}; $_[0]->{'views'} = $in{'views'}; $_[0]->{'no_multiple'} = $in{'no_multiple'}; $_[0]->{'tld'} = $in{'tld'}; $_[0]->{'sd'} = $in{'sd'}; $_[0]->{'sd2'} = ($in{'sd'}) ? $in{'sd2'} : 0; $_[0]->{'remote'} = $in{'remote'}; $_[0]->{'gen'} = $in{'gen'}; $_[0]->{'dyn_as_static'} = $in{'dyn_as_static'}; return;}1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -