diff options
author | Thomas Haller <thaller@redhat.com> | 2019-04-17 17:21:13 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-04-18 18:51:21 +0200 |
commit | 93eb40eda923a07753083361fc5b7b5515548e4a (patch) | |
tree | 3bb8d85c1ff05776078934e4dffd8b7d79d87866 | |
parent | f6d73aff709e8039d90726a21a3db37b879ce8fe (diff) |
ifcfg-rh: use nm_utils_escaped_tokens* for "MATCH_INTERFACE_NAME"
For one, use NM_ASCII_SPACES as delimiter when reading
"MATCH_INTERFACE_NAME". Previously, it was only " \t".
I think there is no change in behavior otherwise.
(cherry picked from commit 941f27d350f8d086d3dbdda7ae19f6e4fa2856cf)
-rw-r--r-- | src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 5 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 10 |
2 files changed, 8 insertions, 7 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 a5f158a85e..a86e61b9d7 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -1427,13 +1427,12 @@ make_match_setting (shvarFile *ifcfg) if (!v) return NULL; - strv = nm_utils_strsplit_set_full (v, " \t", NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); + strv = nm_utils_escaped_tokens_split (v, NM_ASCII_SPACES); if (strv) { for (i = 0; strv[i]; i++) { if (!s_match) s_match = (NMSettingMatch *) nm_setting_match_new (); - nm_setting_match_add_interface_name (s_match, - _nm_utils_unescape_spaces ((char *) strv[i], TRUE)); + nm_setting_match_add_interface_name (s_match, strv[i]); } } 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 a8be7cdec2..2be986307e 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -2375,15 +2375,17 @@ write_match_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) num = nm_setting_match_get_num_interface_names (s_match); for (i = 0; i < num; i++) { - gs_free char *to_free = NULL; const char *name; - if (i == 0) + name = nm_setting_match_get_interface_name (s_match, i); + if (!name || !name[0]) + continue; + + if (!str) str = g_string_new (""); else g_string_append_c (str, ' '); - name = nm_setting_match_get_interface_name (s_match, i); - g_string_append (str, _nm_utils_escape_spaces (name, &to_free)); + nm_utils_escaped_tokens_escape_gstr (name, NM_ASCII_SPACES, str); } if (str) |