ifcfg-rh: support serializaing all possible values for ethernet.s390-options (OPTIONS)

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.
This commit is contained in:
Thomas Haller 2019-04-24 13:06:58 +02:00
parent 0a8f11639a
commit df769c8dfd
2 changed files with 10 additions and 2 deletions

View file

@ -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;

View file

@ -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);