]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(network-legacy): shellcheck for modules.d/35network-legacy
authorHarald Hoyer <harald@redhat.com>
Fri, 26 Mar 2021 09:29:14 +0000 (10:29 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Tue, 30 Mar 2021 08:14:34 +0000 (10:14 +0200)
13 files changed:
modules.d/35network-legacy/.shchkdir [new file with mode: 0644]
modules.d/35network-legacy/dhclient-script.sh
modules.d/35network-legacy/dhcp-multi.sh
modules.d/35network-legacy/ifup.sh
modules.d/35network-legacy/kill-dhclient.sh
modules.d/35network-legacy/module-setup.sh
modules.d/35network-legacy/net-genrules.sh
modules.d/35network-legacy/parse-bond.sh
modules.d/35network-legacy/parse-bridge.sh
modules.d/35network-legacy/parse-ifname.sh
modules.d/35network-legacy/parse-ip-opts.sh
modules.d/35network-legacy/parse-team.sh
modules.d/35network-legacy/parse-vlan.sh

diff --git a/modules.d/35network-legacy/.shchkdir b/modules.d/35network-legacy/.shchkdir
new file mode 100644 (file)
index 0000000..e69de29
index 401f3b9182f813ce78eab0876d916e5b731337fd..82fc7e2c2c8a81405dbf5dbfd9fa7d08c5c75929 100755 (executable)
@@ -15,7 +15,8 @@ setup_interface() {
     bcast=$new_broadcast_address
     gw=${new_routers%%,*}
     domain=$new_domain_name
-    search=$(printf -- "$new_domain_search")
+    # get rid of control chars
+    search=$(printf -- "%s" "$new_domain_search" | tr -d '[:cntrl:]')
     namesrv=$new_domain_name_servers
     hostname=$new_host_name
     [ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time
@@ -23,7 +24,8 @@ setup_interface() {
     preferred_lft=$lease_time
     [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
 
-    [ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+    # shellcheck disable=SC1090
+    [ -f /tmp/net."$netif".override ] && . /tmp/net."$netif".override
 
     # Taken from debian dhclient-script:
     # The 576 MTU is only used for X.25 and dialup connections
@@ -31,51 +33,52 @@ setup_interface() {
     # 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 "$mtu" ] && [ $mtu -gt 576 ]; then
-        if ! ip link set $netif mtu $mtu; then
-            ip link set $netif down
-            ip link set $netif mtu $mtu
-            linkup $netif
+    if [ -n "$mtu" ] && [ "$mtu" -gt 576 ]; then
+        if ! ip link set "$netif" mtu "$mtu"; then
+            ip link set "$netif" down
+            ip link set "$netif" mtu "$mtu"
+            linkup "$netif"
         fi
     fi
 
-    ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif \
+    ip addr add "$ip"${mask:+/$mask} ${bcast:+broadcast $bcast} dev "$netif" \
         ${lease_time:+valid_lft $lease_time} \
         ${preferred_lft:+preferred_lft ${preferred_lft}}
 
     if [ -n "$gw" ]; then
         if [ "$mask" = "255.255.255.255" ]; then
             # point-to-point connection => set explicit route to gateway
-            echo ip route add $gw dev $netif > /tmp/net.$netif.gw
+            echo ip route add "$gw" dev "$netif" > /tmp/net."$netif".gw
         fi
 
         echo "$gw" | {
             IFS=' ' read -r main_gw other_gw
-            echo ip route replace default via $main_gw dev $netif >> /tmp/net.$netif.gw
+            echo ip route replace default via "$main_gw" dev "$netif" >> /tmp/net."$netif".gw
             if [ -n "$other_gw" ]; then
                 for g in $other_gw; do
-                    echo ip route add default via $g dev $netif >> /tmp/net.$netif.gw
+                    echo ip route add default via "$g" dev "$netif" >> /tmp/net."$netif".gw
                 done
             fi
         }
     fi
 
     if getargbool 1 rd.peerdns; then
-        [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
+        [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net."$netif".resolv.conf
         if [ -n "$namesrv" ]; then
             for s in $namesrv; do
-                echo nameserver $s
+                echo nameserver "$s"
             done
-        fi >> /tmp/net.$netif.resolv.conf
+        fi >> /tmp/net."$netif".resolv.conf
     fi
     # Note: hostname can be fqdn OR short hostname, so chop off any
     # trailing domain name and explicity add any domain if set.
-    [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+    [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
 }
 
 setup_interface6() {
     domain=$new_domain_name
-    search=$(printf -- "$new_dhcp6_domain_search")
+    # get rid of control chars
+    search=$(printf -- "%s" "$new_dhcp6_domain_search" | tr -d '[:cntrl:]')
     namesrv=$new_dhcp6_name_servers
     hostname=$new_host_name
     [ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time
@@ -83,25 +86,26 @@ setup_interface6() {
     preferred_lft=$lease_time
     [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
 
-    [ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+    # shellcheck disable=SC1090
+    [ -f /tmp/net."$netif".override ] && . /tmp/net."$netif".override
 
-    ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
-        dev ${netif} scope global \
+    ip -6 addr add "${new_ip6_address}"/"${new_ip6_prefixlen}" \
+        dev "${netif}" scope global \
         ${lease_time:+valid_lft $lease_time} \
         ${preferred_lft:+preferred_lft ${preferred_lft}}
 
     if getargbool 1 rd.peerdns; then
-        [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
+        [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net."$netif".resolv.conf
         if [ -n "$namesrv" ]; then
             for s in $namesrv; do
-                echo nameserver $s
+                echo nameserver "$s"
             done
-        fi >> /tmp/net.$netif.resolv.conf
+        fi >> /tmp/net."$netif".resolv.conf
     fi
 
     # Note: hostname can be fqdn OR short hostname, so chop off any
     # trailing domain name and explicity add any domain if set.
-    [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+    [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net."$netif".hostname
 }
 
 parse_option_121() {
@@ -110,29 +114,29 @@ parse_option_121() {
         shift
 
         # Is the destination a multicast group?
-        if [ $1 -ge 224 -a $1 -lt 240 ]; then
+        if [ "$1" -ge 224 -a "$1" -lt 240 ]; then
             multicast=1
         else
             multicast=0
         fi
 
         # Parse the arguments into a CIDR net/mask string
-        if [ $mask -gt 24 ]; then
+        if [ "$mask" -gt 24 ]; then
             destination="$1.$2.$3.$4/$mask"
             shift
             shift
             shift
             shift
-        elif [ $mask -gt 16 ]; then
+        elif [ "$mask" -gt 16 ]; then
             destination="$1.$2.$3.0/$mask"
             shift
             shift
             shift
-        elif [ $mask -gt 8 ]; then
+        elif [ "$mask" -gt 8 ]; then
             destination="$1.$2.0.0/$mask"
             shift
             shift
-        elif [ $mask -gt 0 ]; then
+        elif [ "$mask" -gt 0 ]; then
             destination="$1.0.0.0/$mask"
             shift
         else
@@ -162,29 +166,29 @@ parse_option_121() {
 case $reason in
     PREINIT)
         echo "dhcp: PREINIT $netif up"
-        linkup $netif
+        linkup "$netif"
         ;;
 
     PREINIT6)
         echo "dhcp: PREINIT6 $netif up"
-        linkup $netif
-        wait_for_ipv6_dad_link $netif
+        linkup "$netif"
+        wait_for_ipv6_dad_link "$netif"
         ;;
 
     BOUND)
         echo "dhcp: BOUND setting up $netif"
         unset layer2
-        if [ -f /sys/class/net/$netif/device/layer2 ]; then
-            read layer2 < /sys/class/net/$netif/device/layer2
+        if [ -f /sys/class/net/"$netif"/device/layer2 ]; then
+            read -r layer2 < /sys/class/net/"$netif"/device/layer2
         fi
         if [ "$layer2" != "0" ]; then
             if command -v arping2 > /dev/null; then
-                if arping2 -q -C 1 -c 2 -I $netif -0 $new_ip_address; then
+                if arping2 -q -C 1 -c 2 -I "$netif" -0 "$new_ip_address"; then
                     warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
                     exit 1
                 fi
             else
-                if ! arping -f -q -D -c 2 -I $netif $new_ip_address; then
+                if ! arping -f -q -D -c 2 -I "$netif" "$new_ip_address"; then
                     warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
                     exit 1
                 fi
@@ -192,10 +196,10 @@ case $reason in
         fi
         unset layer2
         setup_interface
-        set | while read line || [ -n "$line" ]; do
+        set | while read -r line || [ -n "$line" ]; do
             [ "${line#new_}" = "$line" ] && continue
             echo "$line"
-        done > /tmp/dhclient.$netif.dhcpopts
+        done > /tmp/dhclient."$netif".dhcpopts
 
         {
             echo '. /lib/net-lib.sh'
@@ -203,18 +207,18 @@ case $reason in
             if [ -n "$new_classless_static_routes" ]; then
                 OLDIFS="$IFS"
                 IFS=".$IFS"
-                parse_option_121 $new_classless_static_routes
+                parse_option_121 "$new_classless_static_routes"
                 IFS="$OLDIFS"
             fi
             echo "source_hook initqueue/online $netif"
-            [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
+            [ -e /tmp/net."$netif".manualup ] || echo "/sbin/netroot $netif"
             echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
-        } > $hookdir/initqueue/setup_net_$netif.sh
+        } > "$hookdir"/initqueue/setup_net_"$netif".sh
 
-        echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
-        > /tmp/net.$netif.up
-        if [ -e /sys/class/net/${netif}/address ]; then
-            > /tmp/net.$(cat /sys/class/net/${netif}/address).up
+        echo "[ -f /tmp/net.$netif.did-setup ]" > "$hookdir"/initqueue/finished/dhclient-"$netif".sh
+        : > /tmp/net."$netif".up
+        if [ -e /sys/class/net/"${netif}"/address ]; then
+            : > "/tmp/net.$(cat /sys/class/net/"${netif}"/address).up"
         fi
 
         ;;
@@ -225,7 +229,7 @@ case $reason in
         [ -n "$new_max_life" ] && lease_time=$new_max_life
         preferred_lft=$lease_time
         [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
-        ip -4 addr change ${new_ip_address}/${new_subnet_mask} broadcast ${new_broadcast_address} dev ${interface} \
+        ip -4 addr change "${new_ip_address}"/"${new_subnet_mask}" broadcast "${new_broadcast_address}" dev "${interface}" \
             ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
             > /dev/null 2>&1
         ;;
@@ -234,23 +238,23 @@ case $reason in
         echo "dhcp: BOUND6 setting up $netif"
         setup_interface6
 
-        set | while read line || [ -n "$line" ]; do
+        set | while read -r line || [ -n "$line" ]; do
             [ "${line#new_}" = "$line" ] && continue
             echo "$line"
-        done > /tmp/dhclient.$netif.dhcpopts
+        done > /tmp/dhclient."$netif".dhcpopts
 
         {
             echo '. /lib/net-lib.sh'
             echo "setup_net $netif"
             echo "source_hook initqueue/online $netif"
-            [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
+            [ -e /tmp/net."$netif".manualup ] || echo "/sbin/netroot $netif"
             echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
-        } > $hookdir/initqueue/setup_net_$netif.sh
+        } > "$hookdir"/initqueue/setup_net_"$netif".sh
 
-        echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
-        > /tmp/net.$netif.up
-        if [ -e /sys/class/net/${netif}/address ]; then
-            > /tmp/net.$(cat /sys/class/net/${netif}/address).up
+        echo "[ -f /tmp/net.$netif.did-setup ]" > "$hookdir"/initqueue/finished/dhclient-"$netif".sh
+        : > /tmp/net."$netif".up
+        if [ -e /sys/class/net/"${netif}"/address ]; then
+            : > "/tmp/net.$(cat /sys/class/net/"${netif}"/address).up"
         fi
         ;;
 
@@ -260,7 +264,7 @@ case $reason in
         [ -n "$new_max_life" ] && lease_time=$new_max_life
         preferred_lft=$lease_time
         [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
-        ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} dev ${interface} scope global \
+        ip -6 addr change "${new_ip6_address}"/"${new_ip6_prefixlen}" dev "${interface}" scope global \
             ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
             > /dev/null 2>&1
         ;;
index b4ba61f0a6ac67d6b2e66efa1e42e6f6e732ed6f..f1b412ceea11ae831888dba287338d71dfb2bae2 100755 (executable)
@@ -16,20 +16,21 @@ arg=$3
 # Run dhclient in parallel
 do_dhclient() {
     local _COUNT=0
-    local _timeout=$(getargs rd.net.timeout.dhcp=)
-    local _DHCPRETRY=$(getargs rd.net.dhcp.retry=)
-    _DHCPRETRY=${_DHCPRETRY:-1}
+    local _timeout
+    local _DHCPRETRY
+    _timeout=$(getarg rd.net.timeout.dhcp=)
+    _DHCPRETRY=$(getargnum 1 1 1000000000 rd.net.dhcp.retry=)
 
-    while [ $_COUNT -lt $_DHCPRETRY ]; do
+    while [ $_COUNT -lt "$_DHCPRETRY" ]; do
         info "Starting dhcp for interface $netif"
-        dhclient $arg \
-            ${_timeout:+--timeout $_timeout} \
+        dhclient "$arg" \
+            ${_timeout:+--timeout "$_timeout"} \
             -q \
             -1 \
             -cf /etc/dhclient.conf \
-            -pf /tmp/dhclient.$netif.pid \
-            -lf /tmp/dhclient.$netif.lease \
-            $netif &
+            -pf /tmp/dhclient."$netif".pid \
+            -lf /tmp/dhclient."$netif".lease \
+            "$netif" &
         wait $! 2> /dev/null
 
         # wait will return the return value of dhclient
@@ -50,21 +51,21 @@ do_dhclient() {
         # or it finished execution but failed dhcp on that interface.
 
         if [ $retv -eq 127 ]; then
-            pid=$(cat /tmp/dhclient.$netif.pid)
+            pid=$(cat /tmp/dhclient."$netif".pid)
             info "PID $pid was not found by wait for $netif"
-            if [ -e /tmp/dhclient.$netif.lease ]; then
+            if [ -e /tmp/dhclient."$netif".lease ]; then
                 info "PID $pid not found but DHCP successful on $netif"
                 return 0
             fi
         fi
 
         _COUNT=$((_COUNT + 1))
-        [ $_COUNT -lt $_DHCPRETRY ] && sleep 1
+        [ $_COUNT -lt "$_DHCPRETRY" ] && sleep 1
     done
     warn "dhcp for interface $netif failed"
     # nuke those files since we failed; we might retry dhcp again if it's e.g.
     # `ip=dhcp,dhcp6` and we check for the PID file earlier
-    rm -f /tmp/dhclient.$netif.{pid,lease}
+    rm -f /tmp/dhclient."$netif".{pid,lease}
     return 1
 }
 
@@ -74,14 +75,14 @@ ret=$?
 # setup nameserver
 for s in "$dns1" "$dns2" $(getargs nameserver); do
     [ -n "$s" ] || continue
-    echo nameserver $s >> /tmp/net.$netif.resolv.conf
+    echo nameserver "$s" >> /tmp/net."$netif".resolv.conf
 done
 
 if [ $ret -eq 0 ]; then
-    > /tmp/net.${netif}.up
+    : > /tmp/net."${netif}".up
 
-    if [ -z "$do_vlan" ] && [ -e /sys/class/net/${netif}/address ]; then
-        > /tmp/net.$(cat /sys/class/net/${netif}/address).up
+    if [ -z "$do_vlan" ] && [ -e /sys/class/net/"${netif}"/address ]; then
+        : > "/tmp/net.$(cat /sys/class/net/"${netif}"/address).up"
     fi
 
     # Check if DHCP also suceeded on another interface before this one.
@@ -101,18 +102,18 @@ if [ $ret -eq 0 ]; then
     # Also, the link points to the interface name, which will tell us which
     # interface succeeded.
 
-    if ln -s $netif $IFNETFILE 2> /dev/null; then
-        intf=$(readlink $IFNETFILE)
-        if [ -e /tmp/dhclient.$intf.lease ]; then
+    if ln -s "$netif" "$IFNETFILE" 2> /dev/null; then
+        intf=$(readlink "$IFNETFILE")
+        if [ -e /tmp/dhclient."$intf".lease ]; then
             info "DHCP successful on interface $intf"
             # Kill all existing dhclient calls for other interfaces, since we
             # already got one successful interface
 
-            npid=$(cat /tmp/dhclient.$netif.pid)
+            npid=$(cat /tmp/dhclient."$netif".pid)
             pidlist=$(pgrep dhclient)
             for pid in $pidlist; do
                 [ "$pid" -eq "$npid" ] && continue
-                kill -9 $pid > /dev/null 2>&1
+                kill -9 "$pid" > /dev/null 2>&1
             done
         else
             echo "ERROR! $IFNETFILE exists but /tmp/dhclient.$intf.lease does not exist!!!"
index 4d91ee85185e47ea1386e583d279b904f30cabf0..95a8a8b37f65a8f080841c95a24b97bb2f1fdcd6 100755 (executable)
@@ -28,15 +28,15 @@ do_dhcp_parallel() {
     # event for nfsroot
     # XXX add -V vendor class and option parsing per kernel
 
-    [ -e /tmp/dhclient.$netif.pid ] && return 0
+    [ -e "/tmp/dhclient.$netif.pid" ] && return 0
 
-    if ! iface_has_carrier $netif; then
+    if ! iface_has_carrier "$netif"; then
         warn "No carrier detected on interface $netif"
         return 1
     fi
 
-    bootintf=$(readlink $IFNETFILE)
-    if [ ! -z $bootintf ] && [ -e /tmp/dhclient.$bootintf.lease ]; then
+    bootintf=$(readlink "$IFNETFILE")
+    if [ -n "$bootintf" ] && [ -e "/tmp/dhclient.${bootintf}.lease" ]; then
         info "DHCP already succeeded for $bootintf, exiting for $netif"
         return 1
     fi
@@ -58,14 +58,17 @@ do_dhcp() {
     # event for nfsroot
     # XXX add -V vendor class and option parsing per kernel
 
-    local _COUNT=0
-    local _timeout=$(getargs rd.net.timeout.dhcp=)
-    local _DHCPRETRY=$(getargs rd.net.dhcp.retry=)
-    _DHCPRETRY=${_DHCPRETRY:-1}
+    local _COUNT
+    local _timeout
+    local _DHCPRETRY
+
+    _COUNT=0
+    _timeout=$(getarg rd.net.timeout.dhcp=)
+    _DHCPRETRY=$(getargnum 1 1 1000000000 rd.net.dhcp.retry=)
 
-    [ -e /tmp/dhclient.$netif.pid ] && return 0
+    [ -e "/tmp/dhclient.${netif}.pid" ] && return 0
 
-    if ! iface_has_carrier $netif; then
+    if ! iface_has_carrier "$netif"; then
         warn "No carrier detected on interface $netif"
         return 1
     fi
@@ -76,24 +79,24 @@ do_dhcp() {
         echo 'dhcp=dhclient' >> /run/NetworkManager/conf.d/10-dracut-dhclient.conf
     fi
 
-    while [ $_COUNT -lt $_DHCPRETRY ]; do
+    while [ "$_COUNT" -lt "$_DHCPRETRY" ]; do
         info "Starting dhcp for interface $netif"
         dhclient "$@" \
-            ${_timeout:+--timeout $_timeout} \
+            ${_timeout:+--timeout "$_timeout"} \
             -q \
             -1 \
             -cf /etc/dhclient.conf \
-            -pf /tmp/dhclient.$netif.pid \
-            -lf /tmp/dhclient.$netif.lease \
-            $netif \
+            -pf "/tmp/dhclient.${netif}.pid" \
+            -lf "/tmp/dhclient.${netif}.lease" \
+            "$netif" \
             && return 0
         _COUNT=$((_COUNT + 1))
-        [ $_COUNT -lt $_DHCPRETRY ] && sleep 1
+        [ "$_COUNT" -lt "$_DHCPRETRY" ] && sleep 1
     done
     warn "dhcp for interface $netif failed"
     # nuke those files since we failed; we might retry dhcp again if it's e.g.
     # `ip=dhcp,dhcp6` and we check for the PID file at the top
-    rm -f /tmp/dhclient.$netif.{pid,lease}
+    rm -f "/tmp/dhclient.${netif}".{pid,lease}
     return 1
 }
 
@@ -111,34 +114,34 @@ load_ipv6() {
 do_ipv6auto() {
     local ret
     load_ipv6
-    echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
-    echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
-    echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
-    linkup $netif
-    wait_for_ipv6_auto $netif
+    echo 0 > /proc/sys/net/ipv6/conf/"${netif}"/forwarding
+    echo 1 > /proc/sys/net/ipv6/conf/"${netif}"/accept_ra
+    echo 1 > /proc/sys/net/ipv6/conf/"${netif}"/accept_redirects
+    linkup "$netif"
+    wait_for_ipv6_auto "$netif"
     ret=$?
 
-    [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+    [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > "/tmp/net.${netif}.hostname"
 
-    return $ret
+    return "$ret"
 }
 
 do_ipv6link() {
     local ret
     load_ipv6
-    echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
-    echo 0 > /proc/sys/net/ipv6/conf/$netif/accept_ra
-    echo 0 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
-    linkup $netif
+    echo 0 > /proc/sys/net/ipv6/conf/"${netif}"/forwarding
+    echo 0 > /proc/sys/net/ipv6/conf/"${netif}"/accept_ra
+    echo 0 > /proc/sys/net/ipv6/conf/"${netif}"/accept_redirects
+    linkup "$netif"
 
-    [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+    [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > "/tmp/net.${netif}.hostname"
 
-    return $ret
+    return "$ret"
 }
 
 # Handle static ip configuration
 do_static() {
-    strglobin $ip '*:*:*' && load_ipv6
+    strglobin "$ip" '*:*:*' && load_ipv6
 
     if ! iface_has_carrier "$netif"; then
         warn "No carrier detected on interface $netif"
@@ -149,7 +152,7 @@ do_static() {
     fi
 
     ip route get "$ip" 2> /dev/null | {
-        read a rest
+        read -r a rest
         if [ "$a" = "local" ]; then
             warn "Not assigning $ip to interface $netif, cause it is already assigned!"
             return 1
@@ -157,35 +160,35 @@ do_static() {
         return 0
     } || return 1
 
-    [ -n "$macaddr" ] && ip link set address $macaddr dev $netif
-    [ -n "$mtu" ] && ip link set mtu $mtu dev $netif
-    if strglobin $ip '*:*:*'; then
+    [ -n "$macaddr" ] && ip link set address "$macaddr" dev "$netif"
+    [ -n "$mtu" ] && ip link set mtu "$mtu" dev "$netif"
+    if strglobin "$ip" '*:*:*'; then
         # note no ip addr flush for ipv6
-        ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
-        echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
-        echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
-        echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
-        wait_for_ipv6_dad $netif
+        ip addr add "$ip/$mask" ${srv:+peer "$srv"} dev "$netif"
+        echo 0 > /proc/sys/net/ipv6/conf/"${netif}"/forwarding
+        echo 1 > /proc/sys/net/ipv6/conf/"${netif}"/accept_ra
+        echo 1 > /proc/sys/net/ipv6/conf/"${netif}"/accept_redirects
+        wait_for_ipv6_dad "$netif"
     else
         if [ -z "$srv" ]; then
             if command -v arping2 > /dev/null; then
-                if arping2 -q -C 1 -c 2 -I $netif -0 $ip; then
+                if arping2 -q -C 1 -c 2 -I "$netif" -0 "$ip"; then
                     warn "Duplicate address detected for $ip for interface $netif."
                     return 1
                 fi
             else
-                if ! arping -f -q -D -c 2 -I $netif $ip; then
+                if ! arping -f -q -D -c 2 -I "$netif" "$ip"; then
                     warn "Duplicate address detected for $ip for interface $netif."
                     return 1
                 fi
             fi
         fi
-        ip addr flush dev $netif
-        ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
+        ip addr flush dev "$netif"
+        ip addr add "$ip/$mask" ${srv:+peer "$srv"} brd + dev "$netif"
     fi
 
-    [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw
-    [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+    [ -n "$gw" ] && echo "ip route replace default via '$gw' dev '$netif'" > "/tmp/net.$netif.gw"
+    [ -n "$hostname" ] && echo "echo '$hostname' > /proc/sys/kernel/hostname" > "/tmp/net.$netif.hostname"
 
     return 0
 }
@@ -193,28 +196,29 @@ do_static() {
 get_vid() {
     case "$1" in
         vlan*)
-            echo ${1#vlan}
+            echo "${1#vlan}"
             ;;
         *.*)
-            echo ${1##*.}
+            echo "${1##*.}"
             ;;
     esac
 }
 
 # check, if we need VLAN's for this interface
-if [ -z "$DO_VLAN_PHY" ] && [ -e /tmp/vlan.${netif}.phy ]; then
+if [ -z "$DO_VLAN_PHY" ] && [ -e "/tmp/vlan.${netif}.phy" ]; then
     unset DO_VLAN
     NO_AUTO_DHCP=yes DO_VLAN_PHY=yes ifup "$netif"
     modprobe -b -q 8021q
 
-    for i in /tmp/vlan.*.${netif}; do
+    for i in /tmp/vlan.*."${netif}"; do
         [ -e "$i" ] || continue
         unset vlanname
         unset phydevice
+        # shellcheck disable=SC1090
         . "$i"
         if [ -n "$vlanname" ]; then
             linkup "$phydevice"
-            ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname)"
+            ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid "$vlanname")"
             ifup "$vlanname"
         fi
     done
@@ -222,8 +226,8 @@ if [ -z "$DO_VLAN_PHY" ] && [ -e /tmp/vlan.${netif}.phy ]; then
 fi
 
 # Check, if interface is VLAN interface
-if ! [ -e /tmp/vlan.${netif}.phy ]; then
-    for i in /tmp/vlan.${netif}.*; do
+if ! [ -e "/tmp/vlan.${netif}.phy" ]; then
+    for i in "/tmp/vlan.${netif}".*; do
         [ -e "$i" ] || continue
         export DO_VLAN=yes
         break
@@ -236,19 +240,20 @@ if [ -z "$NO_BRIDGE_MASTER" ]; then
         [ -e "$i" ] || continue
         unset bridgeslaves
         unset bridgename
+        # shellcheck disable=SC1090
         . "$i"
         for ethname in $bridgeslaves; do
             [ "$netif" != "$ethname" ] && continue
 
-            NO_BRIDGE_MASTER=yes NO_AUTO_DHCP=yes ifup $ethname
-            linkup $ethname
-            if [ ! -e /tmp/bridge.$bridgename.up ]; then
-                ip link add name $bridgename type bridge
-                echo 0 > /sys/devices/virtual/net/$bridgename/bridge/forward_delay
-                > /tmp/bridge.$bridgename.up
+            NO_BRIDGE_MASTER=yes NO_AUTO_DHCP=yes ifup "$ethname"
+            linkup "$ethname"
+            if [ ! -e "/tmp/bridge.$bridgename.up" ]; then
+                ip link add name "$bridgename" type bridge
+                echo 0 > "/sys/devices/virtual/net/$bridgename/bridge/forward_delay"
+                : > "/tmp/bridge.$bridgename.up"
             fi
-            ip link set dev $ethname master $bridgename
-            ifup $bridgename
+            ip link set dev "$ethname" master "$bridgename"
+            ifup "$bridgename"
             exit 0
         done
     done
@@ -260,19 +265,20 @@ if [ -z "$NO_BOND_MASTER" ]; then
         [ -e "$i" ] || continue
         unset bondslaves
         unset bondname
+        # shellcheck disable=SC1090
         . "$i"
-        for slave in $bondslaves; do
-            [ "$netif" != "$slave" ] && continue
+        for testslave in $bondslaves; do
+            [ "$netif" != "testslave" ] && continue
 
             # already setup
-            [ -e /tmp/bond.$bondname.up ] && exit 0
+            [ -e "/tmp/bond.$bondname.up" ] && exit 0
 
             # wait for all slaves to show up
             for slave in $bondslaves; do
                 # try to create the slave (maybe vlan or bridge)
-                NO_BOND_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
+                NO_BOND_MASTER=yes NO_AUTO_DHCP=yes ifup "$slave"
 
-                if ! ip link show dev $slave > /dev/null 2>&1; then
+                if ! ip link show dev "$slave" > /dev/null 2>&1; then
                     # wait for the last slave to show up
                     exit 0
                 fi
@@ -280,7 +286,7 @@ if [ -z "$NO_BOND_MASTER" ]; then
 
             modprobe -q -b bonding
             echo "+$bondname" > /sys/class/net/bonding_masters 2> /dev/null
-            ip link set $bondname down
+            ip link set "$bondname" down
 
             # Stolen from ifup-eth
             # add the bits to setup driver parameters here
@@ -292,38 +298,38 @@ if [ -z "$NO_BOND_MASTER" ]; then
                     OLDIFS=$IFS
                     IFS=','
                     for arp_ip in $value; do
-                        echo +$arp_ip > /sys/class/net/${bondname}/bonding/$key
+                        echo "+$arp_ip" > "/sys/class/net/${bondname}/bonding/$key"
                     done
                     IFS=$OLDIFS
                 else
-                    echo $value > /sys/class/net/${bondname}/bonding/$key
+                    echo "$value" > "/sys/class/net/${bondname}/bonding/$key"
                 fi
             done
 
-            linkup $bondname
+            linkup "$bondname"
 
             for slave in $bondslaves; do
-                cat /sys/class/net/$slave/address > /tmp/net.${bondname}.${slave}.hwaddr
-                ip link set $slave down
-                echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
-                linkup $slave
+                cat "/sys/class/net/$slave/address" > "/tmp/net.${bondname}.${slave}.hwaddr"
+                ip link set "$slave" down
+                echo "+$slave" > "/sys/class/net/$bondname/bonding/slaves"
+                linkup "$slave"
             done
 
             # Set mtu on bond master
-            [ -n "$bondmtu" ] && ip link set mtu $bondmtu dev $bondname
+            [ -n "$bondmtu" ] && ip link set mtu "$bondmtu" dev "$bondname"
 
             # add the bits to setup the needed post enslavement parameters
             for arg in $bondoptions; do
                 key=${arg%%=*}
                 value=${arg##*=}
                 if [ "${key}" = "primary" ]; then
-                    echo $value > /sys/class/net/${bondname}/bonding/$key
+                    echo "$value" > "/sys/class/net/${bondname}/bonding/$key"
                 fi
             done
 
-            > /tmp/bond.$bondname.up
+            : > "/tmp/bond.$bondname.up"
 
-            NO_BOND_MASTER=yes ifup $bondname
+            NO_BOND_MASTER=yes ifup "$bondname"
             exit $?
         done
     done
@@ -334,63 +340,67 @@ if [ -z "$NO_TEAM_MASTER" ]; then
         [ -e "$i" ] || continue
         unset teammaster
         unset teamslaves
+        # shellcheck disable=SC1090
         . "$i"
-        for slave in $teamslaves; do
-            [ "$netif" != "$slave" ] && continue
+        for testslave in $teamslaves; do
+            [ "$netif" != "$testslave" ] && continue
 
-            [ -e /tmp/team.$teammaster.up ] && exit 0
+            [ -e "/tmp/team.$teammaster.up" ] && exit 0
 
             # wait for all slaves to show up
             for slave in $teamslaves; do
                 # try to create the slave (maybe vlan or bridge)
-                NO_TEAM_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
+                NO_TEAM_MASTER=yes NO_AUTO_DHCP=yes ifup "$slave"
 
-                if ! ip link show dev $slave > /dev/null 2>&1; then
+                if ! ip link show dev "$slave" > /dev/null 2>&1; then
                     # wait for the last slave to show up
                     exit 0
                 fi
             done
 
-            if [ ! -e /tmp/team.$teammaster.up ]; then
+            if [ ! -e "/tmp/team.$teammaster.up" ]; then
                 # We shall only bring up those _can_ come up
                 # in case of some slave is gone in active-backup mode
                 working_slaves=""
                 for slave in $teamslaves; do
-                    teamdctl ${teammaster} port present ${slave} 2> /dev/null \
+                    teamdctl "${teammaster}" port present "${slave}" 2> /dev/null \
                         && continue
-                    ip link set dev $slave up 2> /dev/null
-                    if wait_for_if_up $slave; then
+                    ip link set dev "$slave" up 2> /dev/null
+                    if wait_for_if_up "$slave"; then
                         working_slaves="$working_slaves$slave "
                     fi
                 done
                 # Do not add slaves now
-                teamd -d -U -n -N -t $teammaster -f /etc/teamd/${teammaster}.conf
+                teamd -d -U -n -N -t "$teammaster" -f "/etc/teamd/${teammaster}.conf"
                 for slave in $working_slaves; do
                     # team requires the slaves to be down before joining team
-                    ip link set dev $slave down
+                    ip link set dev "$slave" down
                     (
                         unset TEAM_PORT_CONFIG
-                        _hwaddr=$(cat /sys/class/net/$slave/address)
+                        _hwaddr=$(cat "/sys/class/net/$slave/address")
                         _subchannels=$(iface_get_subchannels "$slave")
                         if [ -n "$_hwaddr" ] && [ -e "/etc/sysconfig/network-scripts/mac-${_hwaddr}.conf" ]; then
+                            # shellcheck disable=SC1090
                             . "/etc/sysconfig/network-scripts/mac-${_hwaddr}.conf"
                         elif [ -n "$_subchannels" ] && [ -e "/etc/sysconfig/network-scripts/ccw-${_subchannels}.conf" ]; then
+                            # shellcheck disable=SC1090
                             . "/etc/sysconfig/network-scripts/ccw-${_subchannels}.conf"
                         elif [ -e "/etc/sysconfig/network-scripts/ifcfg-${slave}" ]; then
+                            # shellcheck disable=SC1090
                             . "/etc/sysconfig/network-scripts/ifcfg-${slave}"
                         fi
 
                         if [ -n "${TEAM_PORT_CONFIG}" ]; then
-                            /usr/bin/teamdctl ${teammaster} port config update ${slave} "${TEAM_PORT_CONFIG}"
+                            /usr/bin/teamdctl "${teammaster}" port config update "${slave}" "${TEAM_PORT_CONFIG}"
                         fi
                     )
-                    teamdctl $teammaster port add $slave
+                    teamdctl "$teammaster" port add "$slave"
                 done
 
-                ip link set dev $teammaster up
+                ip link set dev "$teammaster" up
 
-                > /tmp/team.$teammaster.up
-                NO_TEAM_MASTER=yes ifup $teammaster
+                : > "/tmp/team.$teammaster.up"
+                NO_TEAM_MASTER=yes ifup "$teammaster"
                 exit $?
             fi
         done
@@ -398,7 +408,7 @@ if [ -z "$NO_TEAM_MASTER" ]; then
 fi
 
 # all synthetic interfaces done.. now check if the interface is available
-if ! ip link show dev $netif > /dev/null 2>&1; then
+if ! ip link show dev "$netif" > /dev/null 2>&1; then
     exit 1
 fi
 
@@ -407,29 +417,29 @@ fi
 [ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
 
 if [ -n "$manualup" ]; then
-    > /tmp/net.$netif.manualup
-    rm -f /tmp/net.${netif}.did-setup
+    : > "/tmp/net.$netif.manualup"
+    rm -f "/tmp/net.${netif}.did-setup"
 else
-    [ -e /tmp/net.${netif}.did-setup ] && exit 0
+    [ -e "/tmp/net.${netif}.did-setup" ] && exit 0
     [ -z "$DO_VLAN" ] \
-        && [ -e /sys/class/net/$netif/address ] \
-        && [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
+        && [ -e "/sys/class/net/$netif/address" ] \
+        && [ -e "/tmp/net.$(cat "/sys/class/net/$netif/address").did-setup" ] && exit 0
 fi
 
 # Specific configuration, spin through the kernel command line
 # looking for ip= lines
 for p in $(getargs ip=); do
-    ip_to_var $p
+    ip_to_var "$p"
     # skip ibft
     [ "$autoconf" = "ibft" ] && continue
 
     case "$dev" in
         ??:??:??:??:??:??) # MAC address
-            _dev=$(iface_for_mac $dev)
+            _dev=$(iface_for_mac "$dev")
             [ -n "$_dev" ] && dev="$_dev"
             ;;
         ??-??-??-??-??-??) # MAC address in BOOTIF form
-            _dev=$(iface_for_mac $(fix_bootif $dev))
+            _dev=$(iface_for_mac "$(fix_bootif "$dev")")
             [ -n "$_dev" ] && dev="$_dev"
             ;;
     esac
@@ -444,7 +454,7 @@ for p in $(getargs ip=); do
     # Store config for later use
     for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do
         eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
-    done > /tmp/net.$netif.override
+    done > "/tmp/net.$netif.override"
 
     for autoopt in $(str_replace "$autoconf" "," " "); do
         case $autoopt in
@@ -478,28 +488,28 @@ for p in $(getargs ip=); do
     # setup nameserver
     for s in "$dns1" "$dns2" $(getargs nameserver); do
         [ -n "$s" ] || continue
-        echo nameserver $s >> /tmp/net.$netif.resolv.conf
+        echo "nameserver $s" >> "/tmp/net.$netif.resolv.conf"
     done
 
     if [ $ret -eq 0 ]; then
-        > /tmp/net.${netif}.up
+        : > "/tmp/net.${netif}.up"
 
-        if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
-            > /tmp/net.$(cat /sys/class/net/${netif}/address).up
+        if [ -z "$DO_VLAN" ] && [ -e "/sys/class/net/${netif}/address" ]; then
+            : > "/tmp/net.$(cat "/sys/class/net/${netif}/address").up"
         fi
 
         # and finally, finish interface set up if there isn't already a script
         # to do so (which is the case in the dhcp path)
-        if [ ! -e $hookdir/initqueue/setup_net_$netif.sh ]; then
-            setup_net $netif
-            source_hook initqueue/online $netif
+        if [ ! -e "$hookdir/initqueue/setup_net_$netif.sh" ]; then
+            setup_net "$netif"
+            source_hook initqueue/online "$netif"
             if [ -z "$manualup" ]; then
-                /sbin/netroot $netif
+                /sbin/netroot "$netif"
             fi
         fi
 
         if command -v wicked > /dev/null && [ -z "$manualup" ]; then
-            /sbin/netroot $netif
+            /sbin/netroot "$netif"
         fi
 
         exit $ret
@@ -507,11 +517,11 @@ for p in $(getargs ip=); do
 done
 
 # no ip option directed at our interface?
-if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then
+if [ -z "$NO_AUTO_DHCP" ] && [ ! -e "/tmp/net.${netif}.up" ]; then
     ret=1
     if [ -e /tmp/net.bootdev ]; then
         BOOTDEV=$(cat /tmp/net.bootdev)
-        if [ "$netif" = "$BOOTDEV" ] || [ "$BOOTDEV" = "$(cat /sys/class/net/${netif}/address)" ]; then
+        if [ "$netif" = "$BOOTDEV" ] || [ "$BOOTDEV" = "$(cat "/sys/class/net/${netif}/address")" ]; then
             do_dhcp
             ret=$?
         fi
@@ -532,13 +542,13 @@ if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then
 
     for s in $(getargs nameserver); do
         [ -n "$s" ] || continue
-        echo nameserver $s >> /tmp/net.$netif.resolv.conf
+        echo "nameserver $s" >> "/tmp/net.$netif.resolv.conf"
     done
 
-    if [ "$ret" -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}* 2> /dev/null)" ]; then
-        > /tmp/net.${netif}.did-setup
-        if [ -e /sys/class/net/${netif}/address ]; then
-            > /tmp/net.$(cat /sys/class/net/${netif}/address).did-setup
+    if [ "$ret" -eq 0 ] && [ -n "$(ls "/tmp/leaseinfo.${netif}"* 2> /dev/null)" ]; then
+        : > "/tmp/net.${netif}.did-setup"
+        if [ -e "/sys/class/net/${netif}/address" ]; then
+            : > "/tmp/net.$(cat "/sys/class/net/${netif}/address").did-setup"
         fi
     fi
 fi
index 363abf95d25cfd73566cb0bdfe1e7283cc69decc..9ed615fd9a20991762b3f782f93957ab3f0e02dd 100755 (executable)
@@ -1,15 +1,15 @@
 #!/bin/sh
 
 for f in /tmp/dhclient.*.pid; do
-    [ -e $f ] || continue
-    read PID < $f
-    kill $PID > /dev/null 2>&1
+    [ -e "$f" ] || continue
+    read -r PID < "$f"
+    kill "$PID" > /dev/null 2>&1
 done
 
 sleep 0.1
 
 for f in /tmp/dhclient.*.pid; do
-    [ -e $f ] || continue
-    read PID < $f
-    kill -9 $PID > /dev/null 2>&1
+    [ -e "$f" ] || continue
+    read -r PID < "$f"
+    kill -9 "$PID" > /dev/null 2>&1
 done
index 7f31914a1aa0cf3cfec1ad00bac439ad28a685cc..9b90aaaa0ce0cb8ce391074d21c0b1e927806a9a 100755 (executable)
@@ -2,9 +2,7 @@
 
 # called by dracut
 check() {
-    local _program
-
-    require_binaries ip dhclient sed awk grep pgrep || return 1
+    require_binaries ip dhclient sed awk grep pgrep tr || return 1
     require_any_binary arping arping2 || return 1
 
     return 255
@@ -22,8 +20,8 @@ installkernel() {
 
 # called by dracut
 install() {
-    local _arch _i _dir
-    inst_multiple ip dhclient sed awk grep pgrep
+    local _arch
+    inst_multiple ip dhclient sed awk grep pgrep tr
 
     inst_multiple -o arping arping2
     strstr "$(arping 2>&1)" "ARPing 2" && mv "$initdir/bin/arping" "$initdir/bin/arping2"
@@ -60,21 +58,22 @@ install() {
                 ;;
         esac
         (
+            # shellcheck disable=SC1090
             . "$i"
             if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \
                 && [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then
                 if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then
-                    mkdir -p $initdir/etc/teamd
+                    mkdir -p "$initdir"/etc/teamd
                     printf -- "%s" "$TEAM_CONFIG" > "$initdir/etc/teamd/${DEVICE}.conf"
                 elif [ -n "$TEAM_PORT_CONFIG" ]; then
                     inst_simple "$i"
 
-                    HWADDR="$(echo $HWADDR | sed 'y/ABCDEF/abcdef/')"
+                    HWADDR="$(echo "$HWADDR" | sed 'y/ABCDEF/abcdef/')"
                     if [ -n "$HWADDR" ]; then
                         ln_r "$i" "/etc/sysconfig/network-scripts/mac-${HWADDR}.conf"
                     fi
 
-                    SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')"
+                    SUBCHANNELS="$(echo "$SUBCHANNELS" | sed 'y/ABCDEF/abcdef/')"
                     if [ -n "$SUBCHANNELS" ]; then
                         ln_r "$i" "/etc/sysconfig/network-scripts/ccw-${SUBCHANNELS}.conf"
                     fi
index 7252900e09cdafa6efdc9b1e4d67b138cf883ec2..7e89f73de28455a285ec638f19c35094e30f9ae2 100755 (executable)
@@ -16,6 +16,7 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
         [ -e "$i" ] || continue
         unset bridgeslaves
         unset bridgename
+        # shellcheck disable=SC1090
         . "$i"
         RAW_IFACES="$RAW_IFACES $bridgeslaves"
         MASTER_IFACES="$MASTER_IFACES $bridgename"
@@ -26,6 +27,7 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
         [ -e "$i" ] || continue
         unset bondslaves
         unset bondname
+        # shellcheck disable=SC1090
         . "$i"
         # It is enough to fire up only one
         RAW_IFACES="$RAW_IFACES $bondslaves"
@@ -36,6 +38,7 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
         [ -e "$i" ] || continue
         unset teamslaves
         unset teammaster
+        # shellcheck disable=SC1090
         . "$i"
         RAW_IFACES="$RAW_IFACES ${teamslaves}"
         MASTER_IFACES="$MASTER_IFACES ${teammaster}"
@@ -44,11 +47,13 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
     for i in /tmp/vlan.*.phy; do
         [ -e "$i" ] || continue
         unset phydevice
+        # shellcheck disable=SC1090
         . "$i"
         RAW_IFACES="$RAW_IFACES $phydevice"
-        for j in /tmp/vlan.*.${phydevice}; do
+        for j in /tmp/vlan.*".${phydevice}"; do
             [ -e "$j" ] || continue
             unset vlanname
+            # shellcheck disable=SC1090
             . "$j"
             MASTER_IFACES="$MASTER_IFACES ${vlanname}"
         done
@@ -58,13 +63,14 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
     RAW_IFACES="$(trim "$RAW_IFACES")"
 
     if [ -z "$IFACES" ]; then
-        [ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
+        [ -e /tmp/net.ifaces ] && read -r IFACES < /tmp/net.ifaces
     fi
 
     if [ -e /tmp/net.bootdev ]; then
         bootdev=$(cat /tmp/net.bootdev)
     fi
 
+    # shellcheck disable=SC2016
     ifup='/sbin/ifup $name'
 
     runcmd="RUN+=\"/sbin/initqueue --name ifup-\$name --unique --onetime $ifup\""
@@ -80,7 +86,7 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
                     echo "$cond, $runcmd, GOTO=\"net_end\""
                     ;;
                 ??-??-??-??-??-??) # MAC address in BOOTIF form
-                    cond="ATTR{address}==\"$(fix_bootif $iface)\""
+                    cond="ATTR{address}==\"$(fix_bootif "$iface")\""
                     echo "$cond, $runcmd, GOTO=\"net_end\""
                     ;;
                 *) # an interface name
@@ -100,7 +106,7 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
                     echo "systemctl is-active initrd-root-device.target || [ -f /tmp/net.${iface}.did-setup ]"
                 else
                     echo "[ -f /tmp/net.${iface}.did-setup ]"
-                fi > $hookdir/initqueue/finished/wait-$iface.sh
+                fi > "$hookdir"/initqueue/finished/wait-"$iface".sh
             fi
         done
     # Default: We don't know the interface to use, handle all
@@ -110,7 +116,8 @@ command -v fix_bootif > /dev/null || . /lib/net-lib.sh
         # if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
         echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
         if [ "$NEEDNET" = "1" ]; then
-            echo 'for i in /tmp/net.*.did-setup; do [ -f "$i" ]  && exit 0; done; exit 1' > $hookdir/initqueue/finished/wait-network.sh
+            # shellcheck disable=SC2016
+            echo 'for i in /tmp/net.*.did-setup; do [ -f "$i" ]  && exit 0; done; exit 1' > "$hookdir"/initqueue/finished/wait-network.sh
         fi
     fi
 
index becd1e263260d934794d2ed096561cba2ccb448d..86cd89ce692085f2515f1244c17aab959e5fb1b5 100755 (executable)
@@ -66,8 +66,11 @@ for bond in $(getargs bond=); do
     fi
     # Make it suitable for initscripts export
     bondoptions=$(str_replace "$bondoptions" ";" ",")
-    echo "bondname=$bondname" > /tmp/bond.${bondname}.info
-    echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
-    echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
-    echo "bondmtu=\"$bondmtu\"" >> /tmp/bond.${bondname}.info
+
+    {
+        echo "bondname=$bondname"
+        echo "bondslaves=\"$bondslaves\""
+        echo "bondoptions=\"$bondoptions\""
+        echo "bondmtu=\"$bondmtu\""
+    } > "/tmp/bond.${bondname}.info"
 done
index 6a5732405d016891b340f5422b05ce35239ffddf..f15ce4707bbbc63f5d636773a0746691f2882bcd 100755 (executable)
@@ -35,13 +35,15 @@ for bridge in $(getargs bridge=); do
     iface=eth0
     # Read bridge= parameters if they exist
     if [ "$bridge" != "bridge" ]; then
-        parsebridge $bridge
+        parsebridge "$bridge"
     fi
     # Simple default bridge
     if [ -z "$bridgename" ]; then
         bridgename=br0
         bridgeslaves=$iface
     fi
-    echo "bridgename=$bridgename" > /tmp/bridge.${bridgename}.info
-    echo "bridgeslaves=\"$bridgeslaves\"" >> /tmp/bridge.${bridgename}.info
+    {
+        echo "bridgename=$bridgename"
+        echo "bridgeslaves=\"$bridgeslaves\""
+    } > /tmp/bridge.${bridgename}.info
 done
index d85de885b917f73568c83bfb4ca8ac9e4fcb5afc..be7b6ad69f882c08c13cc0053cba35d6918d879d 100755 (executable)
@@ -20,5 +20,5 @@ command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh
 
 # Check ifname= lines
 for p in $(getargs ifname=); do
-    parse_ifname_opts $p
+    parse_ifname_opts "$p"
 done
index dcec8ebe3f529ec22fe4c8e57dd32e876202eefc..b904fba835dc9e7ad47f81e83e3f46dff004c9d2 100755 (executable)
@@ -48,7 +48,7 @@ fi
 # Check ip= lines
 # XXX Would be nice if we could errorcheck ip addresses here as well
 for p in $(getargs ip=); do
-    ip_to_var $p
+    ip_to_var "$p"
 
     # make first device specified the BOOTDEV
     if [ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEV" ] && [ -n "$dev" ]; then
@@ -126,7 +126,7 @@ done
 
 # put BOOTIF in IFACES to make sure it comes up
 if getargbool 1 "rd.bootif" && BOOTIF="$(getarg BOOTIF=)"; then
-    BOOTDEV=$(fix_bootif $BOOTIF)
+    BOOTDEV=$(fix_bootif "$BOOTIF")
     IFACES="$BOOTDEV $IFACES"
 fi
 
@@ -137,5 +137,5 @@ if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ]; then
 fi
 
 # Store BOOTDEV and IFACES for later use
-[ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev
-[ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces
+[ -n "$BOOTDEV" ] && echo "$BOOTDEV" > /tmp/net.bootdev
+[ -n "$IFACES" ] && echo "$IFACES" > /tmp/net.ifaces
index 0ae558fd7645abf68c703e387aec5d0feb004a7f..7b1801ba458b8ff7c48a92cf9fccc5f5e87fbd30 100755 (executable)
@@ -52,11 +52,13 @@ for team in $(getargs team); do
 
     parseteam "$team" || continue
 
-    echo "teammaster=$teammaster" > /tmp/team.${teammaster}.info
-    echo "teamslaves=\"$teamslaves\"" >> /tmp/team.${teammaster}.info
-    echo "teamrunner=\"$teamrunner\"" >> /tmp/team.${teammaster}.info
+    {
+        echo "teammaster=$teammaster"
+        echo "teamslaves=\"$teamslaves\""
+        echo "teamrunner=\"$teamrunner\""
+    } > /tmp/team."${teammaster}".info
 
-    if ! [ -e /etc/teamd/${teammaster}.conf ]; then
+    if ! [ -e /etc/teamd/"${teammaster}".conf ]; then
         warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using $teamrunner."
         mkdir -p /etc/teamd
         printf -- "%s" "{\"runner\": {\"name\": \"$teamrunner\"}, \"link_watch\": {\"name\": \"ethtool\"}}" > "/tmp/${teammaster}.conf"
index a8b4ddcbdaec588610b1f6ae3d959beae4315977..1570cd8124fd08ec7f1a2deae402364c0f0dec10 100755 (executable)
@@ -29,9 +29,9 @@ for vlan in $(getargs vlan=); do
         parsevlan "$vlan"
     fi
 
-    echo "phydevice=\"$phydevice\"" > /tmp/vlan.${phydevice}.phy
+    echo "phydevice=\"$phydevice\"" > /tmp/vlan."${phydevice}".phy
     {
         echo "vlanname=\"$vlanname\""
         echo "phydevice=\"$phydevice\""
-    } > /tmp/vlan.${vlanname}.${phydevice}
+    } > /tmp/vlan."${vlanname}"."${phydevice}"
 done