mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 04:28:29 +02:00
glib-aux: rename nm_uuid_generate_from_strings() to nm_uuid_generate_from_strings_v3()
nm_uuid_generate_from_strings() uses variant3 UUIDs based on MD5. We shouldn't use that in the future. We will add a replacement, so rename this function so that the "good" name is free again. Of course, code that uses this function currently relies on that the behavior doesn't change. We cannot just drop it entirely, but will replace it by something that gives the same result. Rename.
This commit is contained in:
parent
ee32de41cf
commit
2fcea1cf05
7 changed files with 35 additions and 35 deletions
|
|
@ -1725,11 +1725,11 @@ new_default_connection(NMDevice *self)
|
||||||
|
|
||||||
/* Create a stable UUID. The UUID is also the Network_ID for stable-privacy addr-gen-mode,
|
/* Create a stable UUID. The UUID is also the Network_ID for stable-privacy addr-gen-mode,
|
||||||
* thus when it changes we will also generate different IPv6 addresses. */
|
* thus when it changes we will also generate different IPv6 addresses. */
|
||||||
uuid = nm_uuid_generate_from_strings("default-wired",
|
uuid = nm_uuid_generate_from_strings_v3("default-wired",
|
||||||
nm_utils_machine_id_str(),
|
nm_utils_machine_id_str(),
|
||||||
defname,
|
defname,
|
||||||
perm_hw_addr ?: iface,
|
perm_hw_addr ?: iface,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_object_set(setting,
|
g_object_set(setting,
|
||||||
NM_SETTING_CONNECTION_ID,
|
NM_SETTING_CONNECTION_ID,
|
||||||
|
|
|
||||||
|
|
@ -2296,7 +2296,7 @@ test_read_missing_id_uuid(void)
|
||||||
gs_free char *expected_uuid = NULL;
|
gs_free char *expected_uuid = NULL;
|
||||||
const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID";
|
const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID";
|
||||||
|
|
||||||
expected_uuid = nm_uuid_generate_from_strings("keyfile", FILENAME, NULL);
|
expected_uuid = nm_uuid_generate_from_strings_v3("keyfile", FILENAME, NULL);
|
||||||
|
|
||||||
connection = keyfile_read_connection_from_file(FILENAME);
|
connection = keyfile_read_connection_from_file(FILENAME);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3800,7 +3800,7 @@ nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallback_uuid_
|
||||||
if (nm_setting_connection_get_uuid(s_con))
|
if (nm_setting_connection_get_uuid(s_con))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
hashed_uuid = nm_uuid_generate_from_strings("keyfile", fallback_uuid_seed, NULL);
|
hashed_uuid = nm_uuid_generate_from_strings_v3("keyfile", fallback_uuid_seed, NULL);
|
||||||
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, hashed_uuid, NULL);
|
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, hashed_uuid, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7946,7 +7946,7 @@ test_nm_utils_uuid_generate_from_string(void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
__test_uuid(const char *expected_uuid, const char *str, gssize slen, char *uuid_test)
|
_check_uuid_v3(const char *expected_uuid, const char *str, gssize slen, char *uuid_test)
|
||||||
{
|
{
|
||||||
g_assert(uuid_test);
|
g_assert(uuid_test);
|
||||||
g_assert(nm_uuid_is_normalized(uuid_test));
|
g_assert(nm_uuid_is_normalized(uuid_test));
|
||||||
|
|
@ -7975,8 +7975,8 @@ __test_uuid(const char *expected_uuid, const char *str, gssize slen, char *uuid_
|
||||||
g_free(uuid_test);
|
g_free(uuid_test);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _test_uuid(expected_uuid, str, strlen, ...) \
|
#define check_uuid_v3(expected_uuid, str, strlen, ...) \
|
||||||
__test_uuid(expected_uuid, str, strlen, nm_uuid_generate_from_strings(__VA_ARGS__, NULL))
|
_check_uuid_v3(expected_uuid, str, strlen, nm_uuid_generate_from_strings_v3(__VA_ARGS__, NULL))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_nm_utils_uuid_generate_from_strings(void)
|
test_nm_utils_uuid_generate_from_strings(void)
|
||||||
|
|
@ -7998,20 +7998,20 @@ test_nm_utils_uuid_generate_from_strings(void)
|
||||||
g_assert_cmpstr(NM_UUID_NS_1, ==, nm_uuid_unparse(&nm_uuid_ns_1, buf));
|
g_assert_cmpstr(NM_UUID_NS_1, ==, nm_uuid_unparse(&nm_uuid_ns_1, buf));
|
||||||
g_assert_cmpstr(NM_UUID_NS_ZERO, ==, nm_uuid_unparse(&nm_uuid_ns_zero, buf));
|
g_assert_cmpstr(NM_UUID_NS_ZERO, ==, nm_uuid_unparse(&nm_uuid_ns_zero, buf));
|
||||||
|
|
||||||
_test_uuid("b07c334a-399b-32de-8d50-58e4e08f98e3", "", 0, NULL);
|
check_uuid_v3("b07c334a-399b-32de-8d50-58e4e08f98e3", "", 0, NULL);
|
||||||
_test_uuid("b8a426cb-bcb5-30a3-bd8f-6786fea72df9", "\0", 1, "");
|
check_uuid_v3("b8a426cb-bcb5-30a3-bd8f-6786fea72df9", "\0", 1, "");
|
||||||
_test_uuid("12a4a982-7aae-39e1-951e-41aeb1250959", "a\0", 2, "a");
|
check_uuid_v3("12a4a982-7aae-39e1-951e-41aeb1250959", "a\0", 2, "a");
|
||||||
_test_uuid("69e22c7e-f89f-3a43-b239-1cb52ed8db69", "aa\0", 3, "aa");
|
check_uuid_v3("69e22c7e-f89f-3a43-b239-1cb52ed8db69", "aa\0", 3, "aa");
|
||||||
_test_uuid("59829fd3-5ad5-3d90-a7b0-4911747e4088", "\0\0", 2, "", "");
|
check_uuid_v3("59829fd3-5ad5-3d90-a7b0-4911747e4088", "\0\0", 2, "", "");
|
||||||
_test_uuid("01ad0e06-6c50-3384-8d86-ddab81421425", "a\0\0", 3, "a", "");
|
check_uuid_v3("01ad0e06-6c50-3384-8d86-ddab81421425", "a\0\0", 3, "a", "");
|
||||||
_test_uuid("e1ed8647-9ed3-3ec8-8c6d-e8204524d71d", "aa\0\0", 4, "aa", "");
|
check_uuid_v3("e1ed8647-9ed3-3ec8-8c6d-e8204524d71d", "aa\0\0", 4, "aa", "");
|
||||||
_test_uuid("fb1c7cd6-275c-3489-9382-83b900da8af0", "\0a\0", 3, "", "a");
|
check_uuid_v3("fb1c7cd6-275c-3489-9382-83b900da8af0", "\0a\0", 3, "", "a");
|
||||||
_test_uuid("5d79494e-c4ba-31a6-80a2-d6016ccd7e17", "a\0a\0", 4, "a", "a");
|
check_uuid_v3("5d79494e-c4ba-31a6-80a2-d6016ccd7e17", "a\0a\0", 4, "a", "a");
|
||||||
_test_uuid("fd698d86-1b60-3ebe-855f-7aada9950a8d", "aa\0a\0", 5, "aa", "a");
|
check_uuid_v3("fd698d86-1b60-3ebe-855f-7aada9950a8d", "aa\0a\0", 5, "aa", "a");
|
||||||
_test_uuid("8c573b48-0f01-30ba-bb94-c5f59f4fe517", "\0aa\0", 4, "", "aa");
|
check_uuid_v3("8c573b48-0f01-30ba-bb94-c5f59f4fe517", "\0aa\0", 4, "", "aa");
|
||||||
_test_uuid("2bdd3d46-eb83-3c53-a41b-a724d04b5544", "a\0aa\0", 5, "a", "aa");
|
check_uuid_v3("2bdd3d46-eb83-3c53-a41b-a724d04b5544", "a\0aa\0", 5, "a", "aa");
|
||||||
_test_uuid("13d4b780-07c1-3ba7-b449-81c4844ef039", "aa\0aa\0", 6, "aa", "aa");
|
check_uuid_v3("13d4b780-07c1-3ba7-b449-81c4844ef039", "aa\0aa\0", 6, "aa", "aa");
|
||||||
_test_uuid("dd265bf7-c05a-3037-9939-b9629858a477", "a\0b\0", 4, "a", "b");
|
check_uuid_v3("dd265bf7-c05a-3037-9939-b9629858a477", "a\0b\0", 4, "a", "b");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
const NMUuid nm_uuid_ns_zero =
|
const NMUuid nm_uuid_ns_zero =
|
||||||
NM_UUID_INIT(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00);
|
NM_UUID_INIT(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00);
|
||||||
|
|
||||||
/* arbitrarily chosen namespace UUID for nm_uuid_generate_from_strings() */
|
/* arbitrarily chosen namespace UUID for nm_uuid_generate_from_strings_v3() */
|
||||||
const NMUuid nm_uuid_ns_1 =
|
const NMUuid nm_uuid_ns_1 =
|
||||||
NM_UUID_INIT(b4, 25, e9, fb, 75, 98, 44, b4, 9e, 3b, 5a, 2e, 3a, aa, 49, 05);
|
NM_UUID_INIT(b4, 25, e9, fb, 75, 98, 44, b4, 9e, 3b, 5a, 2e, 3a, aa, 49, 05);
|
||||||
|
|
||||||
|
|
@ -406,7 +406,7 @@ nm_uuid_generate_from_string_str(const char *s,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_uuid_generate_from_strings:
|
* nm_uuid_generate_from_strings_v3:
|
||||||
* @string1: a variadic list of strings. Must be NULL terminated.
|
* @string1: a variadic list of strings. Must be NULL terminated.
|
||||||
*
|
*
|
||||||
* Returns a variant3 UUID based on the concatenated C strings.
|
* Returns a variant3 UUID based on the concatenated C strings.
|
||||||
|
|
@ -419,7 +419,7 @@ nm_uuid_generate_from_string_str(const char *s,
|
||||||
* ("aa"), ("aa", ""), ("", "aa"), ...
|
* ("aa"), ("aa", ""), ("", "aa"), ...
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
nm_uuid_generate_from_strings(const char *string1, ...)
|
nm_uuid_generate_from_strings_v3(const char *string1, ...)
|
||||||
{
|
{
|
||||||
if (!string1)
|
if (!string1)
|
||||||
return nm_uuid_generate_from_string_str(NULL, 0, NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1);
|
return nm_uuid_generate_from_string_str(NULL, 0, NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1);
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ char *nm_uuid_generate_from_string_str(const char *s,
|
||||||
NMUuidType uuid_type,
|
NMUuidType uuid_type,
|
||||||
const NMUuid *type_args);
|
const NMUuid *type_args);
|
||||||
|
|
||||||
char *nm_uuid_generate_from_strings(const char *string1, ...) G_GNUC_NULL_TERMINATED;
|
char *nm_uuid_generate_from_strings_v3(const char *string1, ...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -307,13 +307,13 @@ connection_setting_add(GHashTable *nic,
|
||||||
s_index ? " " : "",
|
s_index ? " " : "",
|
||||||
s_index ? s_index : "");
|
s_index ? s_index : "");
|
||||||
|
|
||||||
uuid = nm_uuid_generate_from_strings("ibft",
|
uuid = nm_uuid_generate_from_strings_v3("ibft",
|
||||||
s_hwaddr,
|
s_hwaddr,
|
||||||
s_vlanid ? "V" : "v",
|
s_vlanid ? "V" : "v",
|
||||||
s_vlanid ? s_vlanid : "",
|
s_vlanid ? s_vlanid : "",
|
||||||
s_ipaddr ? "A" : "DHCP",
|
s_ipaddr ? "A" : "DHCP",
|
||||||
s_ipaddr ? s_ipaddr : "",
|
s_ipaddr ? s_ipaddr : "",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
s_con = (NMSetting *) nm_connection_get_setting_connection(connection);
|
s_con = (NMSetting *) nm_connection_get_setting_connection(connection);
|
||||||
if (!s_con) {
|
if (!s_con) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue