unable to get WPA supplicant status via wpa-cli utility from a snap
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
wpa (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Hi
As a developer, while trying to get the wpa_supplicant status by using wpa_cli, it always returns a timeout from the snap context on Ubuntu Core 20.
The problem is not reproducible with Ubuntu Classic.
I did some further analysis to get strace output of `wpa_cli` as well as `wpa_supplicant` for the good (running wpa_cli from host terminal) and bad (running from snap context) cases.
Here is the strace output of the wpa_cli;
Good case:
```
bind(3, {sa_family=AF_UNIX, sun_path=
connect(3, {sa_family=AF_UNIX, sun_path=
fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
sendto(3, "STATUS", 6, 0, NULL, 0) = 6
pselect6(4, [3], NULL, NULL, {tv_sec=10, tv_nsec=0}, NULL) = 1 (in [3], left {tv_sec=9, tv_nsec=999998877})
recvfrom(3, "bssid=
newfstatat(1, "", {st_mode=
write(1, "bssid=
) = 24
write(1, "freq=5260\n", 10freq=5260
) = 10
write(1, "ssid=SUPERBOX_
) = 25
write(1, "id=0\n", 5id=0
) = 5
write(1, "mode=station\n", 13mode=station
) = 13
write(1, "wifi_generatio
) = 18
write(1, "pairwise_
) = 21
write(1, "group_
) = 18
write(1, "key_mgmt=
) = 18
write(1, "wpa_state=
) = 20
write(1, "ip_address=
) = 25
write(1, "p2p_device_
) = 37
write(1, "address=
) = 26
write(1, "uuid=962ca758-
) = 42
write(1, "ieee80211ac=1\n", 14ieee80211ac=1
) = 14
unlink(
close(3) = 0
exit_group(0) = ?
```
Bad case (running from the snap context)
```
getpid() = 58024
bind(3, {sa_family=AF_UNIX, sun_path=
connect(3, {sa_family=AF_UNIX, sun_path=
fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
sendto(3, "STATUS", 6, 0, NULL, 0) = 6
fstat(1, {st_mode=
unlink(
close(3) = 0
write(1, "'STATUS' command timed out.\n", 28'STATUS' command timed out.
) = 28
exit_group(-2) = ?
+++ exited with 254 +++
```
Here is the wpa_supplicant strace output;
For the good case, wpa_supplicant was able to send the message back to the wpa_cli;
```
pselect6(19, [4 5 7 9 10 11 13 14 15 16 17 18], [], [4], {tv_sec=9, tv_nsec=999997000}, NULL) = 1 (in [14], left {tv_sec=9, tv_nsec=281454971})
recvfrom(14, "STATUS", 8193, 0, {sa_family=AF_UNIX, sun_path=
getsockopt(14, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
ioctl(14, TIOCOUTQ, [0]) = 0
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 19
ioctl(19, SIOCGIFADDR, {ifr_name=
close(19) = 0
getsockopt(14, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
ioctl(14, TIOCOUTQ, [0]) = 0
sendto(14, "bssid=
pselect6(19, [4 5 7 9 10 11 13 14 15 16 17 18], [], [4], {tv_sec=9, tv_nsec=278742000}, NULL
```
However, for the bad case (where wpa_cli is called from the snap context), the data is available but while wpa_supplicant tries to send it, the socket is probably not visible since we got a no such a file error;
```
recvfrom(14, "STATUS", 8193, 0, {sa_family=AF_UNIX, sun_path=
getsockopt(14, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
ioctl(14, TIOCOUTQ, [0]) = 0
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 19
ioctl(19, SIOCGIFADDR, {ifr_name=
close(19) = 0
getsockopt(14, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
ioctl(14, TIOCOUTQ, [0]) = 0
sendto(14, "bssid=
getsockopt(14, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
ioctl(14, TIOCOUTQ, [0]) = 0
```
I dont see any denial for accessing to the unix socket and the same problem also occurs within devmode.
I'm assuming that since all of the snaps have their own `/tmp` directory, they may not be able to reach out to the `/tmp` of the host. Moreover, it seems like the wpa_cli also opens a unix socket that exist within the `/tmp` directory. Thus, we might be observing this behavior.
Could you please suggest a potential fixes?
Thanks,
Bugra
Status changed to 'Confirmed' because the bug affects multiple users.