mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-21 18:10:54 +02:00
all: use nm_uuid_is_normalized() for checking valid UUID for "connection.uuid"
"connection.uuid" gets normalized. When we check for a valid UUID, we expect it to be normalized.
This commit is contained in:
parent
423e83b880
commit
6f2ae46b37
8 changed files with 23 additions and 18 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "nm-settings-storage.h"
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-settings-plugin.h"
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
case PROP_UUID:
|
||||
/* construct-only */
|
||||
self->_uuid = g_value_dup_string(value);
|
||||
nm_assert(!self->_uuid || nm_utils_is_uuid(self->_uuid));
|
||||
nm_assert(!self->_uuid || nm_uuid_is_normalized(self->_uuid));
|
||||
break;
|
||||
case PROP_FILENAME:
|
||||
/* construct-only */
|
||||
|
|
@ -97,7 +98,7 @@ NMSettingsStorage *
|
|||
nm_settings_storage_new(NMSettingsPlugin *plugin, const char *uuid, const char *filename)
|
||||
{
|
||||
nm_assert(NM_IS_SETTINGS_PLUGIN(plugin));
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
|
||||
return g_object_new(NM_TYPE_SETTINGS_STORAGE,
|
||||
NM_SETTINGS_STORAGE_PLUGIN,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#endif
|
||||
|
||||
#include "libnm-core-aux-intern/nm-common-macros.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-keyfile-aux.h"
|
||||
#include "libnm-core-intern/nm-keyfile-internal.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
|
|
@ -139,7 +140,7 @@ nm_assert_storage_data_lst(CList *head)
|
|||
u = nm_settings_storage_get_uuid(sd->storage);
|
||||
if (!uuid) {
|
||||
uuid = u;
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
} else
|
||||
nm_assert(nm_streq0(uuid, u));
|
||||
}
|
||||
|
|
@ -182,7 +183,7 @@ _sett_conn_entry_new(const char *uuid)
|
|||
SettConnEntry *sett_conn_entry;
|
||||
gsize l_p_1;
|
||||
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
|
||||
l_p_1 = strlen(uuid) + 1;
|
||||
|
||||
|
|
@ -1461,7 +1462,7 @@ _add_connection_to_first_plugin(NMSettings * self,
|
|||
|
||||
uuid = nm_connection_get_uuid(new_connection);
|
||||
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
|
||||
for (iter = priv->plugins; iter; iter = iter->next) {
|
||||
NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN(iter->data);
|
||||
|
|
@ -2295,7 +2296,7 @@ nm_settings_delete_connection(NMSettings * self,
|
|||
nm_assert(NM_IS_SETTINGS_STORAGE(cur_storage));
|
||||
|
||||
uuid = nm_settings_storage_get_uuid(cur_storage);
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
|
||||
sett_conn_entry = _sett_conn_entries_get(self, uuid);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "nms-ifcfg-rh-storage.h"
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "nm-utils.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "nm-connection.h"
|
||||
|
|
@ -88,7 +89,7 @@ static NMSIfcfgRHStorage *
|
|||
_storage_new(NMSIfcfgRHPlugin *plugin, const char *uuid, const char *filename)
|
||||
{
|
||||
nm_assert(NMS_IS_IFCFG_RH_PLUGIN(plugin));
|
||||
nm_assert(!uuid || nm_utils_is_uuid(uuid));
|
||||
nm_assert(!uuid || nm_uuid_is_normalized(uuid));
|
||||
nm_assert(filename && filename[0] == '/');
|
||||
|
||||
return g_object_new(NMS_TYPE_IFCFG_RH_STORAGE,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "libnm-std-aux/c-list-util.h"
|
||||
#include "libnm-glib-aux/nm-c-list.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-io-utils.h"
|
||||
|
||||
#include "nm-connection.h"
|
||||
|
|
@ -233,7 +234,7 @@ _read_from_file(const char * full_filename,
|
|||
|
||||
nm_assert(!connection
|
||||
|| (_nm_connection_verify(connection, NULL) == NM_SETTING_VERIFY_SUCCESS));
|
||||
nm_assert(!connection || nm_utils_is_uuid(nm_connection_get_uuid(connection)));
|
||||
nm_assert(!connection || nm_uuid_is_normalized(nm_connection_get_uuid(connection)));
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
|
@ -260,7 +261,7 @@ _nm_assert_storage(gpointer plugin /* NMSKeyfilePlugin */,
|
|||
|
||||
uuid = nms_keyfile_storage_get_uuid(storage);
|
||||
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
|
||||
nm_assert(((NMSKeyfileStorage *) storage)->is_meta_data
|
||||
|| !(((NMSKeyfileStorage *) storage)->u.conn_data.connection)
|
||||
|
|
@ -1106,7 +1107,7 @@ nms_keyfile_plugin_set_nmmeta_tombstone(NMSKeyfilePlugin * self,
|
|||
const char * dirname;
|
||||
|
||||
nm_assert(NMS_IS_KEYFILE_PLUGIN(self));
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
nm_assert(!out_storage || !*out_storage);
|
||||
nm_assert(!shadowed_storage || (set && in_memory));
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "nms-keyfile-storage.h"
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "nm-utils.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "nms-keyfile-plugin.h"
|
||||
|
|
@ -108,7 +109,7 @@ _storage_new(NMSKeyfilePlugin * plugin,
|
|||
NMSKeyfileStorage *self;
|
||||
|
||||
nm_assert(NMS_IS_KEYFILE_PLUGIN(plugin));
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
nm_assert(filename && filename[0] == '/');
|
||||
|
||||
self = g_object_new(NMS_TYPE_KEYFILE_STORAGE,
|
||||
|
|
@ -135,7 +136,7 @@ nms_keyfile_storage_new_tombstone(NMSKeyfilePlugin * plugin,
|
|||
{
|
||||
NMSKeyfileStorage *self;
|
||||
|
||||
nm_assert(nm_utils_is_uuid(uuid));
|
||||
nm_assert(nm_uuid_is_normalized(uuid));
|
||||
nm_assert(filename && filename[0] == '/');
|
||||
nm_assert(nms_keyfile_nmmeta_check_filename(filename, NULL));
|
||||
nm_assert(NM_IN_SET(storage_type, NMS_KEYFILE_STORAGE_TYPE_ETC, NMS_KEYFILE_STORAGE_TYPE_RUN));
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ nms_keyfile_nmmeta_check_filename(const char *filename, guint *out_uuid_len)
|
|||
|
||||
if (len != 36) {
|
||||
/* the remaining part of the filename has not the right length to
|
||||
* contain a UUID (according to nm_utils_is_uuid()). */
|
||||
* contain a UUID (according to nm_uuid_is_normalized()). */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ nms_keyfile_nmmeta_filename(const char *dirname, const char *uuid, gboolean temp
|
|||
char *s;
|
||||
|
||||
nm_assert(dirname && dirname[0] == '/');
|
||||
nm_assert(nm_utils_is_uuid(uuid) && !strchr(uuid, '/'));
|
||||
nm_assert(nm_uuid_is_normalized(uuid) && !strchr(uuid, '/'));
|
||||
|
||||
if (g_snprintf(filename,
|
||||
sizeof(filename),
|
||||
|
|
@ -82,7 +82,7 @@ nms_keyfile_nmmeta_filename(const char *dirname, const char *uuid, gboolean temp
|
|||
NM_KEYFILE_PATH_SUFFIX_NMMETA,
|
||||
temporary ? "~" : "")
|
||||
>= sizeof(filename)) {
|
||||
/* valid uuids are limited in length (nm_utils_is_uuid). The buffer should always
|
||||
/* valid uuids are limited in length (nm_uuid_is_normalized). The buffer should always
|
||||
* be large enough. */
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ nms_keyfile_nmmeta_write(const char *dirname,
|
|||
int errsv;
|
||||
|
||||
nm_assert(dirname && dirname[0] == '/');
|
||||
nm_assert(nm_utils_is_uuid(uuid) && !strchr(uuid, '/'));
|
||||
nm_assert(nm_uuid_is_normalized(uuid) && !strchr(uuid, '/'));
|
||||
nm_assert(!loaded_path || loaded_path[0] == '/');
|
||||
nm_assert(!shadowed_storage || loaded_path);
|
||||
|
||||
|
|
|
|||
|
|
@ -1740,7 +1740,7 @@ _nm_connection_ensure_normalized(NMConnection * connection,
|
|||
|
||||
nm_assert(NM_IS_CONNECTION(connection));
|
||||
nm_assert(!out_connection_clone || !*out_connection_clone);
|
||||
nm_assert(!expected_uuid || nm_utils_is_uuid(expected_uuid));
|
||||
nm_assert(!expected_uuid || nm_uuid_is_normalized(expected_uuid));
|
||||
|
||||
if (expected_uuid) {
|
||||
if (nm_streq0(expected_uuid, nm_connection_get_uuid(connection)))
|
||||
|
|
|
|||
|
|
@ -7788,7 +7788,7 @@ static void
|
|||
__test_uuid(const char *expected_uuid, const char *str, gssize slen, char *uuid_test)
|
||||
{
|
||||
g_assert(uuid_test);
|
||||
g_assert(nm_utils_is_uuid(uuid_test));
|
||||
g_assert(nm_uuid_is_normalized(uuid_test));
|
||||
|
||||
if (strcmp(uuid_test, expected_uuid)) {
|
||||
g_error("UUID test failed (1): text=%s, len=%lld, expected=%s, uuid_test=%s",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue