iwd: fix iwd autoconnect being set wrongly on new connections
Due to an extremely subtle bug in tracking the autoconnect state from
connman on through to iwd, iwd was incorrectly being sent zero-initialized
default data as the autoconnect value.
In particular, what happened is as follows:
- A new iwd_network is created for the iwd.Network that appears, which
also creates an associated connman_network. In the process of creating
the connman_network, the iwd plugin receives a callback that correctly
sets the cm_autoconnect state of the iwd_network.
- Connman's Service.Connect() function is called via D-Bus, which calls
into the iwd plugin, which in turn calls iwd.Network.Connect() over
D-Bus.
- The connection completes and the following fire:
- iwd.KnownNetwork created event, which is supposed to initialize the
cm_autoconnect state to that of the iwd_network, but this does not
occur since the iwd_network does not yet have a KnownNetwork
associated, so it remains uninitialized
- PropertyChanged event on the corresponding iwd.Network object,
with the new KnownNetwork property value, springing the trap set
earlier by synchronizing the zero-initialized
iwd_known_network.cm_autoconnect state to the iwd KnownNetwork
In practice, this looks like:
-> net.connman.iwd.Network.Connect() on /net/connman/iwd/0/3/0000000000000000000000_psk
<- RequestPassphrase()
-> (passphrase)
-> Set('AutoConnect', False) on /net/connman/iwd/0000000000000000000000_psk
This was found by investigating why my computer was not automatically
connecting to some networks after coming out of sleep, and finding that
the iwd AutoConnect setting was false on those networks while connman
thought it was true (in fact, this was the case! The connman iwd plugin
thought otherwise).
Reproduction:
connmanctl> agent on
Agent registered
connmanctl> config wifi_9cb6d0f7daaf_00000000_managed_psk --remove
connmanctl> connect wifi_9cb6d0f7daaf_00000000_managed_psk
Agent RequestInput wifi_9cb6d0f7daaf_00000000_managed_psk
Passphrase = [ Type=psk, Requirement=mandatory ]
Passphrase? 00000000
Connected wifi_9cb6d0f7daaf_00000000_managed_psk
$ busctl get-property net.connman.iwd /net/connman/iwd/00000000_psk net.connman.iwd.KnownNetwork AutoConnect
b false
Then sleep the machine and observe that the network is not automatically
reconnected.
1 file changed