mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 12:34:55 +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,
|
/* 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_v3("default-wired",
|
uuid = nm_uuid_generate_from_strings(NM_UUID_TYPE_VERSION3,
|
||||||
nm_utils_machine_id_str(),
|
&nm_uuid_ns_1,
|
||||||
defname,
|
"default-wired",
|
||||||
perm_hw_addr ?: iface,
|
nm_utils_machine_id_str(),
|
||||||
NULL);
|
defname,
|
||||||
|
perm_hw_addr ?: iface);
|
||||||
|
|
||||||
g_object_set(setting,
|
g_object_set(setting,
|
||||||
NM_SETTING_CONNECTION_ID,
|
NM_SETTING_CONNECTION_ID,
|
||||||
|
|
|
@ -2296,7 +2296,8 @@ 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_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);
|
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))
|
if (nm_setting_connection_get_uuid(s_con))
|
||||||
return FALSE;
|
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);
|
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, hashed_uuid, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7951,8 +7951,7 @@ _check_uuid(NMUuidType uuid_type,
|
||||||
const char *expected_uuid,
|
const char *expected_uuid,
|
||||||
const char *str,
|
const char *str,
|
||||||
gssize slen,
|
gssize slen,
|
||||||
char *uuid_test,
|
char *uuid_test)
|
||||||
char *uuid_test_v3)
|
|
||||||
{
|
{
|
||||||
g_assert(uuid_test);
|
g_assert(uuid_test);
|
||||||
g_assert(nm_uuid_is_normalized(uuid_test));
|
g_assert(nm_uuid_is_normalized(uuid_test));
|
||||||
|
@ -7980,35 +7979,23 @@ _check_uuid(NMUuidType uuid_type,
|
||||||
uuid_test);
|
uuid_test);
|
||||||
}
|
}
|
||||||
g_free(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, ...) \
|
#define check_uuid(uuid_type, type_arg, expected_uuid, str, ...) \
|
||||||
({ \
|
({ \
|
||||||
const NMUuidType _uuid_type = (uuid_type); \
|
const NMUuidType _uuid_type = (uuid_type); \
|
||||||
const NMUuid *_type_arg = type_arg; \
|
const NMUuid *_type_arg = type_arg; \
|
||||||
const char *_expected_uuid = (expected_uuid); \
|
const char *_expected_uuid = (expected_uuid); \
|
||||||
const char *_str = (str); \
|
const char *_str = (str); \
|
||||||
const gsize _strlen = NM_STRLEN(str); \
|
const gsize _strlen = NM_STRLEN(str); \
|
||||||
\
|
\
|
||||||
_check_uuid( \
|
_check_uuid( \
|
||||||
_uuid_type, \
|
_uuid_type, \
|
||||||
_type_arg, \
|
_type_arg, \
|
||||||
_expected_uuid, \
|
_expected_uuid, \
|
||||||
_str, \
|
_str, \
|
||||||
_strlen, \
|
_strlen, \
|
||||||
nm_uuid_generate_from_strings_strv(_uuid_type, _type_arg, NM_MAKE_STRV(__VA_ARGS__)), \
|
nm_uuid_generate_from_strings_strv(_uuid_type, _type_arg, NM_MAKE_STRV(__VA_ARGS__))); \
|
||||||
nm_uuid_generate_from_strings_v3(__VA_ARGS__, NULL)); \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -8036,8 +8023,7 @@ test_nm_utils_uuid_generate_from_strings(void)
|
||||||
"457229f4-fe49-32f5-8b09-c531d81f44d9",
|
"457229f4-fe49-32f5-8b09-c531d81f44d9",
|
||||||
"x",
|
"x",
|
||||||
1,
|
1,
|
||||||
nm_uuid_generate_from_strings_strv(NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1, NULL),
|
nm_uuid_generate_from_strings_strv(NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1, NULL));
|
||||||
NULL);
|
|
||||||
check_uuid(NM_UUID_TYPE_VERSION3,
|
check_uuid(NM_UUID_TYPE_VERSION3,
|
||||||
&nm_uuid_ns_1,
|
&nm_uuid_ns_1,
|
||||||
"b07c334a-399b-32de-8d50-58e4e08f98e3",
|
"b07c334a-399b-32de-8d50-58e4e08f98e3",
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
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_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 =
|
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);
|
||||||
|
|
||||||
|
|
|
@ -130,9 +130,6 @@ char *nm_uuid_generate_from_strings_strv(NMUuidType uuid_type,
|
||||||
#define nm_uuid_generate_from_strings(uuid_type, type_args, ...) \
|
#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__))
|
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__ */
|
#endif /* __NM_UUID_H__ */
|
||||||
|
|
|
@ -307,13 +307,14 @@ connection_setting_add(GHashTable *nic,
|
||||||
s_index ? " " : "",
|
s_index ? " " : "",
|
||||||
s_index ? s_index : "");
|
s_index ? s_index : "");
|
||||||
|
|
||||||
uuid = nm_uuid_generate_from_strings_v3("ibft",
|
uuid = nm_uuid_generate_from_strings(NM_UUID_TYPE_VERSION3,
|
||||||
s_hwaddr,
|
&nm_uuid_ns_1,
|
||||||
s_vlanid ? "V" : "v",
|
"ibft",
|
||||||
s_vlanid ? s_vlanid : "",
|
s_hwaddr,
|
||||||
s_ipaddr ? "A" : "DHCP",
|
s_vlanid ? "V" : "v",
|
||||||
s_ipaddr ? s_ipaddr : "",
|
s_vlanid ? s_vlanid : "",
|
||||||
NULL);
|
s_ipaddr ? "A" : "DHCP",
|
||||||
|
s_ipaddr ? s_ipaddr : "");
|
||||||
|
|
||||||
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…
Reference in a new issue