mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 20:45:32 +00:00
all: drop nm_uuid_generate_from_strings_v3()
For new uses of nm_uuid_generate_from_strings() we should generate version5 UUIDs and we should use unique namespace UUID arguments. The namespace UUID was so far replaced by always passing a special prefix as first string. It seems nicer to use a namespace instead. Version3 UUIDs should not be used for new applications. Hence, nm_uuid_generate_from_strings_v3() is no longer a desirable way to generate UUIDs, so drop the wrapper.
This commit is contained in:
parent
7e33ef916a
commit
e9a33bbbf8
|
@ -1725,11 +1725,12 @@ new_default_connection(NMDevice *self)
|
|||
|
||||
/* 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. */
|
||||
uuid = nm_uuid_generate_from_strings_v3("default-wired",
|
||||
uuid = nm_uuid_generate_from_strings(NM_UUID_TYPE_VERSION3,
|
||||
&nm_uuid_ns_1,
|
||||
"default-wired",
|
||||
nm_utils_machine_id_str(),
|
||||
defname,
|
||||
perm_hw_addr ?: iface,
|
||||
NULL);
|
||||
perm_hw_addr ?: iface);
|
||||
|
||||
g_object_set(setting,
|
||||
NM_SETTING_CONNECTION_ID,
|
||||
|
|
|
@ -2296,7 +2296,8 @@ test_read_missing_id_uuid(void)
|
|||
gs_free char *expected_uuid = NULL;
|
||||
const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID";
|
||||
|
||||
expected_uuid = nm_uuid_generate_from_strings_v3("keyfile", FILENAME, NULL);
|
||||
expected_uuid =
|
||||
nm_uuid_generate_from_strings(NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1, "keyfile", FILENAME);
|
||||
|
||||
connection = keyfile_read_connection_from_file(FILENAME);
|
||||
|
||||
|
|
|
@ -3800,7 +3800,10 @@ nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallback_uuid_
|
|||
if (nm_setting_connection_get_uuid(s_con))
|
||||
return FALSE;
|
||||
|
||||
hashed_uuid = nm_uuid_generate_from_strings_v3("keyfile", fallback_uuid_seed, NULL);
|
||||
hashed_uuid = nm_uuid_generate_from_strings(NM_UUID_TYPE_VERSION3,
|
||||
&nm_uuid_ns_1,
|
||||
"keyfile",
|
||||
fallback_uuid_seed);
|
||||
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, hashed_uuid, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -7951,8 +7951,7 @@ _check_uuid(NMUuidType uuid_type,
|
|||
const char *expected_uuid,
|
||||
const char *str,
|
||||
gssize slen,
|
||||
char *uuid_test,
|
||||
char *uuid_test_v3)
|
||||
char *uuid_test)
|
||||
{
|
||||
g_assert(uuid_test);
|
||||
g_assert(nm_uuid_is_normalized(uuid_test));
|
||||
|
@ -7980,17 +7979,6 @@ _check_uuid(NMUuidType uuid_type,
|
|||
uuid_test);
|
||||
}
|
||||
g_free(uuid_test);
|
||||
|
||||
if (!uuid_test_v3) {
|
||||
/* The special case of NULL argument. This cannot be represented by
|
||||
* nm_uuid_generate_from_strings_v3(). */
|
||||
g_assert_cmpmem(str, slen, "x", 1);
|
||||
} else if (uuid_type == NM_UUID_TYPE_VERSION3 && type_arg == &nm_uuid_ns_1)
|
||||
g_assert_cmpstr(expected_uuid, ==, uuid_test_v3);
|
||||
else
|
||||
g_assert_cmpstr(expected_uuid, !=, uuid_test_v3);
|
||||
|
||||
g_free(uuid_test_v3);
|
||||
}
|
||||
|
||||
#define check_uuid(uuid_type, type_arg, expected_uuid, str, ...) \
|
||||
|
@ -8007,8 +7995,7 @@ _check_uuid(NMUuidType uuid_type,
|
|||
_expected_uuid, \
|
||||
_str, \
|
||||
_strlen, \
|
||||
nm_uuid_generate_from_strings_strv(_uuid_type, _type_arg, NM_MAKE_STRV(__VA_ARGS__)), \
|
||||
nm_uuid_generate_from_strings_v3(__VA_ARGS__, NULL)); \
|
||||
nm_uuid_generate_from_strings_strv(_uuid_type, _type_arg, NM_MAKE_STRV(__VA_ARGS__))); \
|
||||
})
|
||||
|
||||
static void
|
||||
|
@ -8036,8 +8023,7 @@ test_nm_utils_uuid_generate_from_strings(void)
|
|||
"457229f4-fe49-32f5-8b09-c531d81f44d9",
|
||||
"x",
|
||||
1,
|
||||
nm_uuid_generate_from_strings_strv(NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1, NULL),
|
||||
NULL);
|
||||
nm_uuid_generate_from_strings_strv(NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1, NULL));
|
||||
check_uuid(NM_UUID_TYPE_VERSION3,
|
||||
&nm_uuid_ns_1,
|
||||
"b07c334a-399b-32de-8d50-58e4e08f98e3",
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
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);
|
||||
|
||||
/* arbitrarily chosen namespace UUID for nm_uuid_generate_from_strings_v3() */
|
||||
/* arbitrarily chosen namespace UUID for some uses of nm_uuid_generate_from_strings().
|
||||
* Try not to re-use this namespace, instead, generate a unique one. */
|
||||
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);
|
||||
|
||||
|
|
|
@ -130,9 +130,6 @@ char *nm_uuid_generate_from_strings_strv(NMUuidType uuid_type,
|
|||
#define nm_uuid_generate_from_strings(uuid_type, type_args, ...) \
|
||||
nm_uuid_generate_from_strings_strv((uuid_type), (type_args), NM_MAKE_STRV(__VA_ARGS__))
|
||||
|
||||
#define nm_uuid_generate_from_strings_v3(...) \
|
||||
nm_uuid_generate_from_strings(NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1, __VA_ARGS__)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* __NM_UUID_H__ */
|
||||
|
|
|
@ -307,13 +307,14 @@ connection_setting_add(GHashTable *nic,
|
|||
s_index ? " " : "",
|
||||
s_index ? s_index : "");
|
||||
|
||||
uuid = nm_uuid_generate_from_strings_v3("ibft",
|
||||
uuid = nm_uuid_generate_from_strings(NM_UUID_TYPE_VERSION3,
|
||||
&nm_uuid_ns_1,
|
||||
"ibft",
|
||||
s_hwaddr,
|
||||
s_vlanid ? "V" : "v",
|
||||
s_vlanid ? s_vlanid : "",
|
||||
s_ipaddr ? "A" : "DHCP",
|
||||
s_ipaddr ? s_ipaddr : "",
|
||||
NULL);
|
||||
s_ipaddr ? s_ipaddr : "");
|
||||
|
||||
s_con = (NMSetting *) nm_connection_get_setting_connection(connection);
|
||||
if (!s_con) {
|
||||
|
|
Loading…
Reference in a new issue