summaryrefslogtreecommitdiffstats
path: root/src/connections
diff options
context:
space:
mode:
Diffstat (limited to 'src/connections')
-rw-r--r--src/connections/bond6
-rw-r--r--src/connections/bridge28
-rw-r--r--src/connections/ethernet35
-rw-r--r--src/connections/pppoe4
-rw-r--r--src/connections/tunnel2
-rw-r--r--src/connections/tuntap4
-rw-r--r--src/connections/vlan10
-rw-r--r--src/connections/wireless4
8 files changed, 46 insertions, 47 deletions
diff --git a/src/connections/bond b/src/connections/bond
index ea6af77..132225a 100644
--- a/src/connections/bond
+++ b/src/connections/bond
@@ -5,7 +5,7 @@ IFENSLAVE="/sbin/ifenslave"
bond_up() {
load_profile "$1"
- if [ -e /sys/class/net/$INTERFACE ]; then
+ if [[ -e "/sys/class/net/$INTERFACE" ]]; then
report_fail "Interface $INTERFACE already exists."
exit 1
else
@@ -31,12 +31,12 @@ bond_down() {
"$CONN_DIR/ethernet" down "$1"
bring_interface down "$INTERFACE"
- ip link delete $INTERFACE &>/dev/null
+ ip link delete "$INTERFACE" &> /dev/null
return 0
}
bond_status() {
- if [ -e /sys/class/net/$INTERFACE ]; then
+ if [[ -e "/sys/class/net/$INTERFACE" ]]; then
return 0
else
return 1
diff --git a/src/connections/bridge b/src/connections/bridge
index 3cf60c1..e134647 100644
--- a/src/connections/bridge
+++ b/src/connections/bridge
@@ -6,27 +6,23 @@ bridge_up() {
local bridge_interface
load_profile "$1"
- if [ -e "/sys/class/net/$INTERFACE" ]; then
- if [ ! -d "/sys/class/net/$INTERFACE/brif" ]; then
+ if [[ -e "/sys/class/net/$INTERFACE" ]]; then
+ if [[ ! -d "/sys/class/net/$INTERFACE/brif" ]]; then
report_fail "Interface $INTERFACE already exists and is not a bridge."
exit 1
fi
else
- $BRCTL addbr $INTERFACE
+ $BRCTL addbr "$INTERFACE"
fi
for bridge_client in $BRIDGE_INTERFACES; do
- ip link set $bridge_client promisc on up
- ip addr flush dev $bridge_client
- $BRCTL addif $INTERFACE $bridge_client
+ ip link set "$bridge_client" promisc on up
+ ip addr flush dev "$bridge_client"
+ $BRCTL addif "$INTERFACE" "$bridge_client"
done
# Set options
- if [ -n "$FWD_DELAY" ]; then
- $BRCTL setfd $INTERFACE "$FWD_DELAY"
- fi
- if [ -n "$MAX_AGE" ]; then
- $BRCTL setmaxage $INTERFACE "$MAX_AGE"
- fi
+ [[ "$FWD_DELAY" ]] && $BRCTL setfd "$INTERFACE" "$FWD_DELAY"
+ [[ "$MAX_AGE" ]] && $BRCTL setmaxage "$INTERFACE" "$MAX_AGE"
bring_interface up "$INTERFACE"
"$CONN_DIR/ethernet" up "$1"
@@ -38,14 +34,14 @@ bridge_down() {
load_profile "$1"
for bridge_client in $BRIDGE_INTERFACES; do
- ip link set $bridge_client promisc off down
- $BRCTL delif $INTERFACE $bridge_client
+ ip link set "$bridge_client" promisc off down
+ $BRCTL delif "$INTERFACE" "$bridge_client"
done
"$CONN_DIR/ethernet" down "$1"
bring_interface down "$INTERFACE"
- $BRCTL delbr $INTERFACE
- return 0
+ $BRCTL delbr "$INTERFACE"
+ return 0
}
# Returns status of profile - is it still functional?
diff --git a/src/connections/ethernet b/src/connections/ethernet
index 78f8240..8be3c6f 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -23,8 +23,8 @@ ethernet_up() {
fi
# Disable IPv6 before the interface to prevent SLAAC
- if [[ "$IP6" == "no"]]; then
- sysctl -q -w net.ipv6.conf.$INTERFACE.disable_ipv6=1
+ if [[ "$IP6" == "no" ]]; then
+ sysctl -q -w "net.ipv6.conf.$INTERFACE.disable_ipv6=1"
fi
report_debug ethernet_iproute_up ifup
@@ -32,7 +32,8 @@ ethernet_up() {
if ! checkyesno "${SKIPNOCARRIER:-no}" && ip link show dev "$INTERFACE" | fgrep -q "NO-CARRIER"; then
- sleep ${CARRIER_TIMEOUT:-2} # Some cards are plain slow to come up. Don't fail immediately.
+ # Some cards are plain slow to come up. Don't fail immediately.
+ sleep ${CARRIER_TIMEOUT:-2}
if ip link show dev "$INTERFACE" | fgrep -q "NO-CARRIER"; then
report_iproute "No connection"
fi
@@ -47,7 +48,7 @@ ethernet_up() {
if grep "^ *ctrl_interface=" "$WPA_CONF" &>/dev/null; then
WPA_CTRL_PATH=$(grep -m 1 "^ *ctrl_interface=" "$WPA_CONF" | tail -n 1 | cut -d= -f 2- | sed -r 's/DIR=(.*) +GROUP=.*/\1/')
fi
-
+
report_debug ethernet_iproute_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_DRIVER" "$WPA_OPTS"
if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_DRIVER" "$WPA_OPTS"; then
report_fail "wpa_supplicant did not start, possible configuration error"
@@ -94,7 +95,7 @@ ethernet_up() {
static)
if [[ -n "$ADDR" ]]; then
[[ -z $NETMASK ]] && NETMASK=24
- report_debug ethernet_iproute_up ip addr add "$ADDR/$NETMASK" brd + dev "$INTERFACE"
+ report_debug ethernet_iproute_up ip addr add "$ADDR/$NETMASK" brd + dev "$INTERFACE"
if ! ip addr add "$ADDR/$NETMASK" brd + dev "$INTERFACE"; then
report_iproute "Could not configure interface"
fi
@@ -140,10 +141,12 @@ ethernet_up() {
# Load ipv6 module if necessary (FS#25530)
case "$IP6" in
dhcp*|stateless|static)
- [ -d "/proc/sys/net/ipv6" ] || modprobe ipv6
+ [[ -d "/proc/sys/net/ipv6" ]] || modprobe ipv6
;;
no)
- [ -d /proc/sys/net/ipv6 ] && sysctl -q -w net.ipv6.conf.$INTERFACE.accept_ra=0
+ [[ -d "/proc/sys/net/ipv6" ]] && sysctl -q -w "net.ipv6.conf.$INTERFACE.accept_ra=0"
+ ;;
+ "") # undefined IP6 does not prevent RA's from being received -> nop
;;
*)
report_iproute "IP6 must be 'dhcp', 'dhcp-noaddr', 'stateless', 'static' or 'no'"
@@ -153,12 +156,12 @@ ethernet_up() {
case "$IP6" in
dhcp*)
if [[ -x /usr/sbin/dhclient ]]; then
- _DHCLIENT_PIDFILE=/run/dhclient6-${INTERFACE}.pid
+ _DHCLIENT_PIDFILE="/run/dhclient6-${INTERFACE}.pid"
if [[ "$IP6" = "dhcp-noaddr" ]]; then
- sysctl -q -w net.ipv6.conf.$INTERFACE.accept_ra=1
+ sysctl -q -w "net.ipv6.conf.$INTERFACE.accept_ra=1"
DHCLIENT6_OPTIONS="-S ${DHCLIENT6_OPTIONS}"
else
- sysctl -q -w net.ipv6.conf.$INTERFACE.accept_ra=0
+ sysctl -q -w "net.ipv6.conf.$INTERFACE.accept_ra=0"
fi
rm -r ${_DHCLIENT_PIDFILE} &>/dev/null
report_debug ethernet_up dhclient -6 -q -e TIMEOUT="${DHCP_TIMEOUT:-10}" -pf ${_DHCLIENT_PIDFILE} "$INTERFACE"
@@ -172,10 +175,10 @@ ethernet_up() {
fi
;;
stateless)
- sysctl -q -w net.ipv6.conf.$INTERFACE.accept_ra=1
+ sysctl -q -w "net.ipv6.conf.$INTERFACE.accept_ra=1"
;;
static)
- sysctl -q -w net.ipv6.conf.$INTERFACE.accept_ra=0
+ sysctl -q -w "net.ipv6.conf.$INTERFACE.accept_ra=0"
if [[ -n "$ADDR6" ]]; then
for addr in "${ADDR6[@]}"; do
report_debug ethernet_iproute_up ip -6 addr add "$addr" dev "$INTERFACE"
@@ -194,8 +197,8 @@ ethernet_up() {
# Add static IPv6 routes
if [[ -n "$ROUTES6" ]]; then
for route in "${ROUTES6[@]}"; do
- report_debug ethernet_iproute_up ip -6 route add $route dev $INTERFACE
- if ! ip -6 route add $route dev $INTERFACE ; then
+ report_debug ethernet_iproute_up ip -6 route add "$route" dev "$INTERFACE"
+ if ! ip -6 route add "$route" dev "$INTERFACE"; then
report_iproute "Adding route '$route' failed"
fi
done
@@ -267,7 +270,7 @@ ethernet_down() {
else
bring_interface down "$INTERFACE"
fi
- return 0
+ return 0
}
# Returns status of profile - is it still functional?
@@ -277,7 +280,7 @@ ethernet_status() {
fi
}
-# Stop wpa_supplicant if neccessary
+# Stop wpa_supplicant if neccessary
stop_80211x() {
if checkyesno "${AUTH8021X:-no}"; then
. "$SUBR_DIR/8021x"
diff --git a/src/connections/pppoe b/src/connections/pppoe
index 07eb9ae..ba9f67a 100644
--- a/src/connections/pppoe
+++ b/src/connections/pppoe
@@ -61,8 +61,8 @@ pppoe_down() {
PIDFILE="/var/run/ppp-$1.pid"
if [[ -e $PIDFILE ]]; then
- PID=$(cat "$PIDFILE")
- [[ -n "$PID" ]] && kill "$PID"
+ read PID < "$PIDFILE"
+ [[ "$PID" ]] && kill "$PID"
fi
rm "${cfg}"
diff --git a/src/connections/tunnel b/src/connections/tunnel
index 613cc67..67c7d9d 100644
--- a/src/connections/tunnel
+++ b/src/connections/tunnel
@@ -4,7 +4,7 @@
tunnel_up() {
load_profile "$1"
- if [ -e "/sys/class/net/$INTERFACE" ]; then
+ if [[ -e "/sys/class/net/$INTERFACE" ]]; then
report_fail "Interface $INTERFACE already exists."
exit 1
else
diff --git a/src/connections/tuntap b/src/connections/tuntap
index 27641e4..84b3bce 100644
--- a/src/connections/tuntap
+++ b/src/connections/tuntap
@@ -4,7 +4,7 @@
tuntap_up() {
load_profile "$1"
- if [ -e /sys/class/net/$INTERFACE ]; then
+ if [[ -e /sys/class/net/$INTERFACE ]]; then
report_fail "Interface $INTERFACE already exists."
exit 1
else
@@ -26,7 +26,7 @@ tuntap_down() {
}
tuntap_status() {
- if [ -e /sys/class/net/$INTERFACE ]; then
+ if [[ -e "/sys/class/net/$INTERFACE" ]]; then
return 0
else
return 1
diff --git a/src/connections/vlan b/src/connections/vlan
index 7b81e7f..97147c7 100644
--- a/src/connections/vlan
+++ b/src/connections/vlan
@@ -5,12 +5,12 @@ vlan_up() {
local vlan_interface
load_profile "$1"
- if [ -e /sys/class/net/$INTERFACE ]; then
+ if [[ -e "/sys/class/net/$INTERFACE" ]]; then
report_fail "Interface $INTERFACE already exists."
exit 1
else
- ip link set $VLAN_PHYS_DEV up
- ip link add link $VLAN_PHYS_DEV name $INTERFACE type vlan id $VLAN_ID >/dev/null 2>&1
+ ip link set "$VLAN_PHYS_DEV" up
+ ip link add link "$VLAN_PHYS_DEV" name "$INTERFACE" type vlan id "$VLAN_ID" >/dev/null 2>&1
fi
bring_interface up "$INTERFACE"
"$CONN_DIR/ethernet" up "$1"
@@ -23,12 +23,12 @@ vlan_down() {
"$CONN_DIR/ethernet" down "$1"
bring_interface down "$INTERFACE"
- ip link delete $INTERFACE >/dev/null 2>&1
+ ip link delete "$INTERFACE" >/dev/null 2>&1
return 0
}
vlan_status() {
- if [ -e /sys/class/net/$INTERFACE ]; then
+ if [[ -e "/sys/class/net/$INTERFACE" ]]; then
return 0
else
return 1
diff --git a/src/connections/wireless b/src/connections/wireless
index b19afde..f08ba43 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -27,7 +27,7 @@ wireless_up() {
# Start wpa_supplicant
WPA_CTRL_PATH=/run/wpa_supplicant
- if [ "$SECURITY" = "wpa-config" ]; then
+ if [[ "$SECURITY" = "wpa-config" ]]; then
WPA_CONF="${WPA_CONF:-/etc/wpa_supplicant.conf}"
# Use defined control path (FS#24949)
if grep "^ *ctrl_interface=" "$WPA_CONF" &>/dev/null; then
@@ -74,7 +74,7 @@ wireless_up() {
wpa-config)
;;
none|wep|wpa|wpa-configsection)
- echo -e "network={ \n$(make_wpa_config) \n}" >> "$WPA_CONF"
+ printf "%s\n" "network={" "$(make_wpa_config)" "}" >> "$WPA_CONF"
report_debug wireless_up "Configuration generated at $WPA_CONF"
;;
*)