diff options
-rw-r--r-- | src/devices/nm-device-ethernet.c | 21 | ||||
-rw-r--r-- | src/settings/nm-settings.c | 8 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 6225ae7bf6..7019c5f6b8 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <unistd.h> #include <errno.h> +#include <uuid/uuid.h> #include <gudev/gudev.h> @@ -1433,7 +1434,10 @@ new_default_connection (NMDevice *self) const GSList *connections; NMSetting *setting; const char *hw_address; - char *defname, *uuid; + gs_free char *defname = NULL; + gs_free char *uuid = NULL; + gs_free char *secret_key = NULL; + uuid_t machine_id; if (nm_config_get_no_auto_default_for_device (nm_config_get (), self)) return NULL; @@ -1448,7 +1452,18 @@ new_default_connection (NMDevice *self) connections = nm_connection_provider_get_connections (nm_connection_provider_get ()); defname = nm_device_ethernet_utils_get_default_wired_name (connections); - uuid = nm_utils_uuid_generate (); + if (!defname) + return NULL; + + if (nm_utils_get_machine_id (machine_id)) + secret_key = nm_utils_binary_to_hex (machine_id, sizeof (machine_id)); + + uuid = _nm_utils_uuid_generate_from_strings ("default-wired", + secret_key ?: "", + defname, + hw_address, + NULL); + g_object_set (setting, NM_SETTING_CONNECTION_ID, defname, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, @@ -1457,8 +1472,6 @@ new_default_connection (NMDevice *self) NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL); - g_free (uuid); - g_free (defname); /* Lock the connection to the device */ setting = nm_setting_wired_new (); diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 281f299f1f..3b8ac5b5df 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -1982,9 +1982,11 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self) g_object_unref (connection); if (!added) { - _LOGW ("(%s) couldn't create default wired connection: %s", - nm_device_get_iface (device), - error->message); + if (!g_error_matches (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_UUID_EXISTS)) { + _LOGW ("(%s) couldn't create default wired connection: %s", + nm_device_get_iface (device), + error->message); + } g_clear_error (&error); return; } |