From cf5e759978d0301711bd438ba16deefcf5151c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Wed, 5 Mar 2014 12:43:14 +0100 Subject: [PATCH 1/2] team: replace NL chars in team config when passing to libteamdctl (rh #1051517) usock interface in libteamdctl uses \n as a parameter separator and thus would cut the config. So we replace '\r' and '\n' with ' '. https://bugzilla.redhat.com/show_bug.cgi?id=1051517 --- src/devices/nm-device-team.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device-team.c b/src/devices/nm-device-team.c index 1cc7641f3c..a82b4c6bfc 100644 --- a/src/devices/nm-device-team.c +++ b/src/devices/nm-device-team.c @@ -679,8 +679,11 @@ enslave_slave (NMDevice *device, iface, slave_iface); } else { int err; + char *sanitized_config; - err = teamdctl_port_config_update_raw (priv->tdc, slave_iface, config); + sanitized_config = g_strdelimit (g_strdup (config), "\r\n", ' '); + err = teamdctl_port_config_update_raw (priv->tdc, slave_iface, sanitized_config); + g_free (sanitized_config); if (err != 0) { nm_log_err (LOGD_TEAM, "(%s): failed to update config for port %s (err=%d)", iface, slave_iface, err); From 08ed6c5be23dea47043f8b49e8e8d65584011bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Wed, 5 Mar 2014 13:59:17 +0100 Subject: [PATCH 2/2] cli: sanitize team config before setting it into property Replace '\r' and '\n' chareacter with a space in the configuration. libteamdctl sends the config to team daemon using its usock interface that separates parameters with '\n'. Related: rh #1051517 --- cli/src/common.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/src/common.c b/cli/src/common.c index 6f6d0c0838..2dd59bdbcb 100644 --- a/cli/src/common.c +++ b/cli/src/common.c @@ -907,6 +907,17 @@ nmc_bond_validate_mode (const char *mode, GError **error) return nmc_string_is_valid (mode, valid_modes, error); } +/* + * nmc_team_check_config: + * @config: file name with team config, or raw team JSON config data + * @out_config: raw team JSON config data (with removed new-line characters) + * @error: location to store error, or %NUL + * + * Check team config from @config parameter and return the checked/sanitized + * config in @out_config. + * + * Returns: %TRUE if the config is valid, %FALSE if it is invalid + */ gboolean nmc_team_check_config (const char *config, char **out_config, GError **error) { @@ -936,7 +947,7 @@ nmc_team_check_config (const char *config, char **out_config, GError **error) g_free (contents); return FALSE; } - *out_config = contents; + *out_config = g_strdelimit (contents, "\r\n", ' '); return TRUE; }