RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1490782 - dhclient_script incorrectly sets hostname when building /etc/resolv.conf
Summary: dhclient_script incorrectly sets hostname when building /etc/resolv.conf
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: dhcp
Version: 7.4
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Pavel Zhukov
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-09-12 08:43 UTC by Renaud Métrich
Modified: 2021-09-09 12:35 UTC (History)
5 users (show)

Fixed In Version: dhcp-4.2.5-63.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 08:00:52 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Suggested fix (699 bytes, text/plain)
2017-09-12 08:43 UTC, Renaud Métrich
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0658 0 None None None 2018-04-10 08:01:58 UTC

Description Renaud Métrich 2017-09-12 08:43:52 UTC
Created attachment 1324764 [details]
Suggested fix

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


How reproducible:

Always

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
myscript_config() {
	echo "HOSTNAME=$HOSTNAME"
	need_hostname
	echo "need_hostname=$?"
}
EOF
# chmod +x /etc/dhcp/dhclient.d/myscript.sh

5. Execute dhclient -1 -d


Actual results:

HOSTNAME=vm-rhel74.mydomain
need_hostname=1

-> $HOSTNAME is set and need_hostname returns 1 (no need for a hostname)

Expected results:

HOSTNAME=localhost.localdomain
need_hostname=0

Comment 3 Pavel Zhukov 2017-09-20 14:21:42 UTC
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.

Comment 13 errata-xmlrpc 2018-04-10 08:00:52 UTC
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.

https://access.redhat.com/errata/RHBA-2018:0658


Note You need to log in before you can comment on or make changes to this bug.