summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-24 13:06:58 +0200
committerThomas Haller <thaller@redhat.com>2019-04-24 13:06:58 +0200
commitd5805e956b5f899d63820ea95cda4a5f4860ee43 (patch)
treec6c0a545f3d99d34b42c97f9a60cfa6f80816149
parent59ba4134f01ea6a07ccc1ed93e3800192ad4602d (diff)
downloadNetworkManager-th/cli-team-cleanup.tar.gz
ifcfg-rh: support serializaing all possible values for ethernet.s390-options (OPTIONS)th/cli-team-cleanup
While the keys of s390-options are from a well-behaving set of names (that is enforced by nm_connection_verify()), the values are arbitrary strings. Our settings plugin must be able to express all values of a connection, hence we need to support escapes.
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c2
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c10
2 files changed, 10 insertions, 2 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index e5423b181e..286ee58abc 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -4512,7 +4512,7 @@ make_wired_setting (shvarFile *ifcfg,
gs_free const char **options = NULL;
gsize i;
- options = nm_utils_strsplit_set_with_empty (value, " ");
+ options = nm_utils_escaped_tokens_split (value, NM_ASCII_SPACES);
for (i = 0; options && options[i]; i++) {
const char *line = options[i];
const char *equals;
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index b752642dfe..e9a023c5b9 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -1121,11 +1121,19 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
if (NM_IN_STRSET (s390_key, "portname", "ctcprot"))
continue;
+ if (strchr (s390_key, '=')) {
+ /* this key cannot be expressed. But after all, it's not valid anyway
+ * and the connection shouldn't even verify. */
+ continue;
+ }
+
if (!tmp)
tmp = g_string_sized_new (30);
else
g_string_append_c (tmp, ' ');
- g_string_append_printf (tmp, "%s=%s", s390_key, s390_val);
+ nm_utils_escaped_tokens_escape_gstr (s390_key, NM_ASCII_SPACES, tmp);
+ g_string_append_c (tmp, '=');
+ nm_utils_escaped_tokens_escape_gstr (s390_val, NM_ASCII_SPACES, tmp);
}
if (tmp)
svSetValueStr (ifcfg, "OPTIONS", tmp->str);