Check if the user passed a valid interface

This commit is contained in:
oblique 2014-09-06 21:49:52 +03:00
parent 3fe8513d9a
commit f66819c145

View File

@ -82,6 +82,11 @@ version_cmp() {
USE_IWCONFIG=0
is_interface() {
[[ -z "$1" ]] && return 1
ip link show $1 > /dev/null 2>&1
}
is_wifi_interface() {
which iw > /dev/null 2>&1 && iw dev $1 info > /dev/null 2>&1 && return 0
if which iwconfig > /dev/null 2>&1 && iwconfig $1 > /dev/null 2>&1; then
@ -579,6 +584,11 @@ else
fi
fi
if [[ "$SHARE_METHOD" != "none" ]] && ! is_interface $INTERNET_IFACE; then
echo "ERROR: '${INTERNET_IFACE}' is not an interface" >&2
exit 1
fi
if [[ "$SHARE_METHOD" == "bridge" ]]; then
OLD_BRIDGE_IPTABLES=$(cat /proc/sys/net/bridge/bridge-nf-call-iptables)