summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-08-30 15:22:04 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2016-08-30 18:20:28 +0200
commit39ad134b0ca1918084b2b1fc5856cc0b7a6becfc (patch)
tree713e6b9d1734a8fff80c485c05cb9c9fa7cf7eb9
parent34880d62d0ad499465abff53389d56ea13e3921c (diff)
downloadNetworkManager-39ad134b0ca1918084b2b1fc5856cc0b7a6becfc.tar.gz
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 476810c29016d569ac3885542a6c91e7af8a7f6d.
-rw-r--r--libnm-core/nm-connection.c5
-rw-r--r--libnm-core/nm-setting-team-port.c12
-rw-r--r--libnm-core/nm-setting-team.c12
3 files changed, 6 insertions, 23 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index f39d41c58e..57f964095e 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -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;
}
diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c
index 0d175d5ebd..123304fee6 100644
--- a/libnm-core/nm-setting-team-port.c
+++ b/libnm-core/nm-setting-team-port.c
@@ -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;
}
diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c
index a559e0db78..df89694f66 100644
--- a/libnm-core/nm-setting-team.c
+++ b/libnm-core/nm-setting-team.c
@@ -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;
}