Steps to reproduce
- Start AP with custom DNS servers
- Check the generated config:
cat /data/local/virtualap/run/dnsmasq.conf
Logs
The log in app shows:
Auto upstream: table wlan0 (wlan0)
Creating virtual AP interface 'ap0' on wlan0...
Configuring gateway address 192.168.42.1...
Installing routes and policy rules...
Network configuration completed.
Generating service configs (band 2GHz, channel 5)...
/data/user/0/com.virtualap.app/files/backend/start-ap[1108]: /data/local/virtualap/bin/busybox echo: inaccessible or not found
/data/user/0/com.virtualap.app/files/backend/start-ap[1108]: /data/local/virtualap/bin/busybox tr: inaccessible or not found
Starting hostapd (2GHz ch 5, 20MHz)...
hostapd running (PID 12836, 20MHz)
Starting dnsmasq...
dnsmasq running (PID 12884)
VirtualAP is ACTIVE!
SSID : execve (2GHz, channel 5, 20MHz)
Gateway : 192.168.42.1 (static - never changes)
Upstream: wlan0 (table wlan0)
/data/local/virtualap/run/dnsmasq.conf
❯ sudo cat /data/local/virtualap/run/dnsmasq.conf
interface=ap0
bind-interfaces
except-interface=lo
listen-address=192.168.42.1
dhcp-range=192.168.42.10,192.168.42.50,12h
dhcp-option=option:router,192.168.42.1
dhcp-option=option:dns-server,192.168.42.1
dhcp-leasefile=/data/local/virtualap/run/dnsmasq.leases
no-resolv
no-hosts
pid-file=/data/local/virtualap/run/dnsmasq.pid
user=root
log-facility=/data/local/virtualap/logs/dnsmasq.log
log-dhcp
Logs show busybox alias errors
start-ap[1108]: /data/local/virtualap/bin/busybox echo: inaccessible or not found start-ap[1108]: /data/local/virtualap/bin/busybox tr: inaccessible or not found
Root cause
start_services() uses:
ECHO="$BB echo"
TR="$BB tr"
...
clean_dns=$($ECHO "$dns" | $TR -d '[:space:]')
which treats '/data/local/virtualap/bin/busybox tr' as a single command path.
What had I tested
I have tested with this script which can reproduce it.
#!/system/bin/sh
BUSYBOX="/data/local/virtualap/bin/busybox"
BB="$BUSYBOX"
TR="$BB tr"
ECHO="$BB echo"
DNS_SERVERS="1.1.1.1,8.8.8.8"
echo "=======before======"
IFS=","
for dns in $DNS_SERVERS; do
clean_dns=$($ECHO "$dns" | $TR -d '[:space:]')
done
echo "=======after======"
IFS=","
for dns in $DNS_SERVERS; do
echo " dns=[$dns]"
clean_dns=$("$BB" echo "$dns" | "$BB" tr -d '[:space:]')
echo " clean_dns=[$clean_dns]"
done
The result
❯ sudo bash test.sh
=======before======
test.sh: line 13: /data/local/virtualap/bin/busybox echo: No such file or directory
test.sh: line 13: /data/local/virtualap/bin/busybox tr: No such file or directory
test.sh: line 13: /data/local/virtualap/bin/busybox echo: No such file or directory
test.sh: line 13: /data/local/virtualap/bin/busybox tr: No such file or directory
=======after======
dns=[1.1.1.1]
clean_dns=[1.1.1.1]
dns=[8.8.8.8]
clean_dns=[8.8.8.8]
Suggested fix
# Before:
clean_dns=$($ECHO "$dns" | $TR -d '[:space:]')
# After:
clean_dns=$("$BB" echo "$dns" | "$BB" tr -d '[:space:]')
Steps to reproduce
cat /data/local/virtualap/run/dnsmasq.confLogs
The log in app shows:
/data/local/virtualap/run/dnsmasq.conf
Logs show busybox alias errors
start-ap[1108]: /data/local/virtualap/bin/busybox echo: inaccessible or not found start-ap[1108]: /data/local/virtualap/bin/busybox tr: inaccessible or not found
Root cause
start_services()uses:which treats '/data/local/virtualap/bin/busybox tr' as a single command path.
What had I tested
I have tested with this script which can reproduce it.
The result
Suggested fix