summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-04-26 19:05:54 +0200
committerThomas Haller <thaller@redhat.com>2017-04-26 21:14:13 +0200
commitbd21d1054a692692a2a80b1f44e45df85abe21ad (patch)
tree1adabf325071f55198296da1d10dcc4ad075d24a
parent1c06d66a056b6a31e01ad3c91a15e80f3ba79078 (diff)
downloadNetworkManager-bd21d1054a692692a2a80b1f44e45df85abe21ad.tar.gz
device: fix restricting Generic connection by interface-name
NMDeviceGeneric:check_connection_compatible() doesn't check for a matching interface name. It relies on the parent implementation to do that. The parent implementation calls nm_manager_get_connection_iface(). That fails for NM_SETTING_GENERIC_SETTING_NAME, because that one has no factory. Maybe this imbalance of having no factory for the Generic device is wrong, but usually factories only match a distinct set of device types, while the generic factory would handle them all (as last resort). Without this, activating a generic connection might activate the wrong interface. (cherry picked from commit 3876b10a4749638c3dcfa7e65b12bfee8030334c) (cherry picked from commit 753a2cc4d9c4bbf9ad6833ff0f073883ea3de7a0) (cherry picked from commit bd72919b476eb4f6eeb41fa22b34422576fd0eed)
-rw-r--r--src/nm-manager.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index ebcd8a0787..1d56aee8ed 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1104,6 +1104,11 @@ nm_manager_get_connection_iface (NMManager *self,
factory = nm_device_factory_manager_find_factory_for_connection (connection);
if (!factory) {
+ if (nm_streq0 (nm_connection_get_connection_type (connection), NM_SETTING_GENERIC_SETTING_NAME)) {
+ /* the generic type doesn't have a factory. */
+ goto return_ifname_fom_connection;
+ }
+
g_set_error (error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_FAILED,
@@ -1115,15 +1120,7 @@ nm_manager_get_connection_iface (NMManager *self,
if ( !out_parent
&& !NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_connection_iface) {
/* optimization. Shortcut lookup of the partent device. */
- iface = g_strdup (nm_connection_get_interface_name (connection));
- if (!iface) {
- g_set_error (error,
- NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_FAILED,
- "failed to determine interface name: error determine name for %s",
- nm_connection_get_connection_type (connection));
- }
- return iface;
+ goto return_ifname_fom_connection;
}
parent = find_parent_device_for_connection (self, connection, factory);
@@ -1137,6 +1134,17 @@ nm_manager_get_connection_iface (NMManager *self,
if (out_parent)
*out_parent = parent;
return iface;
+
+return_ifname_fom_connection:
+ iface = g_strdup (nm_connection_get_interface_name (connection));
+ if (!iface) {
+ g_set_error (error,
+ NM_MANAGER_ERROR,
+ NM_MANAGER_ERROR_FAILED,
+ "failed to determine interface name: error determine name for %s",
+ nm_connection_get_connection_type (connection));
+ }
+ return iface;
}
/**