jpopelka pushed to dhcp (master). "dhclient-script: fix shellcheck.net suggestions (..more)"

notifications at fedoraproject.org notifications at fedoraproject.org
Wed Mar 25 13:23:35 UTC 2015


>From c191e7ecf1f38405d3d167f98ea51d8ba8ad70e9 Mon Sep 17 00:00:00 2001
From: Jiri Popelka <jpopelka at redhat.com>
Date: Wed, 25 Mar 2015 14:09:29 +0100
Subject: dhclient-script: fix shellcheck.net suggestions

https://github.com/koalaman/shellcheck/wiki/SC2068
https://github.com/koalaman/shellcheck/wiki/SC2086
https://github.com/koalaman/shellcheck/wiki/SC2046

diff --git a/dhclient-script b/dhclient-script
index 17f5757..84bad21 100644
--- a/dhclient-script
+++ b/dhclient-script
@@ -32,7 +32,7 @@
 
 PATH=/bin:/usr/bin:/sbin
 # scripts in dhclient.d/ use $SAVEDIR (#833054)
-SAVEDIR=/var/lib/dhclient
+export SAVEDIR=/var/lib/dhclient
 
 LOGFACILITY="local7"
 LOGLEVEL="notice"
@@ -41,7 +41,7 @@ ETCDIR="/etc/dhcp"
 
 logmessage() {
     msg="${1}"
-    logger -p ${LOGFACILITY}.${LOGLEVEL} -t "NET" "dhclient: ${msg}"
+    logger -p "${LOGFACILITY}.${LOGLEVEL}" -t "NET" "dhclient: ${msg}"
 }
 
 eventually_add_hostnames_domain_to_search() {
@@ -57,13 +57,13 @@ eventually_add_hostnames_domain_to_search() {
     if need_hostname; then
         status=1
         if [ -n "${new_ip_address}" ]; then
-            eval $(/usr/bin/ipcalc --silent --hostname ${new_ip_address} ; echo "status=$?")
+            eval $(/usr/bin/ipcalc --silent --hostname "${new_ip_address}" ; echo "status=$?")
         elif [ -n "${new_ip6_address}" ]; then
-            eval $(/usr/bin/ipcalc --silent --hostname ${new_ip6_address} ; echo "status=$?")
+            eval $(/usr/bin/ipcalc --silent --hostname "${new_ip6_address}" ; echo "status=$?")
         fi
 
         if [ ${status} -eq 0 ]; then
-            domain=$(echo $HOSTNAME | cut -s -d "." -f 2-)
+            domain=$(echo "${HOSTNAME}" | cut -s -d "." -f 2-)
         fi
     else
           domain=$(hostname 2>/dev/null | cut -s -d "." -f 2-)
@@ -101,9 +101,9 @@ make_resolv_conf() {
     if [ -n "${new_domain_name}" ] ||
        [ -n "${new_domain_name_servers}" ] ||
        [ -n "${new_domain_search}" ]; then
-        rscf="$(mktemp ${TMPDIR:-/tmp}/XXXXXX)"
+        rscf="$(mktemp "${TMPDIR:-/tmp}/XXXXXX")"
         [[ -z "${rscf}" ]] && return
-        echo "; generated by /usr/sbin/dhclient-script" > ${rscf}
+        echo "; generated by /usr/sbin/dhclient-script" > "${rscf}"
 
         if [ -n "${SEARCH}" ]; then
             search="${SEARCH}"
@@ -120,28 +120,28 @@ make_resolv_conf() {
         fi
 
         if [ -n "${search}" ]; then
-            echo "search ${search}" >> $rscf
+            echo "search ${search}" >> "${rscf}"
         fi
 
         if [ -n "${RES_OPTIONS}" ]; then
-            echo "options ${RES_OPTIONS}" >> ${rscf}
+            echo "options ${RES_OPTIONS}" >> "${rscf}"
         fi
 
         for nameserver in ${new_domain_name_servers} ; do
-            echo "nameserver ${nameserver}" >> ${rscf}
+            echo "nameserver ${nameserver}" >> "${rscf}"
         done
 
-        change_resolv_conf ${rscf}
-        rm -f ${rscf}
+        change_resolv_conf "${rscf}"
+        rm -f "${rscf}"
 
         if [ -n "${search}" ]; then
             eventually_add_hostnames_domain_to_search "${search}"
         fi
     elif [ -n "${new_dhcp6_name_servers}" ] ||
          [ -n "${new_dhcp6_domain_search}" ]; then
-        rscf="$(mktemp ${TMPDIR:-/tmp}/XXXXXX)"
+        rscf="$(mktemp "${TMPDIR:-/tmp}/XXXXXX")"
         [[ -z "${rscf}" ]] && return
-        echo "; generated by /usr/sbin/dhclient-script" > ${rscf}
+        echo "; generated by /usr/sbin/dhclient-script" > "${rscf}"
 
         if [ -n "${SEARCH}" ]; then
             search="${SEARCH}"
@@ -152,11 +152,11 @@ make_resolv_conf() {
         fi
 
         if [ -n "${search}" ]; then
-            echo "search ${search}" >> $rscf
+            echo "search ${search}" >> "${rscf}"
         fi
 
         if [ -n "${RES_OPTIONS}" ]; then
-            echo "options ${RES_OPTIONS}" >> ${rscf}
+            echo "options ${RES_OPTIONS}" >> "${rscf}"
         fi
 
         shopt -s nocasematch 
@@ -169,12 +169,12 @@ make_resolv_conf() {
             else
                 zone_id=
             fi
-            echo "nameserver ${nameserver}$zone_id" >> ${rscf}
+            echo "nameserver ${nameserver}$zone_id" >> "${rscf}"
         done
         shopt -u nocasematch 
 
-        change_resolv_conf ${rscf}
-        rm -f ${rscf}
+        change_resolv_conf "${rscf}"
+        rm -f "${rscf}"
 
         if [ -n "${search}" ]; then
             eventually_add_hostnames_domain_to_search "${search}"
@@ -189,7 +189,7 @@ exit_with_hooks() {
         . ${ETCDIR}/dhclient-exit-hooks
     fi
 
-    exit ${exit_status}
+    exit "${exit_status}"
 }
 
 quad2num() {
@@ -204,15 +204,15 @@ quad2num() {
 }
 
 ip2num() {
-    IFS="." quad2num ${1}
+    IFS="." quad2num "${1}"
 }
 
 num2ip() {
     let n="${1}"
-    let o1="(n >> 24) & 0xff"
-    let o2="(n >> 16) & 0xff"
-    let o3="(n >> 8) & 0xff"
-    let o4="n & 0xff"
+    let o1="(${n} >> 24) & 0xff"
+    let o2="(${n} >> 16) & 0xff"
+    let o3="(${n} >> 8) & 0xff"
+    let o4="${n} & 0xff"
     echo "${o1}.${o2}.${o3}.${o4}"
 }
 
@@ -223,9 +223,9 @@ get_network_address() {
 
     if [ -n "${ip}" -a -n "${nm}" ]; then
         if [[ "${nm}" = *.* ]]; then
-            ipcalc -s -n ${ip} ${nm} | cut -d '=' -f 2
+            ipcalc -s -n "${ip}" "${nm}" | cut -d '=' -f 2
         else
-            ipcalc -s -n ${ip}/${nm} | cut -d '=' -f 2
+            ipcalc -s -n "${ip}/${nm}" | cut -d '=' -f 2
         fi
     fi
 }
@@ -236,12 +236,12 @@ get_prefix() {
     nm="${2}"
 
     if [ -n "${ip}" -a -n "${nm}" ]; then
-        ipcalc -s -p ${ip} ${nm} | cut -d '=' -f 2
+        ipcalc -s -p "${ip}" "${nm}" | cut -d '=' -f 2
     fi
 }
 
 class_bits() {
-    let ip=$(IFS='.' ip2num $1)
+    let ip=$(IFS='.' ip2num "${1}")
     let bits=32
     let mask='255'
     for ((i=0; i <= 3; i++, 'mask<<=8')); do
@@ -258,14 +258,14 @@ class_bits() {
 is_router_reachable() {
     # handle DHCP servers that give us a router not on our subnet
     router="${1}"
-    routersubnet="$(get_network_address ${router} ${new_subnet_mask})"
-    mysubnet="$(get_network_address ${new_ip_address} ${new_subnet_mask})"
+    routersubnet="$(get_network_address "${router}" "${new_subnet_mask}")"
+    mysubnet="$(get_network_address "${new_ip_address}" "${new_subnet_mask}")"
 
     if [ ! "${routersubnet}" = "${mysubnet}" ]; then
         # TODO: This function should not have side effects such as adding or
         # removing routes. Can this be done with "ip route get" or similar
         # instead? Are there cases that rely on this route being created here?
-        ip -4 route replace ${router}/32 dev ${interface}
+        ip -4 route replace "${router}/32" dev "${interface}"
         if [ "$?" -ne 0 ]; then
             logmessage "failed to create host route for ${router}"
             return 1
@@ -278,12 +278,12 @@ is_router_reachable() {
 add_default_gateway() {
     router="${1}"
 
-    if is_router_reachable ${router} ; then
+    if is_router_reachable "${router}" ; then
         metric=""
-        if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then
+        if [ $# -gt 1 ] && [ "${2}" -gt 0 ]; then
             metric="metric ${2}"
         fi
-        ip -4 route replace default via ${router} dev ${interface} ${metric}
+        ip -4 route replace default via "${router}" dev "${interface}" "${metric}"
         if [ $? -ne 0 ]; then
             logmessage "failed to create default route: ${router} dev ${interface} ${metric}"
             return 1
@@ -299,10 +299,10 @@ 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
+            if [ -x "${f}" ]; then
                 subsystem="${f%.sh}"
                 subsystem="${subsystem##*/}"
-                . ${f}
+                . "${f}"
                 "${subsystem}_${1}"
             fi
         done
@@ -312,17 +312,17 @@ execute_client_side_configuration_scripts() {
 flush_dev() {
 # Instead of bringing the interface down (#574568)
 # explicitly clear ARP cache and flush all addresses & routes.
-    ip -4 addr flush dev ${1} >/dev/null 2>&1
-    ip -4 route flush dev ${1} >/dev/null 2>&1
-    ip -4 neigh flush dev ${1} >/dev/null 2>&1
+    ip -4 addr flush dev "${1}" >/dev/null 2>&1
+    ip -4 route flush dev "${1}" >/dev/null 2>&1
+    ip -4 neigh flush dev "${1}" >/dev/null 2>&1
 }
 
 remove_old_addr() {
     if [ -n "${old_ip_address}" ]; then
         if [ -n "${old_prefix}" ]; then
-            ip -4 addr del ${old_ip_address}/${old_prefix} dev ${interface} >/dev/null 2>&1
+            ip -4 addr del "${old_ip_address}/${old_prefix}" dev "${interface}" >/dev/null 2>&1
         else
-            ip -4 addr del ${old_ip_address} dev ${interface} >/dev/null 2>&1
+            ip -4 addr del "${old_ip_address}" dev "${interface}" >/dev/null 2>&1
         fi
     fi
 }
@@ -331,21 +331,21 @@ dhconfig() {
     if [ -n "${old_ip_address}" ] && [ -n "${alias_ip_address}" ] &&
        [ ! "${alias_ip_address}" = "${old_ip_address}" ]; then
         # possible new alias, remove old alias first
-        ip -4 addr del ${old_ip_address} dev ${interface} label ${interface}:0
+        ip -4 addr del "${old_ip_address}" dev "${interface}" label "${interface}:0"
     fi
 
     if [ -n "${old_ip_address}" ] &&
        [ ! "${old_ip_address}" = "${new_ip_address}" ]; then
         # IP address changed. Delete all routes, and clear the ARP cache.
-        flush_dev ${interface}
+        flush_dev "${interface}"
     fi
 
     # make sure the interface is up
-    ip link set dev ${interface} up
+    ip link set dev "${interface}" up
 
     # replace = add if it doesn't exist or override (update lifetimes) if it's there
-    ip -4 addr replace ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface} \
-       valid_lft ${new_dhcp_lease_time} preferred_lft ${new_dhcp_lease_time} >/dev/null 2>&1
+    ip -4 addr replace "${new_ip_address}/${new_prefix}" broadcast "${new_broadcast_address}" dev "${interface}" \
+       valid_lft "${new_dhcp_lease_time}" preferred_lft "${new_dhcp_lease_time}" >/dev/null 2>&1
 
     if [ "${reason}" = "BOUND" ] || [ "${reason}" = "REBOOT" ] ||
        [ ! "${old_ip_address}" = "${new_ip_address}" ] ||
@@ -360,8 +360,8 @@ dhconfig() {
         # problems with UDP traffic, among other things.  As such,
         # disallow MTUs from 576 and below by default, so that broken
         # MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
-        if [ -n "${new_interface_mtu}" ] && [ ${new_interface_mtu} -gt 576 ]; then
-            ip link set dev ${interface} mtu ${new_interface_mtu}
+        if [ -n "${new_interface_mtu}" ] && [ "${new_interface_mtu}" -gt 576 ]; then
+            ip link set dev "${interface}" mtu "${new_interface_mtu}"
         fi
 
         # static routes
@@ -377,7 +377,7 @@ dhconfig() {
             for((i=0; i<${#static_routes[@]}; i+=2)); do
                 target=${static_routes[$i]}
                 if [ -n "${new_classless_static_routes}" ]; then
-                    if [ ${target} = "0" ]; then
+                    if [ "${target}" = "0" ]; then
                         # If the DHCP server returns both a Classless Static Routes option and
                         # a Router option, the DHCP client MUST ignore the Router option. (RFC3442)
                         new_routers=""
@@ -395,10 +395,10 @@ dhconfig() {
                         # Client MUST zero any bits in the subnet number where the corresponding bit in the mask is zero.
                         # In other words, the subnet number installed in the routing table is the logical AND of
                         # the subnet number and subnet mask given in the Classless Static Routes option. (RFC3442)
-                        target="$(get_network_address ${target} ${prefix})"
+                        target="$(get_network_address "${target}" "${prefix}")"
                     fi
                 else
-                    prefix=$(class_bits ${target})
+                    prefix=$(class_bits "${target}")
                 fi
                 gateway=${static_routes[$i+1]}
 
@@ -408,14 +408,14 @@ dhconfig() {
                     valid_gateway=0
                     scope='scope link'
                 else
-                    is_router_reachable ${gateway}
+                    is_router_reachable "${gateway}"
                     valid_gateway=$?
                     scope=''
                 fi
-                if [ ${valid_gateway} -eq 0 ]; then
+                if [ "${valid_gateway}" -eq 0 ]; then
                     metric=''
-                    for t in ${route_targets[@]}; do
-                        if [ ${t} = ${target} ]; then
+                    for t in "${route_targets[@]}"; do
+                        if [ "${t}" = "${target}" ]; then
                             if [ -z "${metric}" ]; then
                                 metric=1
                             else
@@ -428,7 +428,7 @@ dhconfig() {
                         metric="metric ${metric}"
                     fi
 
-                    ip -4 route replace ${target}/${prefix} proto static via ${gateway} dev ${interface} ${metric} ${scope}
+                    ip -4 route replace "${target}/${prefix}" proto static via "${gateway}" dev "${interface}" "${metric}" "${scope}"
 
                     if [ $? -ne 0 ]; then
                         logmessage "failed to create static route: ${target}/${prefix} via ${gateway} dev ${interface} ${metric}"
@@ -442,8 +442,8 @@ dhconfig() {
         # gateways
         if [[ ( "${DEFROUTE}" != "no" ) &&
               (( -z "${GATEWAYDEV}" ) || ( "${GATEWAYDEV}" = "${interface}" )) ]]; then
-            if [[ ( -z "$GATEWAY" ) ||
-                  (( -n "$DHCLIENT_IGNORE_GATEWAY" ) && ( "$DHCLIENT_IGNORE_GATEWAY" = [Yy]* )) ]]; then
+            if [[ ( -z "${GATEWAY}" ) ||
+                  (( -n "${DHCLIENT_IGNORE_GATEWAY}" ) && ( "${DHCLIENT_IGNORE_GATEWAY}" = [Yy]* )) ]]; then
                 metric="${METRIC:-}"
                 let i="${METRIC:-0}"
                 default_routers=()
@@ -451,7 +451,7 @@ dhconfig() {
                 for router in ${new_routers} ; do
                     added_router=-
 
-                    for r in ${default_routers[@]} ; do
+                    for r in "${default_routers[@]}" ; do
                         if [ "${r}" = "${router}" ]; then
                             added_router=1
                         fi
@@ -459,23 +459,23 @@ dhconfig() {
 
                     if [ -z "${router}" ] ||
                        [ "${added_router}" = "1" ] ||
-                       [ $(IFS=. ip2num ${router}) -le 0 ] ||
+                       [ "$(IFS=. ip2num ${router})" -le 0 ] ||
                        [[ ( "${router}" = "${new_broadcast_address}" ) &&
                           ( "${new_subnet_mask}" != "255.255.255.255" ) ]]; then
                         continue
                     fi
 
                     default_routers=(${default_routers[@]} ${router})
-                    add_default_gateway ${router} ${metric}
+                    add_default_gateway "${router}" "${metric}"
                     let i=i+1
                     metric=${i}
                 done
             elif [ -n "${GATEWAY}" ]; then
-                routersubnet=$(get_network_address ${GATEWAY} ${new_subnet_mask})
-                mysubnet=$(get_network_address ${new_ip_address} ${new_subnet_mask})
+                routersubnet=$(get_network_address "${GATEWAY}" "${new_subnet_mask}")
+                mysubnet=$(get_network_address "${new_ip_address}" "${new_subnet_mask}")
 
                 if [ "${routersubnet}" = "${mysubnet}" ]; then
-                    ip -4 route replace default via ${GATEWAY} dev ${interface}
+                    ip -4 route replace default via "${GATEWAY}" dev "${interface}"
                 fi
             fi
         fi
@@ -484,9 +484,9 @@ dhconfig() {
     if [ ! "${new_ip_address}" = "${alias_ip_address}" ] &&
        [ -n "${alias_ip_address}" ]; then
         # Reset the alias address (fix: this should really only do this on changes)
-        ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
-        ip -4 addr replace ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
-        ip -4 route replace ${alias_ip_address}/32 dev ${interface}
+        ip -4 addr flush dev "${interface}" label "${interface}:0" >/dev/null 2>&1
+        ip -4 addr replace "${alias_ip_address}/${alias_prefix}" broadcast "${alias_broadcast_address}" dev "${interface}" label "${interface}:0"
+        ip -4 route replace "${alias_ip_address}/32" dev "${interface}"
     fi
     
     # After dhclient brings an interface UP with a new IP address, subnet mask, 
@@ -499,8 +499,8 @@ dhconfig() {
        [ ! "${old_routers}" = "${new_routers}" ] ||
        [ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
         
-        if [ -x ${ETCDIR}/dhclient-${interface}-up-hooks ]; then
-            . ${ETCDIR}/dhclient-${interface}-up-hooks
+        if [ -x "${ETCDIR}/dhclient-${interface}-up-hooks" ]; then
+            . "${ETCDIR}/dhclient-${interface}-up-hooks"
         elif [ -x ${ETCDIR}/dhclient-up-hooks ]; then
             . ${ETCDIR}/dhclient-up-hooks
         fi
@@ -509,7 +509,7 @@ dhconfig() {
     make_resolv_conf
 
     if [ -n "${new_host_name}" ] && need_hostname; then
-        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
 
     if [[ ( "${DHCP_TIME_OFFSET_SETS_TIMEZONE}" = [yY1]* ) &&
@@ -527,8 +527,8 @@ dhconfig() {
         fi
 
         tzfile=/usr/share/zoneinfo/Etc/GMT$(printf '%+d' ${hoursWest})
-        if [ -e ${tzfile} ]; then
-            cp -fp ${tzfile} /etc/localtime
+        if [ -e "${tzfile}" ]; then
+            cp -fp "${tzfile}" /etc/localtime
             touch /etc/localtime
         fi
     fi
@@ -541,17 +541,17 @@ dhconfig() {
 # the addresses in any IAs it receives in the Reply message before
 # using that address for traffic.
 add_ipv6_addr_with_DAD() {
-            ip -6 addr replace ${new_ip6_address}/${new_ip6_prefixlen} \
-                dev ${interface} scope global valid_lft ${new_max_life} \
-                                          preferred_lft ${new_preferred_life}
+            ip -6 addr replace "${new_ip6_address}/${new_ip6_prefixlen}" \
+                dev "${interface}" scope global valid_lft "${new_max_life}" \
+                                          preferred_lft "${new_preferred_life}"
 
             # repeatedly test whether newly added address passed
             # duplicate address detection (DAD)
             for i in $(seq 5); do
                 sleep 1 # give the DAD some time
 
-                addr=$(ip -6 addr show dev ${interface} \
-                       | grep ${new_ip6_address}/${new_ip6_prefixlen})
+                addr=$(ip -6 addr show dev "${interface}" \
+                       | grep "${new_ip6_address}/${new_ip6_prefixlen}")
 
                 # tentative flag == DAD is still not complete
                 tentative=$(echo "${addr}" | grep tentative)
@@ -560,7 +560,7 @@ add_ipv6_addr_with_DAD() {
 
                 if [ -n "${dadfailed}" ] ; then
                     # address was added with valid_lft/preferred_lft 'forever', remove it
-                    ip -6 addr del ${new_ip6_address}/${new_ip6_prefixlen} dev ${interface}
+                    ip -6 addr del "${new_ip6_address}/${new_ip6_prefixlen}" dev "${interface}"
                     exit_with_hooks 3
                 fi
                 if [ -z "${tentative}" ] ; then
@@ -579,7 +579,7 @@ add_ipv6_addr_with_DAD() {
 dh6config() {
     if [ -n "${old_ip6_prefix}" ] ||
        [ -n "${new_ip6_prefix}" ]; then
-        echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
+        echo "Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}"
         exit_with_hooks 0
     fi
 
@@ -599,7 +599,7 @@ dh6config() {
             if [[ -n "${new_ip6_address}" ]] &&
                [[ -n "${new_ip6_prefixlen}" ]]; then
                if [[  ! "${new_ip6_address}" = "${old_ip6_address}" ]]; then
-                   [[ -n "${old_ip6_address}" ]] && ip -6 addr del ${old_ip6_address} dev ${interface}
+                   [[ -n "${old_ip6_address}" ]] && ip -6 addr del "${old_ip6_address}" dev "${interface}"
                fi
                # call it even if new_ip6_address = old_ip6_address to update lifetimes
                add_ipv6_addr_with_DAD
@@ -616,8 +616,8 @@ dh6config() {
                 exit_with_hooks 2
             fi
 
-            ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
-                dev ${interface} scope global preferred_lft 0
+            ip -6 addr change "${new_ip6_address}/${new_ip6_prefixlen}" \
+                dev "${interface}" scope global preferred_lft 0
             ;;
     esac
 
@@ -663,12 +663,12 @@ fi
 
 cd /etc/sysconfig/network-scripts
 CONFIG="${interface}"
-need_config ${CONFIG}
+need_config "${CONFIG}"
 source_config >/dev/null 2>&1
 
-new_prefix="$(get_prefix ${new_ip_address} ${new_subnet_mask})"
-old_prefix="$(get_prefix ${old_ip_address} ${old_subnet_mask})"
-alias_prefix="$(get_prefix ${alias_ip_address} ${alias_subnet_mask})"
+new_prefix="$(get_prefix "${new_ip_address}" "${new_subnet_mask}")"
+old_prefix="$(get_prefix "${old_ip_address}" "${old_subnet_mask}")"
+alias_prefix="$(get_prefix "${alias_ip_address}" "${alias_subnet_mask}")"
 
 case "${reason}" in
     MEDIUM|ARPCHECK|ARPSEND)
@@ -679,16 +679,16 @@ case "${reason}" in
     PREINIT)
         if [ -n "${alias_ip_address}" ]; then
             # Flush alias, its routes will disappear too.
-            ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
+            ip -4 addr flush dev "${interface}" label "${interface}:0" >/dev/null 2>&1
         fi
 
         # upstream dhclient-script removes (ifconfig $interface 0 up) old adresses in PREINIT,
         # but we sometimes (#125298) need (for iSCSI/nfs root to have a dhcp interface) to keep the existing ip
         # flush_dev ${interface}
-        ip link set dev ${interface} up
-        if [ -n "${DHCLIENT_DELAY}" ] && [ ${DHCLIENT_DELAY} -gt 0 ]; then
+        ip link set dev "${interface}" up
+        if [ -n "${DHCLIENT_DELAY}" ] && [ "${DHCLIENT_DELAY}" -gt 0 ]; then
             # We need to give the kernel some time to get the interface up.
-            sleep ${DHCLIENT_DELAY}
+            sleep "${DHCLIENT_DELAY}"
         fi
 
         exit_with_hooks 0
@@ -696,14 +696,14 @@ case "${reason}" in
 
     PREINIT6)
         # ensure interface is up
-        ip link set dev ${interface} up
+        ip link set dev "${interface}" up
 
         # remove any stale addresses from aborted clients
-        ip -6 addr flush dev ${interface} scope global permanent
+        ip -6 addr flush dev "${interface}" scope global permanent
 
         # we need a link-local address to be ready (not tentative)
         for i in $(seq 50); do
-            linklocal=$(ip -6 addr show dev ${interface} scope link)
+            linklocal=$(ip -6 addr show dev "${interface}" scope link)
             # tentative flag means DAD is still not complete
             tentative=$(echo "${linklocal}" | grep tentative)
             [[ -n "${linklocal}" && -z "${tentative}" ]] && exit_with_hooks 0
@@ -717,11 +717,11 @@ case "${reason}" in
         if [ -z "${interface}" ] || [ -z "${new_ip_address}" ]; then
             exit_with_hooks 2
         fi
-        if arping -D -q -c2 -I ${interface} ${new_ip_address}; then
+        if arping -D -q -c2 -I "${interface}" "${new_ip_address}"; then
             dhconfig
             exit_with_hooks 0
         else  # DAD failed, i.e. address is already in use
-            ARP_REPLY=$(arping -D -c2 -I ${interface} ${new_ip_address} | grep reply | awk '{print toupper($5)}' | cut -d "[" -f2 | cut -d "]" -f1)
+            ARP_REPLY=$(arping -D -c2 -I "${interface}" "${new_ip_address}" | grep reply | awk '{print toupper($5)}' | cut -d "[" -f2 | cut -d "]" -f1)
             OUR_MACS=$(ip link show | grep link | awk '{print toupper($2)}' | uniq)
             if [[ "${OUR_MACS}" = *"${ARP_REPLY}"* ]]; then
                 # the reply can come from our system, that's OK (#1116004#c33)
@@ -743,13 +743,13 @@ case "${reason}" in
             exit_with_hooks 2
         fi
 
-        ip -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
-            dev ${interface}
+        ip -6 addr del "${old_ip6_address}/${old_ip6_prefixlen}" \
+            dev "${interface}"
 
         execute_client_side_configuration_scripts "restore"
 
-        if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
-            . ${ETCDIR}/dhclient-${interface}-down-hooks
+        if [ -x "${ETCDIR}/dhclient-${interface}-down-hooks" ]; then
+            . "${ETCDIR}/dhclient-${interface}-down-hooks"
         elif [ -x ${ETCDIR}/dhclient-down-hooks ]; then
             . ${ETCDIR}/dhclient-down-hooks
         fi
@@ -760,15 +760,15 @@ case "${reason}" in
     EXPIRE|FAIL|RELEASE|STOP)
         execute_client_side_configuration_scripts "restore"
 
-        if [ -x ${ETCDIR}/dhclient-${interface}-down-hooks ]; then
-            . ${ETCDIR}/dhclient-${interface}-down-hooks
+        if [ -x "${ETCDIR}/dhclient-${interface}-down-hooks" ]; then
+            . "${ETCDIR}/dhclient-${interface}-down-hooks"
         elif [ -x ${ETCDIR}/dhclient-down-hooks ]; then
             . ${ETCDIR}/dhclient-down-hooks
         fi
 
         if [ -n "${alias_ip_address}" ]; then
             # Flush alias
-            ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
+            ip -4 addr flush dev "${interface}" label "${interface}:0" >/dev/null 2>&1
         fi
 
         # upstream script sets interface down here,
@@ -777,8 +777,8 @@ case "${reason}" in
         remove_old_addr
 
         if [ -n "${alias_ip_address}" ]; then
-            ip -4 addr replace ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
-            ip -4 route replace ${alias_ip_address}/32 dev ${interface}
+            ip -4 addr replace "${alias_ip_address}/${alias_prefix}" broadcast "${alias_broadcast_address}" dev "${interface}" label "${interface}:0"
+            ip -4 route replace "${alias_ip_address}/32" dev "${interface}"
         fi
 
         exit_with_hooks 0
@@ -787,15 +787,15 @@ case "${reason}" in
     TIMEOUT)
         if [ -n "${new_routers}" ]; then
             if [ -n "${alias_ip_address}" ]; then
-                ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
+                ip -4 addr flush dev "${interface}" label "${interface}:0" >/dev/null 2>&1
             fi
 
-            ip -4 addr replace ${new_ip_address}/${new_prefix} \
-                broadcast ${new_broadcast_address} dev ${interface} \
-                valid_lft ${new_dhcp_lease_time} preferred_lft ${new_dhcp_lease_time}
+            ip -4 addr replace "${new_ip_address}/${new_prefix}" \
+                broadcast "${new_broadcast_address}" dev "${interface}" \
+                valid_lft "${new_dhcp_lease_time}" preferred_lft "${new_dhcp_lease_time}"
             set ${new_routers}
 
-            if ping -q -c 1 -w 10 -I ${interface} ${1}; then
+            if ping -q -c 1 -w 10 -I "${interface}" "${1}"; then
                 dhconfig
                 exit_with_hooks 0
             fi
diff --git a/dhcp.spec b/dhcp.spec
index 86f3cea..9383442 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -18,7 +18,7 @@
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.3.2
-Release:  2%{?dist}
+Release:  3%{?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.
@@ -675,6 +675,9 @@ done
 %doc doc/html/
 
 %changelog
+* Wed Mar 25 2015 Jiri Popelka <jpopelka at redhat.com> - 12:4.3.2-3
+- dhclient-script: fix shellcheck.net suggestions
+
 * Fri Mar 13 2015 Tomas Hozza <thozza at redhat.com> - 12:4.3.2-2
 - rebuild against bind99 9.9.7 package
 
-- 
cgit v0.10.2


	http://pkgs.fedoraproject.org/cgit/dhcp.git/commit/?h=master&id=c191e7ecf1f38405d3d167f98ea51d8ba8ad70e9

--
You received this message due to your preference settings at
https://apps.fedoraproject.org/notifications//fmnscmcommits.id.fedoraproject.org/email/29390


More information about the scm-commits mailing list