Project

General

Profile

« Previous | Next » 

Revision e5770bc2

Added by Bill Marquette about 14 years ago

DHCP only knows about IPv4
don't allow admins to shoot themselves with v6 addresses in the config

View differences:

usr/local/www/services_dhcp.php
116 116
if (!$if || !isset($iflist[$if])) {
117 117
	foreach ($iflist as $ifent => $ifname) {
118 118
		$oc = $config['interfaces'][$ifent];
119
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddr($oc['ipaddr']))) ||
120
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddr($oc['ipaddr']))))
119
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
120
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
121 121
			continue;
122 122
		$if = $ifent;
123 123
		break;
......
208 208

  
209 209
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
210 210

  
211
		if (($_POST['range_from'] && !is_ipaddr($_POST['range_from'])))
211
		if (($_POST['range_from'] && !is_ipaddrv4($_POST['range_from'])))
212 212
			$input_errors[] = gettext("A valid range must be specified.");
213
		if (($_POST['range_to'] && !is_ipaddr($_POST['range_to'])))
213
		if (($_POST['range_to'] && !is_ipaddrv4($_POST['range_to'])))
214 214
			$input_errors[] = gettext("A valid range must be specified.");
215
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway'])))
215
		if (($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])))
216 216
			$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
217
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2'])))
217
		if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
218 218
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
219
		if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2'])))
219
		if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])))
220 220
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary DNS servers.");
221 221

  
222 222
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
......
225 225
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
226 226
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
227 227
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
228
		if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2'])))
228
		if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
229 229
			$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
230 230
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
231 231
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
232
		if ($_POST['tftp'] && !is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
232
		if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
233 233
			$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
234
		if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver'])))
234
		if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
235 235
			$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
236 236

  
237 237
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
......
276 276
					$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
277 277
				else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
278 278
					$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
279
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddr($numberoption['value']) && !is_hostname($numberoption['value']) )
279
				else if ( $numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value']) )
280 280
					$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
281 281
			}
282 282
		}
......
538 538
	$i = 0;
539 539
	foreach ($iflist as $ifent => $ifname) {
540 540
		$oc = $config['interfaces'][$ifent];
541
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddr($oc['ipaddr']))) ||
542
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddr($oc['ipaddr']))))
541
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
542
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr']))))
543 543
			continue;
544 544
		if ($ifent == $if)
545 545
			$active = true;

Also available in: Unified diff