fix axfr-server-stuff (and close allow-transfer block), let updater and settings validate ipv4/ipv6 via function validate_ip

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-04-22 16:39:35 +02:00
parent ce9c8a766f
commit f2d10046b6
4 changed files with 236 additions and 215 deletions

View File

@@ -73,7 +73,7 @@ return array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'axfrservers', 'varname' => 'axfrservers',
'type' => 'string', 'type' => 'string',
'string_regexp' => '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(, ?(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}))*$/i', 'string_type' => 'validate_ip',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',

View File

@@ -676,13 +676,13 @@ if(isFroxlorVersion('0.9.6'))
`code` varchar(3) NOT NULL, `code` varchar(3) NOT NULL,
`enabled` tinyint(1) DEFAULT '1', `enabled` tinyint(1) DEFAULT '1',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM;"); ) ENGINE=MyISAM;");
$db->query("CREATE TABLE IF NOT EXISTS `domain_redirect_codes` ( $db->query("CREATE TABLE IF NOT EXISTS `domain_redirect_codes` (
`rid` int(5) NOT NULL, `rid` int(5) NOT NULL,
`did` int(11) unsigned NOT NULL, `did` int(11) unsigned NOT NULL,
UNIQUE KEY `rc` (`rid`, `did`) UNIQUE KEY `rc` (`rid`, `did`)
) ENGINE=MyISAM;"); ) ENGINE=MyISAM;");
lastStepStatus(0); lastStepStatus(0);
showUpdateStep("Filling new tables with default data"); showUpdateStep("Filling new tables with default data");
@@ -1202,8 +1202,8 @@ if(isFroxlorVersion('0.9.14-svn6'))
/* /*
* revert database changes we did for multiserver-support * revert database changes we did for multiserver-support
* before branching - sorry guys :/ * before branching - sorry guys :/
*/ */
if(isFroxlorVersion('0.9.14-svn9')) if(isFroxlorVersion('0.9.14-svn9'))
{ {
showUpdateStep("Reverting multiserver-patches (svn)", false); showUpdateStep("Reverting multiserver-patches (svn)", false);
@@ -1400,13 +1400,13 @@ if(isFroxlorVersion('0.9.17-svn1'))
`fid` int(11) NOT NULL, `fid` int(11) NOT NULL,
`docrootsettings` text NOT NULL, `docrootsettings` text NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM;"); ) ENGINE=MyISAM;");
$db->query("CREATE TABLE IF NOT EXISTS `domain_docrootsettings` ( $db->query("CREATE TABLE IF NOT EXISTS `domain_docrootsettings` (
`id` int(5) NOT NULL auto_increment, `id` int(5) NOT NULL auto_increment,
`fid` int(11) NOT NULL, `fid` int(11) NOT NULL,
`docrootsettings` text NOT NULL, `docrootsettings` text NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM;"); ) ENGINE=MyISAM;");
lastStepStatus(0); lastStepStatus(0);
updateToVersion('0.9.17-svn2'); updateToVersion('0.9.17-svn2');
@@ -2092,9 +2092,16 @@ if (isFroxlorVersion('0.9.29-dev2')) {
showUpdateStep("Updating from 0.9.29-dev2 to 0.9.29-dev3", true); showUpdateStep("Updating from 0.9.29-dev2 to 0.9.29-dev3", true);
lastStepStatus(0); lastStepStatus(0);
$system_afxrservers = isset($_POST['system_afxrservers']) ? $_POST['system_afxrservers'] : ''; $system_afxrservers = isset($_POST['system_afxrservers']) ? trim($_POST['system_afxrservers']) : '';
if (!preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(, ?(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}))*$/i', $system_afxrservers)) { if ($system_afxrservers != '') {
$system_afxrservers = ''; $axfrservers = explode(',', $system_afxrservers);
$newaxfrserver = array();
foreach ($axfrservers as $index => $axfrserver) {
if (validate_ip($axfrserver, true) !== false) {
$newaxfrserver[] = $axfrserver;
}
}
$system_afxrservers = implode(", ", $newaxfrserver);
} }
showUpdateStep("Inserting new setting for AFXR server", true); showUpdateStep("Inserting new setting for AFXR server", true);
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'axfrservers', '".$db->escape($system_afxrservers)."');"); $db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'axfrservers', '".$db->escape($system_afxrservers)."');");

View File

@@ -86,6 +86,13 @@ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
$returnvalue = (($newfieldvalue == makeCorrectDir($newfieldvalue)) || ($newfieldvalue == makeCorrectFile($newfieldvalue))); $returnvalue = (($newfieldvalue == makeCorrectDir($newfieldvalue)) || ($newfieldvalue == makeCorrectFile($newfieldvalue)));
} }
} }
elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'validate_ip') {
$newfieldvalue = validate_ip($newfieldvalue, true);
if ($newfieldvalue === false) {
$newfieldvalue = '';
}
$returnvalue = false;
}
elseif (preg_match('/^[^\r\n\t\f\0]*$/D', $newfieldvalue)) { elseif (preg_match('/^[^\r\n\t\f\0]*$/D', $newfieldvalue)) {
$returnvalue = true; $returnvalue = true;
} }

View File

@@ -19,7 +19,7 @@
/* /*
* This script creates the php.ini's used by mod_suPHP+php-cgi * This script creates the php.ini's used by mod_suPHP+php-cgi
*/ */
if(@php_sapi_name() != 'cli' if(@php_sapi_name() != 'cli'
&& @php_sapi_name() != 'cgi' && @php_sapi_name() != 'cgi'
@@ -73,7 +73,7 @@ class bind
if ($this->settings['system']['axfrservers'] != '') { if ($this->settings['system']['axfrservers'] != '') {
$axfrservers = explode(',', $this->settings['system']['axfrservers']); $axfrservers = explode(',', $this->settings['system']['axfrservers']);
foreach ($axfrservers as $axfrserver) { foreach ($axfrservers as $axfrserver) {
$this->axfrservers[] = trim($axfrservers); $this->axfrservers[] = trim($axfrserver);
} }
} }
} }
@@ -117,13 +117,17 @@ class bind
$bindconf_file.= ' file "' . makeCorrectFile($this->settings['system']['bindconf_directory'] . '/' . $domain['zonefile']) . '";' . "\n"; $bindconf_file.= ' file "' . makeCorrectFile($this->settings['system']['bindconf_directory'] . '/' . $domain['zonefile']) . '";' . "\n";
$bindconf_file.= ' allow-query { any; };' . "\n"; $bindconf_file.= ' allow-query { any; };' . "\n";
if (count($this->nameservers) > 0) { if (count($this->nameservers) > 0
|| count($this->axfrservers) > 0
) {
// open allow-transfer
$bindconf_file.= ' allow-transfer {' . "\n"; $bindconf_file.= ' allow-transfer {' . "\n";
// put nameservers in allow-transfer
if (count($this->nameservers) > 0) {
foreach ($this->nameservers as $ns) { foreach ($this->nameservers as $ns) {
$bindconf_file.= ' ' . $ns['ip'] . ';' . "\n"; $bindconf_file.= ' ' . $ns['ip'] . ';' . "\n";
} }
} }
// AXFR server #100 // AXFR server #100
if (count($this->axfrservers) > 0) { if (count($this->axfrservers) > 0) {
foreach ($this->axfrservers as $axfrserver) { foreach ($this->axfrservers as $axfrserver) {
@@ -132,6 +136,9 @@ class bind
} }
} }
} }
// close allow-transfer
$bindconf_file.= '};' . "\n";
}
$bindconf_file.= '};' . "\n"; $bindconf_file.= '};' . "\n";
$bindconf_file.= "\n"; $bindconf_file.= "\n";