summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting-team.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-08-24 09:59:06 +0200
committerThomas Haller <thaller@redhat.com>2016-08-24 10:59:39 +0200
commit5b9f7169eda94ec829f28df7d385be0e62482bb8 (patch)
tree5eddc86fb0236fd8164f8cf551a3bed78bbb7587 /libnm-core/nm-setting-team.c
parent5f1662066dcf5143b9065ebb56704a061ca2ffd9 (diff)
downloadNetworkManager-5b9f7169eda94ec829f28df7d385be0e62482bb8.tar.gz
libnm-core/team: normalize invalid config to NULL
A user may very well have connections on disk with bogus json. Such connections may have failed to activate before, but rejecting them now as invalid means that we stop loading them from disk. That is, they disappear after upgrade. Instead of doing that, also accept invalid json (beside "") and normalize/coerce it to NULL. https://bugzilla.redhat.com/show_bug.cgi?id=1366300 (cherry picked from commit 476810c29016d569ac3885542a6c91e7af8a7f6d)
Diffstat (limited to 'libnm-core/nm-setting-team.c')
-rw-r--r--libnm-core/nm-setting-team.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c
index df89694f66..a559e0db78 100644
--- a/libnm-core/nm-setting-team.c
+++ b/libnm-core/nm-setting-team.c
@@ -94,11 +94,19 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
"%s.%s: ",
NM_SETTING_TEAM_SETTING_NAME,
NM_SETTING_TEAM_CONFIG);
- /* We treat an empty string as no config for compatibility. */
- return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
+ /* 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;
}
}
+ /* NOTE: normalizable/normalizable-errors must appear at the end with decreasing severity.
+ * Take care to properly order statements with priv->config above. */
+
return TRUE;
}