⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 create_slave.cgi

📁 BIND 9 dynamic DNS webmin module. This module supports both static and dynamic zones, and IPv4 and I
💻 CGI
字号:
#! /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.### Create a new slave zone.#use strict;no strict 'vars';require './b9ddns-lib.pl';my $ipv4 = my $ipv6 = 0;my $conf = my $vconf = my $zone = my $view = '';my $base = my $file = my $err = my $directive = '';my $zone_type = my $zone_conf = my $zone_file = '';my $fn_format = my $newidx = '';&ReadParse();$zone_type = $in{'type'} ? 'slave' : 'stub';&error_setup($in{'type'} ? $text{'screate_err1'} : $text{'screate_err2'});%access = &get_module_acl();unless ($access{'slave'}) {	&terror($in{'type'} ? 'screate_ecannot1' : 'screate_ecannot2');}if ($access{'ro'}) {	&terror('master_ero');}$conf = &get_config();if ($in{'view'}) {	$view = $conf->[$in{'view'}];	unless (&can_edit_view(\%access, $view)) {		&terror('master_eview');	}	$vconf = $view->{'members'};}else {	$vconf = $conf;}$newidx = @$vconf;## Validate the input.#$in{'zone'} = lc($in{'zone'});if ($in{'rev'}) {	if ($in{'zone'} =~ /\.(in-addr|ip6)\.arpa\.?$/o) {		$ipv4 = ($1 eq 'in-addr');		$in{'zone'} .= '.' unless ($in{'zone'} =~ /\.$/o);		$in{'zone'} = ($ipv4) ? &arpa_to_ip($in{'zone'})				      : &ip6arpa_to_net($in{'zone'});	}	$ipv4 = ($in{'zone'} =~ /^([\d.]+)$/o) &&		&valipaddr($1, '.in-addr.arpa.', 1, 0, 1, 1);	$ipv6 = ($in{'zone'} =~ /^([\da-f:]+)$/o) &&		&valipaddr($1, '.ip6.arpa.', 1, 0, 1, 0);	unless ($ipv4 || $ipv6) {		&terror('create_enet', $in{'zone'});	}	$in{'zone'} = ($ipv4) ? &ip_to_arpa($in{'zone'})			      : &net_to_ip6arpa($in{'zone'});}else {	$in{'zone'} .= '.' unless ($in{'zone'} =~ /\.$/o);	if ($in{'zone'} =~ /^[\d.]+$/o || $in{'zone'} =~ /:/o) {		&terror('create_edom2', $in{'zone'});	}	unless (&valdnsname($in{'zone'}, 0, '.')) {		&terror('create_edom', $in{'zone'});	}}$in{'zone'} =~ s/\.$//o;foreach $zone (&find('zone', $vconf)) {	if ($zone->{'value'} =~ /^$in{'zone'}\.?$/i) {		&terror('master_etaken');	}}$base = &zone_dir(0, \%access, $conf);if ($in{'file_def'} == 0) {	#	# Use the given filename.	#	$file = $in{'file'};	if (! $file || $file =~ /\s/o) {		&terror('files_efile');	}	unless ($file =~ /^\//o) {		$file = $base . '/' . $file;	}	unless (&allowed_zone_file(\%access, $file)) {		&terror('create_efile2', $file);	}}elsif ($in{'file_def'} == 2) {	#	# Create a filename.	#	$file = &create_zone_fn($conf, $in{'zone'}, $in{'rev'}, undef, $base);}if ($in{'file_def'} == 0 || $in{'file_def'} == 2) {	if (-r $config{'chroot'} . $file) {		&terror('create_efile4', $file);	}	if (open(ZONE, ">$config{'chroot'}$file")) {		close(ZONE);		&set_ownership($config{'chroot'} . $file, 0);	}	else {		$err = $!;		&terror('create_efile3', $file, $err);	}}## Now create the zone directive.#$base = &base_directory($conf);$file =~ s/^$base\/// if ($base);	# Only need to save the shortened name.$zone_conf = ($in{'view'}) ? $view : &get_config_parent();$directive = { 'name' => 'zone', 'values' => [ $in{'zone'} ], 'type' => 1,	       'members' => [ { 'name' => 'type', 'values' => [ $zone_type ] } ]	     };&save_directive($zone_conf, 'zone', [ $directive ], 0, 1, -1);&save_addr_match('masters', $directive, 1, 1, 1);if ($file) {	push(@{ $directive->{'members'} }, { 'name' => 'file',					     'values' => [ $file ] } );}if ($in{'view'}) {	$zone_file = $view->{'file'};}else {	$zone_file = $config{'zones_file'} ? $config{'zones_file'}					   : $config{'named_conf'};}&lock_file($config{'chroot'} . $zone_file);&save_directive($zone_conf, 'zone', [ $directive ], 0, 0, -1);&flush_file_lines();&unlock_file($config{'chroot'} . $zone_file);## Add the new zone to the access list.#&add_zone_access($in{'zone'});&webmin_log('create', $zone_type, $in{'zone'}, \%in);&redirect("edit_zone.cgi?index=${newidx}&view=$in{'view'}&type=${zone_type}&new_zone=1");exit;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -