From bae89dae0f00062ac60e05a3d30f18f135f8e254 Mon Sep 17 00:00:00 2001 From: Mathias Sass Michno Date: Wed, 6 Oct 2021 13:30:16 +0200 Subject: [PATCH 1/2] Add --hostapd-timestamps options to create_ap --- src/scripts/create_ap | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/scripts/create_ap b/src/scripts/create_ap index a2fa05a..5c7e266 100755 --- a/src/scripts/create_ap +++ b/src/scripts/create_ap @@ -46,6 +46,7 @@ usage() { echo " --mac-filter-accept Location of MAC address filter list (defaults to /etc/hostapd/hostapd.accept)" echo " --redirect-to-localhost If -n is set, redirect every web request to localhost (useful for public information networks)" echo " --hostapd-debug With level between 1 and 2, passes arguments -d or -dd to hostapd for debugging." + echo " --hostapd-timestamps Include timestamps in hostapd debug messages." echo " --isolate-clients Disable communication between clients" echo " --ieee80211n Enable IEEE 802.11n (HT)" echo " --ieee80211ac Enable IEEE 802.11ac (VHT)" @@ -1054,7 +1055,7 @@ for ((i=0; i<$#; i++)); do fi done -GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","redirect-to-localhost","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","pidfile:","logfile:","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq","mkconfig:","config:" -n "$PROGNAME" -- "$@") +GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","hostapd-timestamps","redirect-to-localhost","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","pidfile:","logfile:","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq","mkconfig:","config:" -n "$PROGNAME" -- "$@") [[ $? -ne 0 ]] && exit 1 eval set -- "$GETOPT_ARGS" @@ -1229,15 +1230,19 @@ while :; do --hostapd-debug) shift if [ "x$1" = "x1" ]; then - HOSTAPD_DEBUG_ARGS="-d" + HOSTAPD_DEBUG_ARGS+="-d " elif [ "x$1" = "x2" ]; then - HOSTAPD_DEBUG_ARGS="-dd" + HOSTAPD_DEBUG_ARGS+="-dd " else printf "Error: argument for --hostapd-debug expected 1 or 2, got %s\n" "$1" exit 1 fi shift ;; + --hostapd-timestamps) + shift + HOSTAPD_DEBUG_ARGS+="-t " + ;; --mkconfig) shift STORE_CONFIG="$1" From 3b24457d26a39ac42e5cf9d13e7a9a1d8aee5a77 Mon Sep 17 00:00:00 2001 From: Mathias Sass Michno Date: Thu, 7 Oct 2021 21:38:18 +0200 Subject: [PATCH 2/2] Check if root before initializing lock in create_ap If create_ap was executed without root it would initialize the /tmp/create_ap.all.lock with wrong ownership. This required the user to manually delete the lock before being able to run create_ap again. --- src/scripts/create_ap | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/scripts/create_ap b/src/scripts/create_ap index 5c7e266..3bb2292 100755 --- a/src/scripts/create_ap +++ b/src/scripts/create_ap @@ -14,7 +14,7 @@ # dnsmasq # iptables -VERSION=0.4.6 +VERSION=0.4.7 PROGNAME="$(basename $0)" # make sure that all command outputs are in english @@ -1287,6 +1287,11 @@ fi trap "cleanup_lock" EXIT +if [[ $(id -u) -ne 0 ]]; then + echo "create_ap must be run as root." >&2 + exit 1 +fi + if ! init_lock; then echo "ERROR: Failed to initialize lock" >&2 exit 1 @@ -1311,11 +1316,6 @@ if [[ -n "$LIST_CLIENTS_ID" ]]; then exit 0 fi -if [[ $(id -u) -ne 0 ]]; then - echo "create_ap must be run as root." >&2 - exit 1 -fi - if [[ -n "$STOP_ID" ]]; then echo "Trying to kill $PROGNAME instance associated with $STOP_ID..." send_stop "$STOP_ID"