The documentation[1] states: "If a matching configured network already exists, this will fail."
Unfortunately, it doesn't actually fail. Calling createNetwork with the same parameters multiple times in a row just causes it to repeatedly change the GUID of the already-configured network. The new GUID is passed to the createNetwork callback, and it is reflected in the getNetworks result. This can be easily verified by opening a JS console on chrome://settings/network .
Here is what I see happening:
- ManagedNetworkConfigurationHandlerImpl::CreateConfiguration() in Chrome generates a random GUID, then calls CreateShillConfiguration(). There is a TODO in this function that says that Chrome should check for duplicates first, but that code doesn't currently exist.
- NetworkConfigurationHandler::CreateShillConfiguration() makes doubly sure there's a non-empty GUID in the request.
- shill's ConfigureServiceForProfile handler looks up the GUID and finds nothing.
- shill looks up the service by (ssid,mode,security) and finds it.
- shill updates the existing service with the new GUID.
- shill sends an event to Chrome to indicate that the GUID property has changed.
One option is to perform the duplicate check in Chrome's CreateConfiguration, per the TODO. A disadvantage of this approach is that the check isn't atomic, so if somebody hammers Chrome with createNetwork() calls (for whatever insane reason), some of them might succeed in changing the GUID of an existing connection.
Another option is to change the semantics of the ConfigureServiceForProfile shill dbus method so that it atomically checks for duplicates, and fails if there is a (ssid,mode,security) match. This behavior could be gated by a new property. Or maybe we allow Chrome to pass in an empty or special GUID to tell shill how to handle that case.
Or, we can just update the docs to reflect the current behavior. This will require rewriting some of our ARC code, which was based on the documented API behavior. The ARC code may need to implement the racey "check before update" logic listed in the first option.
Your thoughts?
[1] https://developer.chrome.com/extensions/networkingPrivate#method-createNetwork
Comment 1 by quiche@chromium.org
, Mar 28 2016