dhclient-script improvements (#672279)
This commit is contained in:
parent
45c037153f
commit
a2aab09028
101
dhclient-script
101
dhclient-script
@ -42,11 +42,13 @@ logmessage() {
|
|||||||
logger -p ${LOGFACILITY}.${LOGLEVEL} -t "NET" "dhclient: ${msg}"
|
logger -p ${LOGFACILITY}.${LOGLEVEL} -t "NET" "dhclient: ${msg}"
|
||||||
}
|
}
|
||||||
|
|
||||||
fix_context() {
|
if [ -x /sbin/restorecon ]; then
|
||||||
if [ -x /sbin/restorecon ]; then
|
fix_context() {
|
||||||
/sbin/restorecon ${1} >/dev/null 2>&1
|
/sbin/restorecon ${1} >/dev/null 2>&1
|
||||||
fi
|
}
|
||||||
}
|
else
|
||||||
|
fix_context() { :; }
|
||||||
|
fi
|
||||||
|
|
||||||
save_previous() {
|
save_previous() {
|
||||||
origfile="${1}"
|
origfile="${1}"
|
||||||
@ -125,7 +127,7 @@ make_resolv_conf() {
|
|||||||
[ -n "${new_domain_name_servers}" ] ||
|
[ -n "${new_domain_name_servers}" ] ||
|
||||||
[ -n "${new_domain_search}" ]; then
|
[ -n "${new_domain_search}" ]; then
|
||||||
save_previous /etc/resolv.conf
|
save_previous /etc/resolv.conf
|
||||||
rscf="$(mktemp /tmp/XXXXXX)"
|
rscf="$(mktemp ${TMPDIR:-/tmp}/XXXXXX)"
|
||||||
echo "; generated by /sbin/dhclient-script" > ${rscf}
|
echo "; generated by /sbin/dhclient-script" > ${rscf}
|
||||||
|
|
||||||
if [ -n "${SEARCH}" ]; then
|
if [ -n "${SEARCH}" ]; then
|
||||||
@ -165,7 +167,7 @@ make_resolv_conf() {
|
|||||||
elif [ -n "${new_dhcp6_name_servers}" ] ||
|
elif [ -n "${new_dhcp6_name_servers}" ] ||
|
||||||
[ -n "${new_dhcp6_domain_search}" ]; then
|
[ -n "${new_dhcp6_domain_search}" ]; then
|
||||||
save_previous /etc/resolv.conf
|
save_previous /etc/resolv.conf
|
||||||
rscf="$(mktemp /tmp/XXXXXX)"
|
rscf="$(mktemp ${TMPDIR:-/tmp}/XXXXXX)"
|
||||||
echo "; generated by /sbin/dhclient-script" > ${rscf}
|
echo "; generated by /sbin/dhclient-script" > ${rscf}
|
||||||
|
|
||||||
if [ -n "${SEARCH}" ]; then
|
if [ -n "${SEARCH}" ]; then
|
||||||
@ -299,13 +301,12 @@ is_router_reachable() {
|
|||||||
|
|
||||||
add_default_gateway() {
|
add_default_gateway() {
|
||||||
router="${1}"
|
router="${1}"
|
||||||
metric=""
|
|
||||||
|
|
||||||
|
if is_router_reachable ${router} ; then
|
||||||
|
metric=""
|
||||||
if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then
|
if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then
|
||||||
metric="metric ${2}"
|
metric="metric ${2}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_router_reachable ${router} ; then
|
|
||||||
ip -4 route replace default via ${router} dev ${interface} ${metric}
|
ip -4 route replace default via ${router} dev ${interface} ${metric}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
logmessage "failed to create default route: ${router} dev ${interface} ${metric}"
|
logmessage "failed to create default route: ${router} dev ${interface} ${metric}"
|
||||||
@ -318,6 +319,20 @@ add_default_gateway() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
execute_client_side_configuration_scripts() {
|
||||||
|
# execute any additional client side configuration scripts we have
|
||||||
|
if [ "${1}" == "config" ] || [ "${1}" == "restore" ]; then
|
||||||
|
for f in ${ETCDIR}/dhclient.d/*.sh ; do
|
||||||
|
if [ -x ${f} ]; then
|
||||||
|
subsystem="${f%.sh}"
|
||||||
|
subsystem="${subsystem##*/}"
|
||||||
|
. ${f}
|
||||||
|
"${subsystem}_${1}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
flush_dev() {
|
flush_dev() {
|
||||||
# Instead of bringing the interface down (#574568)
|
# Instead of bringing the interface down (#574568)
|
||||||
# explicitly clear the ARP cache and flush all addresses & routes.
|
# explicitly clear the ARP cache and flush all addresses & routes.
|
||||||
@ -383,8 +398,8 @@ dhconfig() {
|
|||||||
new_routers=""
|
new_routers=""
|
||||||
prefix="0"
|
prefix="0"
|
||||||
else
|
else
|
||||||
prefix=$(echo ${target} | cut -d "." -f 1)
|
prefix=${target%%.*}
|
||||||
target=$(echo ${target} | cut -d "." -f 2-)
|
target=${target#*.}
|
||||||
IFS="." target_arr=(${target})
|
IFS="." target_arr=(${target})
|
||||||
unset IFS
|
unset IFS
|
||||||
((pads=4-${#target_arr[@]}))
|
((pads=4-${#target_arr[@]}))
|
||||||
@ -402,6 +417,7 @@ dhconfig() {
|
|||||||
fi
|
fi
|
||||||
gateway=${static_routes[$i+1]}
|
gateway=${static_routes[$i+1]}
|
||||||
|
|
||||||
|
if is_router_reachable ${gateway}; then
|
||||||
metric=''
|
metric=''
|
||||||
for t in ${route_targets[@]}; do
|
for t in ${route_targets[@]}; do
|
||||||
if [ ${t} = ${target} ]; then
|
if [ ${t} = ${target} ]; then
|
||||||
@ -417,7 +433,6 @@ dhconfig() {
|
|||||||
metric="metric ${metric}"
|
metric="metric ${metric}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_router_reachable ${gateway}; then
|
|
||||||
ip -4 route replace ${target}/${prefix} proto static via ${gateway} dev ${interface} ${metric}
|
ip -4 route replace ${target}/${prefix} proto static via ${gateway} dev ${interface} ${metric}
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
@ -430,7 +445,7 @@ dhconfig() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# gateways
|
# gateways
|
||||||
if [[ ( "${DEFROUTE}" != "no") &&
|
if [[ ( "${DEFROUTE}" != "no" ) &&
|
||||||
(( -z "${GATEWAYDEV}" ) ||
|
(( -z "${GATEWAYDEV}" ) ||
|
||||||
( "${GATEWAYDEV}" = "${interface}" )) ]]; then
|
( "${GATEWAYDEV}" = "${interface}" )) ]]; then
|
||||||
if [[ ( -z "$GATEWAY" ) ||
|
if [[ ( -z "$GATEWAY" ) ||
|
||||||
@ -487,9 +502,8 @@ dhconfig() {
|
|||||||
hostname ${new_host_name} || echo "See -nc option in dhclient(8) man page."
|
hostname ${new_host_name} || echo "See -nc option in dhclient(8) man page."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" ] &&
|
if [[ ( "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ) &&
|
||||||
[[ "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ]]; then
|
( -n "${new_time_offset}" ) ]]; then
|
||||||
if [ -n "${new_time_offset}" ]; then
|
|
||||||
# DHCP option "time-offset" is requested by default and should be
|
# DHCP option "time-offset" is requested by default and should be
|
||||||
# handled. The geographical zone abbreviation cannot be determined
|
# handled. The geographical zone abbreviation cannot be determined
|
||||||
# from the GMT offset, but the $ZONEINFO/Etc/GMT$offset file can be
|
# from the GMT offset, but the $ZONEINFO/Etc/GMT$offset file can be
|
||||||
@ -510,19 +524,8 @@ dhconfig() {
|
|||||||
fix_context /etc/localtime
|
fix_context /etc/localtime
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# execute any additional client side configuration scripts we have
|
execute_client_side_configuration_scripts "config"
|
||||||
if [ -d ${ETCDIR}/dhclient.d ]; then
|
|
||||||
for f in ${ETCDIR}/dhclient.d/*.sh ; do
|
|
||||||
if [ -x ${f} ]; then
|
|
||||||
subsystem="${f%.sh}"
|
|
||||||
subsystem="${subsystem##*/}"
|
|
||||||
. ${f}
|
|
||||||
"${subsystem}_config"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Section 18.1.8. (Receipt of Reply Messages) of RFC 3315 says:
|
# Section 18.1.8. (Receipt of Reply Messages) of RFC 3315 says:
|
||||||
@ -601,17 +604,7 @@ dh6config() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# execute any additional client side configuration scripts we have
|
execute_client_side_configuration_scripts "config"
|
||||||
if [ -d ${ETCDIR}/dhclient.d ]; then
|
|
||||||
for f in ${ETCDIR}/dhclient.d/*.sh ; do
|
|
||||||
if [ -x ${f} ]; then
|
|
||||||
subsystem="${f%.sh}"
|
|
||||||
subsystem="${subsystem##*/}"
|
|
||||||
. ${f}
|
|
||||||
"${subsystem}_config"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -723,17 +716,7 @@ case "${reason}" in
|
|||||||
ip -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
|
ip -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
|
||||||
dev ${interface}
|
dev ${interface}
|
||||||
|
|
||||||
# execute any additional client side configuration scripts we have
|
execute_client_side_configuration_scripts "restore"
|
||||||
if [ -d ${ETCDIR}/dhclient.d ]; then
|
|
||||||
for f in ${ETCDIR}/dhclient.d/*.sh ; do
|
|
||||||
if [ -x ${f} ]; then
|
|
||||||
subsystem="${f%.sh}"
|
|
||||||
subsystem="${subsystem##*/}"
|
|
||||||
. ${f}
|
|
||||||
"${subsystem}_restore"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
|
if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
|
||||||
. ${ETCDIR}/dhclient-${interface}-down-hooks
|
. ${ETCDIR}/dhclient-${interface}-down-hooks
|
||||||
@ -756,9 +739,8 @@ case "${reason}" in
|
|||||||
rm -f ${SAVEDIR}/resolv.conf.predhclient.${interface}
|
rm -f ${SAVEDIR}/resolv.conf.predhclient.${interface}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" ] &&
|
if [[ ( "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ) &&
|
||||||
[[ "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ]]; then
|
( -e ${SAVEDIR}/localtime.predhclient.${interface} ) ]]; then
|
||||||
if [ -e ${SAVEDIR}/localtime.predhclient.${interface} ]; then
|
|
||||||
rm -f /etc/localtime
|
rm -f /etc/localtime
|
||||||
contents="$(< ${SAVEDIR}/localtime.predhclient.${interface})"
|
contents="$(< ${SAVEDIR}/localtime.predhclient.${interface})"
|
||||||
echo "${contents}" > /etc/localtime
|
echo "${contents}" > /etc/localtime
|
||||||
@ -767,19 +749,8 @@ case "${reason}" in
|
|||||||
fix_context /etc/localtime
|
fix_context /etc/localtime
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# execute any additional client side configuration scripts we have
|
execute_client_side_configuration_scripts "restore"
|
||||||
if [ -d ${ETCDIR}/dhclient.d ]; then
|
|
||||||
for f in ${ETCDIR}/dhclient.d/*.sh ; do
|
|
||||||
if [ -x ${f} ]; then
|
|
||||||
subsystem="${f%.sh}"
|
|
||||||
subsystem="${subsystem##*/}"
|
|
||||||
. ${f}
|
|
||||||
"${subsystem}_restore"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
|
if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
|
||||||
. ${ETCDIR}/dhclient-${interface}-down-hooks
|
. ${ETCDIR}/dhclient-${interface}-down-hooks
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
Summary: Dynamic host configuration protocol software
|
Summary: Dynamic host configuration protocol software
|
||||||
Name: dhcp
|
Name: dhcp
|
||||||
Version: 4.2.1
|
Version: 4.2.1
|
||||||
Release: 0.1.%{prever}%{?dist}
|
Release: 0.2.%{prever}%{?dist}
|
||||||
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
|
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
|
||||||
# dcantrell maintaining the package) made incorrect use of the epoch and
|
# 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.
|
# that's why it is at 12 now. It should have never been used, but it was.
|
||||||
@ -650,6 +650,9 @@ fi
|
|||||||
%attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
|
%attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Jan 28 2011 Jiri Popelka <jpopelka@redhat.com> - 12:4.2.1-0.2.b1
|
||||||
|
- dhclient-script improvements, thanks to Ville Skyttä (#672279)
|
||||||
|
|
||||||
* Thu Jan 27 2011 Jiri Popelka <jpopelka@redhat.com> - 12:4.2.1-0.1.b1
|
* Thu Jan 27 2011 Jiri Popelka <jpopelka@redhat.com> - 12:4.2.1-0.1.b1
|
||||||
- 4.2.1b1: fix for CVE-2011-0413 (#672996)
|
- 4.2.1b1: fix for CVE-2011-0413 (#672996)
|
||||||
- No longer need invalid-dhclient-conf, parse_date and release6-elapsed patches
|
- No longer need invalid-dhclient-conf, parse_date and release6-elapsed patches
|
||||||
|
Loading…
Reference in New Issue
Block a user