mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 14:20:16 +01:00
settings: change algorithm for UUID generation based on strings
In several cases, connection uuids are generated based on some strings. Change the algorithm, to prefix the hashed identifier differently for each setting type. This makes collisions very unlikely. Also, change the algorithm, to create proper Variant3 UUIDs. This is a behavioral change, but it only affects code places that were added since nm-0-9-10 and were not yet part of a stable release.
This commit is contained in:
parent
9a08d8602c
commit
b159946798
2 changed files with 9 additions and 8 deletions
|
|
@ -384,7 +384,7 @@ connection_setting_add (const GPtrArray *block,
|
|||
GError **error)
|
||||
{
|
||||
NMSetting *s_con;
|
||||
char *id, *uuid, *uuid_data;
|
||||
char *id, *uuid;
|
||||
const char *s_hwaddr = NULL, *s_ip4addr = NULL, *s_vlanid;
|
||||
|
||||
if (!parse_ibft_config (block, error,
|
||||
|
|
@ -404,12 +404,13 @@ connection_setting_add (const GPtrArray *block,
|
|||
prefix ? prefix : "",
|
||||
iface);
|
||||
|
||||
uuid_data = g_strdup_printf ("%s%s%s",
|
||||
s_vlanid ? s_vlanid : "0",
|
||||
s_hwaddr,
|
||||
s_ip4addr ? s_ip4addr : "DHCP");
|
||||
uuid = nm_utils_uuid_generate_from_string (uuid_data, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
|
||||
g_free (uuid_data);
|
||||
uuid = nm_utils_uuid_generate_from_strings ("ibft",
|
||||
s_hwaddr,
|
||||
s_vlanid ? "V" : "v",
|
||||
s_vlanid ? s_vlanid : "",
|
||||
s_ip4addr ? "A" : "DHCP",
|
||||
s_ip4addr ? s_ip4addr : "",
|
||||
NULL);
|
||||
|
||||
s_con = nm_setting_connection_new ();
|
||||
g_object_set (s_con,
|
||||
|
|
|
|||
|
|
@ -1316,7 +1316,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
|
|||
if (!nm_setting_connection_get_uuid (s_con)) {
|
||||
char *hashed_uuid;
|
||||
|
||||
hashed_uuid = nm_utils_uuid_generate_from_string (filename, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
|
||||
hashed_uuid = nm_utils_uuid_generate_from_strings ("keyfile", filename, NULL);
|
||||
g_object_set (s_con, NM_SETTING_CONNECTION_UUID, hashed_uuid, NULL);
|
||||
g_free (hashed_uuid);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue