handle_resolver_configuration() works incorrectly if resolv.conf is a symlink to resolv-peerdns.conf
The issue has been exposed by an update to the postinstall script to initscripts which foe some reason makes resolv.conf a symlink to resolv-peerdns.conf. When that happens the handle_resolver_configuration() routing generates a resolv.conf like:
; generated by /usr/sbin/dhclient-script
search howitts.co.uk
nameserver 172.17.2.1
# Please do not edit this file.
# See http://www.clearcenter.com/support/documentation/clearos_guides/dns_and_resolver
domain howitts.libvirt
nameserver 127.0.0.1
instead of:
# Please do not edit this file.
# See http://www.clearcenter.com/support/documentation/clearos_guides/dns_and_resolver
domain howitts.libvirt
nameserver 127.0.0.1
This can break reverse dns lookups of local IP's which among other things messes up the Identifier column in app-dhcp (perhaps only if Gateway Management is running). It depends what the upstream resolver returns as 127.0.0.1 may never get used.
To reproduce run:
rm -f resolv.conf
ln -s resolv-peerdns.conf resolv.conf
/var/clearos/events/network_peerdns/network_resolver
The first two steps are what initscripts does. The third step is from an event, either filewatch-network-configuration-event.conf or filewatch-network-peerdns-event.conf, which is triggered, probably, from initscripts. These call /var/clearos/events/network_configuration/network_resolver or/var/clearos/events/network_peerdns/network_resolver which are the same and execute handle_resolver_configuration(). At this point you have the issue
You can then fix the issue by just executing:
/var/clearos/events/network_peerdns/network_resolver
This time round it fixes it.
It is not necessarily the right answer, but it can be fixed in handle_resolver_configuration() by changing:
$resolv_file = new File(self::FILE_RESOLV, TRUE);
if ($resolv_file->exists())
$current = $resolv_file->get_contents();
else
$current = '';
if (trim($resolv_lines) == trim($current))
return;
if ($resolv_file->exists())
$resolv_file->delete();
to:
$resolv_file = new File(self::FILE_RESOLV, TRUE);
$current = '';
if ($resolv_file->exists())
$resolv_file->delete();
At the same time the issue in initscripts needs to be fixed.
It is possible this is caused by PHP caching the resolv.conf file as we don't see there $current is otherwise written back to the file.