network: Fixed Network profiles shown on wrong device

Added missing interface name during network profile creation.

Fixes #353

Fixed issues from code review
This commit is contained in:
Luciano da Silva Ribas 2022-09-22 23:00:24 -03:00 committed by Felipe Borges
parent 36cb48ad49
commit ee53bfd8b6

View file

@ -395,8 +395,10 @@ add_profile_button_clicked_cb (NetDeviceEthernet *self)
NMSettingConnection *sc;
g_autofree gchar *uuid = NULL;
g_autofree gchar *id = NULL;
g_autoptr(GError) error = NULL;
NetConnectionEditor *editor;
const GPtrArray *connections;
const char *iface;
connection = nm_simple_connection_new ();
sc = NM_SETTING_CONNECTION (nm_setting_connection_new ());
@ -414,6 +416,16 @@ add_profile_button_clicked_cb (NetDeviceEthernet *self)
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
NULL);
iface = nm_device_get_iface (self->device);
if (nm_utils_is_valid_iface_name (iface, &error)) {
g_object_set (sc,
NM_SETTING_CONNECTION_INTERFACE_NAME, iface,
NULL);
} else {
g_warning ("Invalid interface Name '%s': %s", iface, error->message);
g_error_free (error);
}
nm_connection_add_setting (connection, nm_setting_wired_new ());
editor = net_connection_editor_new (connection, self->device, NULL, self->client);