From f66819c145dbc90bb8000e81ad3a89877e1f3a42 Mon Sep 17 00:00:00 2001 From: oblique Date: Sat, 6 Sep 2014 21:49:52 +0300 Subject: [PATCH] Check if the user passed a valid interface --- create_ap | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/create_ap b/create_ap index da6c5aa..bf5460a 100755 --- a/create_ap +++ b/create_ap @@ -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)