diff options
author | Thomas Haller <thaller@redhat.com> | 2014-11-28 12:53:04 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-12-04 17:02:22 +0100 |
commit | b15994679882805f29403d9635bc0913f37e683d (patch) | |
tree | cb4aa8edf9ea99bcc75b8890e8e68b67a05c5fcf | |
parent | 9a08d8602c8775e3fd6e203b89900ba579bcce9b (diff) | |
download | NetworkManager-b15994679882805f29403d9635bc0913f37e683d.tar.gz |
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.
-rw-r--r-- | src/settings/plugins/ibft/reader.c | 15 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/reader.c | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c index ebac9607ac..066a79f25e 100644 --- a/src/settings/plugins/ibft/reader.c +++ b/src/settings/plugins/ibft/reader.c @@ -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, diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c index 9dc0a7b4aa..1d2ecdad9b 100644 --- a/src/settings/plugins/keyfile/reader.c +++ b/src/settings/plugins/keyfile/reader.c @@ -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); } |