awilliams / wifi-presence

Presence detection on OpenWrt routers using connect/disconnect events of WiFi clients. Events are published to MQTT with Home Assistant integration.
MIT License
64 stars 8 forks source link

daemon.err wifi-presence[6693]: Error: unable to connect to hostapd control socket "/var/run/hostapd/wlan0": ping error: read error from "PING" command: read unixgram /tmp/wp.wlan0->/var/run/hostapd/wlan0: i/o timeout #10

Open pablomarquesmendez opened 1 year ago

pablomarquesmendez commented 1 year ago

Hello there

I get this error in the logs when I start wifi-presence:

daemon.err wifi-presence[6693]: Error: unable to connect to hostapd control socket "/var/run/hostapd/wlan0": ping error: read error from "PING" command: read unixgram /tmp/wp.wlan0->/var/run/hostapd/wlan0: i/o timeout

ls -lrt /var/run/hostapd/

srwxrwx--- 1 network network 0 Oct 23 17:45 global srwxrwx--- 1 network network 0 Oct 23 17:45 wlan0 srwxrwx--- 1 network network 0 Oct 23 17:45 wlan1

pablomarquesmendez commented 1 year ago

something to do with ujail

pablomarquesmendez commented 1 year ago

Temporary solution, delete or move /etc/capabilities/wpad.json file: root@OpenWrt:~# mv /etc/capabilities/wpad.json ./

awilliams commented 1 year ago

Please try running wifi-presence using ujail with the same configuration options as hostapd.

For example, on my OS I see hostapd being run with these settings:

# ps w | grep hostapd | grep ujail
 1575 root      2656 S    {hostapd} /sbin/ujail -t 5 -n hostapd -U network -G network -C /etc/capabilities/wpad.json -c -- /usr/sbi

I'm then able to run wifi-presence in a similar way:

# /sbin/ujail -U network -G network -C /etc/capabilities/wpad.json -n wifi-presence /tmp/wifi-presence -mqtt.addr=tcp://mosquitto:1883 -verbose=1

Once there's more documentation for ujail I'll work on incorporating this into the run script.

Thanks for the bug report.

Ordspilleren commented 1 year ago

I also ran intro this issue and discovered that simply running the service as the network user solves the problem by adding procd_set_param user network to the init file.

Alternatively, running wifi-presence in a jail with the same capabilities as hostapd also seems to solve the issue:

procd_add_jail fdfd log requirejail
procd_set_param capabilities /etc/capabilities/wpad.json
presidentio commented 1 year ago

I have the same issue

presidentio commented 1 year ago

Seems like this issue is fixed in the latest version(0.3.0)

aiac commented 1 year ago

Even at 0.3.0 I had to do the procd_set_param user network trick in /etc/init.d/wifi-presence