keyfile: require a UUID in the connection settings
The connection needs a UUID, period.
This commit is contained in:
@@ -47,8 +47,8 @@ nm_keyfile_connection_new (const char *full_path,
|
|||||||
{
|
{
|
||||||
GObject *object;
|
GObject *object;
|
||||||
NMKeyfileConnectionPrivate *priv;
|
NMKeyfileConnectionPrivate *priv;
|
||||||
NMSettingConnection *s_con;
|
|
||||||
NMConnection *tmp;
|
NMConnection *tmp;
|
||||||
|
const char *uuid;
|
||||||
|
|
||||||
g_return_val_if_fail (full_path != NULL, NULL);
|
g_return_val_if_fail (full_path != NULL, NULL);
|
||||||
|
|
||||||
@@ -75,24 +75,12 @@ nm_keyfile_connection_new (const char *full_path,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if for some reason the connection didn't have a UUID, add one */
|
uuid = nm_connection_get_uuid (NM_CONNECTION (object));
|
||||||
s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (object), NM_TYPE_SETTING_CONNECTION);
|
if (!uuid) {
|
||||||
if (s_con && !nm_setting_connection_get_uuid (s_con)) {
|
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
GError *write_error = NULL;
|
"Connection in file %s had no UUID", full_path);
|
||||||
char *uuid;
|
g_object_unref (object);
|
||||||
|
object = NULL;
|
||||||
uuid = nm_utils_uuid_generate ();
|
|
||||||
g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
|
|
||||||
g_free (uuid);
|
|
||||||
|
|
||||||
if (!nm_keyfile_plugin_write_connection (NM_CONNECTION (object), KEYFILE_DIR, 0, 0, NULL, &write_error)) {
|
|
||||||
PLUGIN_WARN (KEYFILE_PLUGIN_NAME,
|
|
||||||
"Couldn't update connection %s with a UUID: (%d) %s",
|
|
||||||
nm_setting_connection_get_id (s_con),
|
|
||||||
write_error ? write_error->code : -1,
|
|
||||||
(write_error && write_error->message) ? write_error->message : "(unknown)");
|
|
||||||
g_propagate_error (error, write_error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
Reference in New Issue
Block a user