mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 08:18:03 +02:00
Revert "libnm-core/team: normalize invalid config to NULL"
It's better to fail the validation of any invalid configuration
instead of silently ignoring it.
This reverts commit 476810c290.
This commit is contained in:
parent
34880d62d0
commit
39ad134b0c
3 changed files with 6 additions and 23 deletions
|
|
@ -28,7 +28,6 @@
|
||||||
#include "nm-connection.h"
|
#include "nm-connection.h"
|
||||||
#include "nm-connection-private.h"
|
#include "nm-connection-private.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-utils-private.h"
|
|
||||||
#include "nm-setting-private.h"
|
#include "nm-setting-private.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
|
|
@ -916,7 +915,7 @@ _normalize_team_config (NMConnection *self, GHashTable *parameters)
|
||||||
if (s_team) {
|
if (s_team) {
|
||||||
const char *config = nm_setting_team_get_config (s_team);
|
const char *config = nm_setting_team_get_config (s_team);
|
||||||
|
|
||||||
if (config && !_nm_utils_check_valid_json (config, NULL)) {
|
if (config && !*config) {
|
||||||
g_object_set (s_team, NM_SETTING_TEAM_CONFIG, NULL, NULL);
|
g_object_set (s_team, NM_SETTING_TEAM_CONFIG, NULL, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
@ -932,7 +931,7 @@ _normalize_team_port_config (NMConnection *self, GHashTable *parameters)
|
||||||
if (s_team_port) {
|
if (s_team_port) {
|
||||||
const char *config = nm_setting_team_port_get_config (s_team_port);
|
const char *config = nm_setting_team_port_get_config (s_team_port);
|
||||||
|
|
||||||
if (config && !_nm_utils_check_valid_json (config, NULL)) {
|
if (config && !*config) {
|
||||||
g_object_set (s_team_port, NM_SETTING_TEAM_PORT_CONFIG, NULL, NULL);
|
g_object_set (s_team_port, NM_SETTING_TEAM_PORT_CONFIG, NULL, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,19 +122,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||||
"%s.%s: ",
|
"%s.%s: ",
|
||||||
NM_SETTING_TEAM_PORT_SETTING_NAME,
|
NM_SETTING_TEAM_PORT_SETTING_NAME,
|
||||||
NM_SETTING_TEAM_PORT_CONFIG);
|
NM_SETTING_TEAM_PORT_CONFIG);
|
||||||
/* for backward compatibility, we accept invalid json and normalize it */
|
/* We treat an empty string as no config for compatibility. */
|
||||||
if (!priv->config[0]) {
|
return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
|
||||||
/* be more forgiving to "" and let it verify() as valid because
|
|
||||||
* at least anaconda used to write such configs */
|
|
||||||
return NM_SETTING_VERIFY_NORMALIZABLE;
|
|
||||||
}
|
|
||||||
return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NOTE: normalizable/normalizable-errors must appear at the end with decreasing severity.
|
|
||||||
* Take care to properly order statements with priv->config above. */
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,19 +94,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||||
"%s.%s: ",
|
"%s.%s: ",
|
||||||
NM_SETTING_TEAM_SETTING_NAME,
|
NM_SETTING_TEAM_SETTING_NAME,
|
||||||
NM_SETTING_TEAM_CONFIG);
|
NM_SETTING_TEAM_CONFIG);
|
||||||
/* for backward compatibility, we accept invalid json and normalize it */
|
/* We treat an empty string as no config for compatibility. */
|
||||||
if (!priv->config[0]) {
|
return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
|
||||||
/* be more forgiving to "" and let it verify() as valid because
|
|
||||||
* at least anaconda used to write such configs */
|
|
||||||
return NM_SETTING_VERIFY_NORMALIZABLE;
|
|
||||||
}
|
|
||||||
return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NOTE: normalizable/normalizable-errors must appear at the end with decreasing severity.
|
|
||||||
* Take care to properly order statements with priv->config above. */
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue