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

📄 rndc_cmd.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.### Execute an RNDC command.#use strict;no strict 'vars';require './b9ddns-lib.pl';my $status = my $domain_given = my $both = 0;my $domain = my $output = my $rndc_arg = my $cmd = my $slave_error = '';&ReadParse();%access = &get_module_acl();if ($access{'ro'}) {	&terror('rndc_ecannot');}unless ($access{'apply'}) {	&terror('rndc_ecannot');}if (! $in{'index'} && $access{'apply'} != 1) {	&terror('rndc_ecannot');}$rndc_arg = $in{'cmd'};## Setting 'both' means run an 'rndc reconfig' and then do a 'reload'. Since# this will only be called from within a zone, the reload will only apply to# that zone. Doing a reload of all zones could be expensive if there are a lot# of them.#if ($rndc_arg eq 'conf_load') {	$both++;	$rndc_arg = 'reconfig';}if ($in{'slave'}) {	unless ($access{'remote'}) {		&terror('rndc_ecannot_rem');	}	&rndc_slave();	&webmin_log('rndc', undef, "$rndc_arg $domain on $in{'slave'}");	&redirect('');	exit;}$status = &named_running();if ($status == 0) {	&terror('named_pos_no_run');}elsif ($status < 0) {	&terror('named_ctrl_error', &named_err($status));}$domain_given++ if ($in{'index'});if ($rndc_arg eq 'reconfig') {	&do_reconfig();	$rndc_arg = 'reload' if ($both);}if ($rndc_arg eq 'reload') {	&do_reload();}if ($rndc_arg eq 'flush') {	&do_flush();}$domain = "edit_zone.cgi?index=$in{'index'}&view=$in{'view'}&type=$in{'type'}" if ($domain_given);&redirect($domain);exit;sub rndc_slave {	my $sysnam = '';	$domain = &get_domain();	$cmd = 'rndc ' . $rndc_arg;	$cmd .= ' ' . $domain if ($domain);	$cmd .= ' 2>&1';	&remote_error_setup(\&slave_error_handler);	&remote_foreign_require($in{'slave'}, $module_name, 'b9ddns-lib.pl');	if ($slave_error) {		&error($slave_error);	}	$output = &remote_eval($in{'slave'}, $module_name, "`$cmd`");	if ($output) {		&terror('rndc_err', $output);	}	$sysnam = &get_system_hostname();	&remote_foreign_call($in{'slave'}, $module_name, 'webmin_log',	       'rndc', undef, "$rndc_arg $domain from $sysnam");	return;}sub do_reconfig {	$cmd = $config{'rndc_cmd'} . ' reconfig 2>&1';	$output = &backquote_logged($cmd);	if ($? || $output) {		&terror('rndc_err', "<tt>$output</tt>");	}	&webmin_log('rndc', undef, 'reconfig');	return;}sub do_reload {	$domain = &get_domain();	$cmd = $config{'rndc_cmd'} . ' reload';	$cmd .= ' ' . $domain if ($domain);	$cmd .= ' 2>&1';	$output = &backquote_logged($cmd);	#	# It is possible that the admin will not immediately apply the changes	# to named.conf after creating a zone. As such we need to capture any	# failed 'reload' command, which fails because the zone is unknown, and	# replace it with a 'reconfig' command.	#	if ($output =~ /'reload' failed: not found/o) {		&do_reconfig();	}	elsif ($? || $output) {		&terror('rndc_err', "<tt>$output</tt>");	}	else {		&webmin_log('rndc', undef, "reload $domain");	}	return;}sub do_flush {	$cmd = $config{'rndc_cmd'} . ' flush 2>&1';	$output = &backquote_logged($cmd);	if ($? || $output) {		&terror('rndc_err', "<tt>$output</tt>");	}	&webmin_log('rndc', undef, 'flush');	return;}sub get_domain {	my $conf = my $zone = my $view = my $domain = '';	my $version = &bind_version(0);	if ($version >= 9.1) {		if ($in{'index'}) {			$conf = &get_config();			if ($in{'view'}) {				$view = $conf->[$in{'view'}];				$zone = $view->{'members'}->[$in{'index'}];				unless (&can_edit_zone(\%access, $zone, $view)) {					&terror($in{'slave'} ? 'rndc_ecannot_rem' : 'rndc_ecannot');				}				$domain = $zone->{'value'} . ' IN ' . $view->{'value'};			}			else {				$zone = $conf->[$in{'index'}];				unless (&can_edit_zone(\%access, $zone)) {					&terror($in{'slave'} ? 'rndc_ecannot_rem' : 'rndc_ecannot');				}				$domain = $zone->{'value'};			}		}	}	return $domain;}sub slave_error_handler {	$slave_error = $_[0];	return;}

⌨️ 快捷键说明

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