Created attachment 1324764 [details]
Description of problem:
dhclient_script has a function called eventually_add_hostnames_domain_to_search() which adds the domain in the search line of /etc/resolv.conf when no hostname is set and an alternate domain than the one retrieved by DHCP is set.
In that function, calls to "ipcalc" to retrieve a name from DHCP set also the HOSTNAME env variable, which shouldn't be the case (the function is supposed to just add hostname's domain to search line).
This is an issue when dhclient is called directly by the administrator and custom scripts are used in /etc/dhclient.d/*.sh (sourced by execute_client_side_configuration_scripts()).
Version-Release number of selected component (if applicable):
dhclient-4.2.5-58.el7.x86_64 and before
Steps to Reproduce:
1. Disable NetworkManager
# systemctl stop NetworkManager
2. Stop networking
# /etc/init.d/network stop
3. Set hostname to localhost.localdomain
# hostname localhost.localdomain
4. Create /etc/dhcp/dhclient.d/myscript.sh
# cat << EOF > /etc/dhcp/dhclient.d/myscript.sh
# chmod +x /etc/dhcp/dhclient.d/myscript.sh
5. Execute dhclient -1 -d
-> $HOSTNAME is set and need_hostname returns 1 (no need for a hostname)
Thank you for reporting the issue and patch provided.
As it's downstream script only upstream report/commit is not needed so it should be easy.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.