dhclient-script: make_resolv_conf(): keep old nameservers

if server sends domain-name/search, but no nameservers (#1269595)
This commit is contained in:
Jiri Popelka 2015-10-13 14:44:14 +02:00
parent 15e5415130
commit 609ced7095
2 changed files with 29 additions and 17 deletions

View File

@ -129,9 +129,13 @@ make_resolv_conf() {
echo "options ${RES_OPTIONS}" >> "${rscf}"
fi
for nameserver in ${new_domain_name_servers} ; do
echo "nameserver ${nameserver}" >> "${rscf}"
done
if [ -n "${new_domain_name_servers}" ]; then
for nameserver in ${new_domain_name_servers} ; do
echo "nameserver ${nameserver}" >> "${rscf}"
done
else # keep 'old' nameservers
sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p "${RESOLVCONF}" >> "${rscf}"
fi
change_resolv_conf "${rscf}"
rm -f "${rscf}"
@ -161,19 +165,23 @@ make_resolv_conf() {
echo "options ${RES_OPTIONS}" >> "${rscf}"
fi
shopt -s nocasematch
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
if [[ "$nameserver" =~ ^fe80:: ]]
then
zone_id="%${interface}"
else
zone_id=
fi
echo "nameserver ${nameserver}$zone_id" >> "${rscf}"
done
shopt -u nocasematch
shopt -s nocasematch
if [ -n "${new_dhcp6_name_servers}" ]; then
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
if [[ "$nameserver" =~ ^fe80:: ]]
then
zone_id="%${interface}"
else
zone_id=
fi
echo "nameserver ${nameserver}$zone_id" >> "${rscf}"
done
else # keep 'old' nameservers
sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p "${RESOLVCONF}" >> "${rscf}"
fi
shopt -u nocasematch
change_resolv_conf "${rscf}"
rm -f "${rscf}"

View File

@ -18,7 +18,7 @@
Summary: Dynamic host configuration protocol software
Name: dhcp
Version: 4.3.3
Release: 3%{?dist}
Release: 4%{?dist}
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
# dcantrell maintaining the package) made incorrect use of the epoch and
# that's why it is at 12 now. It should have never been used, but it was.
@ -663,6 +663,10 @@ done
%doc doc/html/
%changelog
* Tue Oct 13 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.3-4
- dhclient-script: make_resolv_conf(): keep old nameservers
if server sends domain-name/search, but no nameservers (#1269595)
* Tue Sep 22 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.3-3
- dhclient: make sure link-local address is ready in stateless mode (#1263466)