From 0b87fde89cd6030681e984f2cf31177f378d7f90 Mon Sep 17 00:00:00 2001 From: Vladimir Kirillov Date: Tue, 12 Apr 2016 18:13:43 +0300 Subject: [PATCH] Try to detect hostapd early to prevent passing zero arguments to strings In case hostapd is not installed, strings got stuck trying to read stdin. --- create_ap | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/create_ap b/create_ap index 2c70285..4ab74b4 100755 --- a/create_ap +++ b/create_ap @@ -1292,8 +1292,15 @@ if ! can_be_sta_and_ap ${WIFI_IFACE}; then fi fi +HOSTAPD=$(which hostapd) + +if ! -x "$HOSTAPD"; then + echo "ERROR: hostapd not found." >&2 + exit 1 +fi + if [[ $(get_adapter_kernel_module ${WIFI_IFACE}) =~ ^(8192[cd][ue]|8723a[sue])$ ]]; then - if ! strings $(which hostapd) | grep -m1 rtl871xdrv > /dev/null 2>&1; then + if ! strings "$HOSTAPD" | grep -m1 rtl871xdrv > /dev/null 2>&1; then echo "ERROR: You need to patch your hostapd with rtl871xdrv patches." >&2 exit 1 fi @@ -1773,7 +1780,7 @@ if [[ $NO_HAVEGED -eq 0 ]]; then fi # start hostapd (use stdbuf for no delayed output in programs that redirect stdout) -stdbuf -oL hostapd $HOSTAPD_DEBUG_ARGS $CONFDIR/hostapd.conf & +stdbuf -oL $HOSTAPD $HOSTAPD_DEBUG_ARGS $CONFDIR/hostapd.conf & HOSTAPD_PID=$! echo $HOSTAPD_PID > $CONFDIR/hostapd.pid