mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 10:20:14 +01: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 commit476810c290. (cherry picked from commit39ad134b0c)
This commit is contained in:
parent
9740a59035
commit
4f5059306b
3 changed files with 6 additions and 23 deletions
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-connection.h"
|
||||
#include "nm-connection-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
|
|
@ -916,7 +915,7 @@ _normalize_team_config (NMConnection *self, GHashTable *parameters)
|
|||
if (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);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -932,7 +931,7 @@ _normalize_team_port_config (NMConnection *self, GHashTable *parameters)
|
|||
if (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);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,19 +122,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
"%s.%s: ",
|
||||
NM_SETTING_TEAM_PORT_SETTING_NAME,
|
||||
NM_SETTING_TEAM_PORT_CONFIG);
|
||||
/* for backward compatibility, we accept invalid json and normalize it */
|
||||
if (!priv->config[0]) {
|
||||
/* 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;
|
||||
/* We treat an empty string as no config for compatibility. */
|
||||
return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: normalizable/normalizable-errors must appear at the end with decreasing severity.
|
||||
* Take care to properly order statements with priv->config above. */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,19 +94,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
"%s.%s: ",
|
||||
NM_SETTING_TEAM_SETTING_NAME,
|
||||
NM_SETTING_TEAM_CONFIG);
|
||||
/* for backward compatibility, we accept invalid json and normalize it */
|
||||
if (!priv->config[0]) {
|
||||
/* 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;
|
||||
/* We treat an empty string as no config for compatibility. */
|
||||
return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: normalizable/normalizable-errors must appear at the end with decreasing severity.
|
||||
* Take care to properly order statements with priv->config above. */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue