core: fix crash with bluetooth device factory wrongly claiming NAP connection

The bluetooth device *never* manages NAP connection. Hence, checking for
nm_bt_vtable_network_server in "nm-bluez-manager.c" is wrong.
Especially, because nm_bt_vtable_network_server is only initialized
much later, so during initial start, the bluetooth factory would wronly
claim to support it. This leads to a crash when having a NAP connection.

Also, the bridge factory requires the bluetooth plugin. It should only
claim to support NAP when the bluetooth plugin is present. That
way, we get a proper "missing plugin" error message, instead of failing
later during activation.

It seems to me, distributing the logic to various match_connection()
functions makes it more complicated, because the implementation is
spread out and interact in complicated ways. Anyway.

Fixes: 8665cdfeff
This commit is contained in:
Thomas Haller 2017-08-06 07:50:48 +02:00
parent 220a329fea
commit a7aca2ab08
2 changed files with 12 additions and 4 deletions

View file

@ -426,8 +426,7 @@ match_connection (NMDeviceFactory *factory,
nm_assert (nm_streq (type, NM_SETTING_BLUETOOTH_SETTING_NAME));
if ( nm_bt_vtable_network_server
&& _nm_connection_get_setting_bluetooth_for_nap (connection))
if (_nm_connection_get_setting_bluetooth_for_nap (connection))
return FALSE; /* handled by the bridge factory */
return TRUE;

View file

@ -549,8 +549,17 @@ match_connection (NMDeviceFactory *factory,
nm_assert (nm_streq (type, NM_SETTING_BLUETOOTH_SETTING_NAME));
return nm_bt_vtable_network_server
&& _nm_connection_get_setting_bluetooth_for_nap (connection);
if (!_nm_connection_get_setting_bluetooth_for_nap (connection))
return FALSE;
if (!g_type_from_name ("NMBluezManager")) {
/* bluetooth NAP connections are handled by bridge factory. However,
* it needs help from the bluetooth plugin, so if the plugin is not loaded,
* we claim not to support it. */
return FALSE;
}
return TRUE;
}
NM_DEVICE_FACTORY_DEFINE_INTERNAL (BRIDGE, Bridge, bridge,