mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 00:50:12 +01:00
libnm: fix regression serializing empty "cloned-mac-address"
For "cloned-mac-address", the empty string "" is an invalid value that is rejected by verify(). Commit8eed671changed how the property is serialized to D-Bus. Before, it was serialized using _nm_utils_hwaddr_to_dbus(). For invalid or empty addresses, this would not serialize the value on D-Bus (or before commit76aa6f8e0, it would create a bogus value with no array elements). With commit8eed671, the cloned-mac-address gets also serialized as "assigned-mac-address" via _nm_utils_hwaddr_cloned_data_synth(), which would pass on invalid strings that the server would then reject. That breaks for example nmtui. Try editing a connection with "cloned-mac-address" set to NULL. Note, as long as you don't edit the cloned MAC address in nmtui, you can save the modification. Once you start modifying the entry, you can no longer set an empty MAC address as the server now receives the invalid empty string. Thus, the "OK" button fails with Unable to save connection: 802-3-ethernet.cloned-mac-address: is not a valid MAC address It also means, nmtui cannot modify the "cloned-mac-address" field to become empty. Fix that problem at various places by coercing "" to NULL. Fixes:8eed67122chttps://bugzilla.redhat.com/show_bug.cgi?id=1372799 (cherry picked from commit814784aa46)
This commit is contained in:
parent
1fdf026e2d
commit
742bf5671f
2 changed files with 19 additions and 3 deletions
|
|
@ -201,7 +201,8 @@ nmt_mac_entry_get_property (GObject *object,
|
|||
g_value_set_int (value, priv->mac_length);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_string (value, nmt_newt_entry_get_text (NMT_NEWT_ENTRY (object)));
|
||||
g_value_set_string (value,
|
||||
nm_str_not_empty (nmt_newt_entry_get_text (NMT_NEWT_ENTRY (object))));
|
||||
break;
|
||||
case PROP_ENTRY_TYPE:
|
||||
g_value_set_int (value, priv->entry_type);
|
||||
|
|
|
|||
|
|
@ -3425,7 +3425,22 @@ _nm_utils_hwaddr_cloned_data_synth (NMSetting *setting,
|
|||
"cloned-mac-address",
|
||||
&addr,
|
||||
NULL);
|
||||
return addr ? g_variant_new_string (addr) : NULL;
|
||||
|
||||
/* Before introducing the extended "cloned-mac-address" (and its D-Bus
|
||||
* field "assigned-mac-address"), libnm's _nm_utils_hwaddr_to_dbus()
|
||||
* would drop invalid values as it was unable to serialize them.
|
||||
*
|
||||
* Now, we would like to send invalid values as "assigned-mac-address"
|
||||
* over D-Bus and let the server reject them.
|
||||
*
|
||||
* However, clients used to set the cloned-mac-address property
|
||||
* to "" and it just worked as the value was not serialized in
|
||||
* an ill form.
|
||||
*
|
||||
* To preserve that behavior, seralize "" as NULL.
|
||||
*/
|
||||
|
||||
return addr && addr[0] ? g_variant_new_string (addr) : NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -3443,7 +3458,7 @@ _nm_utils_hwaddr_cloned_data_set (NMSetting *setting,
|
|||
|
||||
g_object_set (setting,
|
||||
"cloned-mac-address",
|
||||
g_variant_get_string (value, NULL),
|
||||
nm_str_not_empty (g_variant_get_string (value, NULL)),
|
||||
NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue