Project

General

Profile

« Previous | Next » 

Revision 32749275

Added by Berger Alexander about 10 years ago

Currently pfsense enforces unique unqualified hostnames for static dhcp leases, which is not correct as only the fully qualified hostname (hostname + domainname) must be unique. With this commit the old validation logic for uniqeness is modified such that hostnames no longer need to be unique and at the same time the fully qualified hostname hast to be unique.

This change makes it possible to have host with identical hostnames in different (sub)domains. For example myhost.sales.acme.com and myhost.support.acme.com will now be possible.

View differences:

usr/local/www/services_dhcp_edit.php
187 187
	}
188 188

  
189 189
	/* check for overlaps */
190
	foreach ($a_maps as $mapent) {
191
		if (isset($id) && ($a_maps[$id]) && ($a_maps[$id] === $mapent))
192
			continue;
193

  
194
		if ((($mapent['hostname'] == $_POST['hostname']) && $mapent['hostname'])  || (($mapent['mac'] == $_POST['mac']) && $mapent['mac']) || (($mapent['ipaddr'] == $_POST['ipaddr']) && $mapent['ipaddr'] ) || (($mapent['cid'] == $_POST['cid']) && $mapent['cid'])) {
195
			$input_errors[] = gettext("This Hostname, IP, MAC address or Client identifier already exists.");
196
			break;
197
		}
198
	}
190
  foreach ($a_maps as $mapent) {
191
    if (isset($id) && ($a_maps[$id]) && ($a_maps[$id] === $mapent))
192
      continue;
193
      /* The fully qualified hostname (hostname + '.' + domainname) must be unique.
194
        The unqualified hostname does not have to be unique as long as the fully
195
        qualified hostname is unique. */
196
		$existingFqn = "{$mapent['hostname']}.{$mapent['domain']}";
197
    $candidateFqn = "{$_POST['hostname']}.{$_POST['domain']}";
198
    if ((($existingFqn == $candidateFqn) && $mapent['hostname']) || (($mapent['mac'] == $_POST['mac']) && $mapent['mac']) || (($mapent['ipaddr'] == $_POST['ipaddr']) && $mapent['ipaddr'] ) || (($mapent['cid'] == $_POST['cid']) && $mapent['cid'])) {
199
      $input_errors[] = gettext("This fully qualified hostname (Hostname + Domainname), IP, MAC address or Client identifier already exists.");
200
      break;
201
    }
202
  }
199 203

  
200 204
	/* make sure it's not within the dynamic subnet */
201 205
	if ($_POST['ipaddr']) {

Also available in: Unified diff