Fix an assertion failure in nmcli (rh #1244048)
This commit is contained in:
parent
802930598f
commit
5088926494
@ -0,0 +1,26 @@
|
||||
From 3af6be7aa6f591a5d9889bd76a589ad3cd58a009 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
|
||||
Date: Fri, 17 Jul 2015 09:20:29 +0200
|
||||
Subject: [PATCH 1/2] docs: fix a copy/paste error in description of VLAN flags
|
||||
|
||||
(cherry picked from commit 2af10ef4442311f08f30afc358b203a11c4c12b0)
|
||||
---
|
||||
libnm-core/nm-setting-vlan.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c
|
||||
index f622ddc..d904ad5 100644
|
||||
--- a/libnm-core/nm-setting-vlan.c
|
||||
+++ b/libnm-core/nm-setting-vlan.c
|
||||
@@ -742,7 +742,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
|
||||
* property: flags
|
||||
* variable: VLAN_FLAGS, REORDER_HDR
|
||||
* values: "GVRP", "LOOSE_BINDING" for VLAN_FLAGS; 0 or 1 for REORDER_HDR
|
||||
- * description: Parent interface of the VLAN.
|
||||
+ * description: VLAN flags.
|
||||
* ---end---
|
||||
*/
|
||||
g_object_class_install_property
|
||||
--
|
||||
2.4.3
|
||||
|
123
0002-cli-fix-verifying-flag-based-properties-rh-1244048.patch
Normal file
123
0002-cli-fix-verifying-flag-based-properties-rh-1244048.patch
Normal file
@ -0,0 +1,123 @@
|
||||
From 439ff3841d7b0aa845d7638b2bc732ecc89d2894 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
|
||||
Date: Fri, 17 Jul 2015 11:24:31 +0200
|
||||
Subject: [PATCH 2/2] cli: fix verifying flag-based properties (rh #1244048)
|
||||
|
||||
Some of the properties changed from GParamSpecUInt to GParamSpecFlags, namely
|
||||
NM_SETTING_VLAN_FLAGS
|
||||
NM_SETTING_DCB_APP_FCOE_FLAGS
|
||||
NM_SETTING_DCB_APP_ISCSI_FLAGS
|
||||
NM_SETTING_DCB_APP_FIP_FLAGS
|
||||
NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS
|
||||
NM_SETTING_DCB_PRIORITY_GROUP_FLAGS
|
||||
|
||||
(commit fcfb4b40badbb5cd944cee0c9819cb2649d0bb58)
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1244048
|
||||
|
||||
(cherry picked from commit 94b1b53a913650b5dd027181fecc08ce5ad8654d)
|
||||
---
|
||||
clients/cli/settings.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
1 file changed, 63 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
|
||||
index 66e6f62..66759df 100644
|
||||
--- a/clients/cli/settings.c
|
||||
+++ b/clients/cli/settings.c
|
||||
@@ -2034,6 +2034,46 @@ validate_uint (NMSetting *setting, const char* prop, guint val, GError **error)
|
||||
return success;
|
||||
}
|
||||
|
||||
+static char *
|
||||
+flag_values_to_string (GFlagsValue *array, guint n)
|
||||
+{
|
||||
+ GString *str;
|
||||
+ guint i;
|
||||
+
|
||||
+ str = g_string_new (NULL);
|
||||
+ for (i = 0; i < n; i++)
|
||||
+ g_string_append_printf (str, "%u, ", array[i].value);
|
||||
+ if (str->len)
|
||||
+ g_string_truncate (str, str->len-2); /* chop off trailing ', ' */
|
||||
+ return g_string_free (str, FALSE);
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+validate_flags (NMSetting *setting, const char* prop, guint val, GError **error)
|
||||
+{
|
||||
+ GParamSpec *pspec;
|
||||
+ GValue value = G_VALUE_INIT;
|
||||
+ gboolean success = TRUE;
|
||||
+
|
||||
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
|
||||
+ g_assert (G_IS_PARAM_SPEC (pspec));
|
||||
+
|
||||
+ g_value_init (&value, pspec->value_type);
|
||||
+ g_value_set_flags (&value, val);
|
||||
+
|
||||
+ if (g_param_value_validate (pspec, &value)) {
|
||||
+ GParamSpecFlags *pspec_flags = (GParamSpecFlags *) pspec;
|
||||
+ char *flag_values = flag_values_to_string (pspec_flags->flags_class->values,
|
||||
+ pspec_flags->flags_class->n_values);
|
||||
+ g_set_error (error, 1, 0, _("'%u' flags are not valid; use combination of %s"),
|
||||
+ val, flag_values);
|
||||
+ g_free (flag_values);
|
||||
+ success = FALSE;
|
||||
+ }
|
||||
+ g_value_unset (&value);
|
||||
+ return success;
|
||||
+}
|
||||
+
|
||||
static gboolean
|
||||
check_and_set_string (NMSetting *setting,
|
||||
const char *prop,
|
||||
@@ -2257,6 +2297,26 @@ nmc_property_set_int64 (NMSetting *setting, const char *prop, const char *val, G
|
||||
}
|
||||
|
||||
static gboolean
|
||||
+nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
+{
|
||||
+ unsigned long val_int;
|
||||
+
|
||||
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
+
|
||||
+ if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) {
|
||||
+ g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ /* Validate the flags according to the property spec */
|
||||
+ if (!validate_flags (setting, prop, (guint) val_int, error))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_object_set (setting, prop, (guint) val_int, NULL);
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
{
|
||||
gboolean val_bool;
|
||||
@@ -4495,8 +4555,8 @@ nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *va
|
||||
g_strfreev (strv);
|
||||
}
|
||||
|
||||
- /* Validate the number according to the property spec */
|
||||
- if (!validate_uint (setting, prop, (guint) flags, error))
|
||||
+ /* Validate the flags according to the property spec */
|
||||
+ if (!validate_flags (setting, prop, (guint) flags, error))
|
||||
return FALSE;
|
||||
|
||||
g_object_set (setting, prop, (guint) flags, NULL);
|
||||
@@ -5927,7 +5987,7 @@ nmc_properties_init (void)
|
||||
NULL);
|
||||
nmc_add_prop_funcs (GLUE (VLAN, FLAGS),
|
||||
nmc_property_vlan_get_flags,
|
||||
- nmc_property_set_uint,
|
||||
+ nmc_property_set_flags,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
--
|
||||
2.4.3
|
||||
|
@ -89,6 +89,10 @@ Source4: 20-connectivity-fedora.conf
|
||||
# Not upstream.
|
||||
Patch0: 0000-explain-dns1-dns2.patch
|
||||
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1244048
|
||||
Patch1: 0001-docs-fix-a-copy-paste-error-in-description-of-VLAN-f.patch
|
||||
Patch2: 0002-cli-fix-verifying-flag-based-properties-rh-1244048.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
%if 0%{?fedora} && 0%{?fedora} < 20
|
||||
@ -367,6 +371,10 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
|
||||
|
||||
%patch0 -p1 -b .0000-explain-dns1-dns2.orig
|
||||
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1244048
|
||||
%patch1 -p1 -b .docs-fix-a-copy-paste-error-in-description-of-VLAN-f.patch
|
||||
%patch2 -p1 -b .cli-fix-verifying-flag-based-properties-rh-1244048.patch
|
||||
|
||||
%build
|
||||
|
||||
%if %{regen_docs}
|
||||
@ -684,6 +692,9 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Jul 14 2015 Lubomir Rintel <lkundrak@v3.sk> - 1:1.0.4-2
|
||||
- Fix an assertion failure in nmcli (rh #1244048)
|
||||
|
||||
* Tue Jul 14 2015 Lubomir Rintel <lkundrak@v3.sk> - 1:1.0.4-1
|
||||
- Update to 1.0.4 release
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user