From 77e3f5025fa16854924fdb1b9a066dd7ac9c833c Mon Sep 17 00:00:00 2001 From: Stan Domula Date: Wed, 3 May 2017 17:39:08 +0200 Subject: [PATCH 1/5] add option to disable dnsmasq handling --- create_ap | 19 +++++++++++++------ create_ap.conf | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/create_ap b/create_ap index 1beaa9e..e840263 100755 --- a/create_ap +++ b/create_ap @@ -610,6 +610,7 @@ ETC_HOSTS=0 ADDN_HOSTS= DHCP_DNS=gateway NO_DNS=0 +NO_DNSMASQ=0 HIDDEN=0 MAC_FILTER=0 MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept @@ -631,7 +632,7 @@ USE_PSK=0 HOSTAPD_DEBUG_ARGS= REDIRECT_TO_LOCALHOST=0 -CONFIG_OPTS=(CHANNEL GATEWAY WPA_VERSION ETC_HOSTS DHCP_DNS NO_DNS HIDDEN MAC_FILTER MAC_FILTER_ACCEPT ISOLATE_CLIENTS +CONFIG_OPTS=(CHANNEL GATEWAY WPA_VERSION ETC_HOSTS DHCP_DNS NO_DNS NO_DNSMASQ HIDDEN MAC_FILTER MAC_FILTER_ACCEPT ISOLATE_CLIENTS SHARE_METHOD IEEE80211N IEEE80211AC HT_CAPAB VHT_CAPAB DRIVER NO_VIRT COUNTRY FREQ_BAND NEW_MACADDR DAEMONIZE NO_HAVEGED WIFI_IFACE INTERNET_IFACE SSID PASSPHRASE USE_PSK) @@ -1025,7 +1026,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","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","mkconfig:","config:" -n "$PROGNAME" -- "$@") +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","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" @@ -1176,6 +1177,10 @@ while :; do shift NO_DNS=1 ;; + --no-dnsmasq) + shift + NO_DNSMASQ=1 + ;; --redirect-to-localhost) shift REDIRECT_TO_LOCALHOST=1 @@ -1652,7 +1657,7 @@ fi if [[ "$SHARE_METHOD" == "bridge" ]]; then echo "bridge=${BRIDGE_IFACE}" >> $CONFDIR/hostapd.conf -else +elif [[ $NO_DNSMASQ -eq 0 ]]; then # dnsmasq config (dhcp + dns) DNSMASQ_VER=$(dnsmasq -v | grep -m1 -oE '[0-9]+(\.[0-9]+)*\.[0-9]+') version_cmp $DNSMASQ_VER 2.63 @@ -1806,9 +1811,11 @@ if [[ "$SHARE_METHOD" != "bridge" ]]; then complain dnsmasq fi - umask 0033 - dnsmasq -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid -l $CONFDIR/dnsmasq.leases -p $DNS_PORT || die - umask $SCRIPT_UMASK + if [[ $NO_DNSMASQ -eq 0 ]]; then + umask 0033 + dnsmasq -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid -l $CONFDIR/dnsmasq.leases -p $DNS_PORT || die + umask $SCRIPT_UMASK + fi fi # start access point diff --git a/create_ap.conf b/create_ap.conf index 940ea2d..9f55f09 100644 --- a/create_ap.conf +++ b/create_ap.conf @@ -4,6 +4,7 @@ WPA_VERSION=2 ETC_HOSTS=0 DHCP_DNS=gateway NO_DNS=0 +NO_DNSMASQ=0 HIDDEN=0 MAC_FILTER=0 MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept From c9b46b213b636d49fb830fdc3578d743332be49e Mon Sep 17 00:00:00 2001 From: Stan Domula Date: Thu, 4 May 2017 11:04:12 +0200 Subject: [PATCH 2/5] add usage for --no-dnsmasq --- create_ap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/create_ap b/create_ap index e840263..95f835f 100755 --- a/create_ap +++ b/create_ap @@ -56,6 +56,8 @@ usage() { echo " --driver Choose your WiFi adapter driver (default: nl80211)" echo " --no-virt Do not create virtual interface" echo " --no-haveged Do not run 'haveged' automatically when needed" + echo " --no-dnsmasq Do not run 'dnsmasq'. Iptables and interfaces for sharing" + echo " the internet connection are still handled automatically." echo " --fix-unmanaged If NetworkManager shows your interface as unmanaged after you" echo " close create_ap, then use this option to switch your interface" echo " back to managed" From a09cf82d1d166b512bc7dadafcb3aeb03aa976ef Mon Sep 17 00:00:00 2001 From: Stan Domula Date: Thu, 4 May 2017 11:08:22 +0200 Subject: [PATCH 3/5] make --no-dnsmasq usage text shorter --- create_ap | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/create_ap b/create_ap index 95f835f..24138a6 100755 --- a/create_ap +++ b/create_ap @@ -56,8 +56,7 @@ usage() { echo " --driver Choose your WiFi adapter driver (default: nl80211)" echo " --no-virt Do not create virtual interface" echo " --no-haveged Do not run 'haveged' automatically when needed" - echo " --no-dnsmasq Do not run 'dnsmasq'. Iptables and interfaces for sharing" - echo " the internet connection are still handled automatically." + echo " --no-dnsmasq Do not run 'dnsmasq'" echo " --fix-unmanaged If NetworkManager shows your interface as unmanaged after you" echo " close create_ap, then use this option to switch your interface" echo " back to managed" From e23fa72487c955664f6ce5033e650533485f9425 Mon Sep 17 00:00:00 2001 From: Stan Domula Date: Thu, 4 May 2017 13:44:01 +0200 Subject: [PATCH 4/5] setting no-dnsmasq will implicitly set no-dns --- create_ap | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/create_ap b/create_ap index 24138a6..18b69bd 100755 --- a/create_ap +++ b/create_ap @@ -56,7 +56,6 @@ usage() { echo " --driver Choose your WiFi adapter driver (default: nl80211)" echo " --no-virt Do not create virtual interface" echo " --no-haveged Do not run 'haveged' automatically when needed" - echo " --no-dnsmasq Do not run 'dnsmasq'" echo " --fix-unmanaged If NetworkManager shows your interface as unmanaged after you" echo " close create_ap, then use this option to switch your interface" echo " back to managed" @@ -76,6 +75,7 @@ usage() { echo echo "Non-Bridging Options:" echo " --no-dns Disable dnsmasq DNS server" + echo " --no-dnsmasq Disable dnsmasq server completely" echo " -g IPv4 Gateway for the Access Point (default: 192.168.12.1)" echo " -d DNS server will take into account /etc/hosts" echo " -e DNS server will take into account additional hosts file" @@ -1181,6 +1181,7 @@ while :; do --no-dnsmasq) shift NO_DNSMASQ=1 + NO_DNS=1 ;; --redirect-to-localhost) shift @@ -1804,15 +1805,16 @@ if [[ "$SHARE_METHOD" != "bridge" ]]; then else DNS_PORT=0 fi - iptables -w -I INPUT -p udp -m udp --dport 67 -j ACCEPT || die - - if which complain > /dev/null 2>&1; then - # openSUSE's apparmor does not allow dnsmasq to read files. - # remove restriction. - complain dnsmasq - fi if [[ $NO_DNSMASQ -eq 0 ]]; then + iptables -w -I INPUT -p udp -m udp --dport 67 -j ACCEPT || die + + if which complain > /dev/null 2>&1; then + # openSUSE's apparmor does not allow dnsmasq to read files. + # remove restriction. + complain dnsmasq + fi + umask 0033 dnsmasq -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid -l $CONFDIR/dnsmasq.leases -p $DNS_PORT || die umask $SCRIPT_UMASK From 49392a34726feee10d365eea4b8726797f17d749 Mon Sep 17 00:00:00 2001 From: Stan Domula Date: Mon, 8 May 2017 10:39:47 +0200 Subject: [PATCH 5/5] check for NO_DNSMASQ after config loading Signed-off-by: Stan Domula --- create_ap | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/create_ap b/create_ap index 18b69bd..81fbd59 100755 --- a/create_ap +++ b/create_ap @@ -1181,7 +1181,6 @@ while :; do --no-dnsmasq) shift NO_DNSMASQ=1 - NO_DNS=1 ;; --redirect-to-localhost) shift @@ -1236,6 +1235,11 @@ if [[ $# -lt 1 && $FIX_UNMANAGED -eq 0 && -z "$STOP_ID" && exit 1 fi +# Set NO_DNS, if dnsmasq is disabled +if [[ $NO_DNSMASQ -eq 1 ]]; then + NO_DNS=1 +fi + trap "cleanup_lock" EXIT if ! init_lock; then