mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 20:45:32 +00:00
libnm: don't serialize empty hardware address on D-Bus
_nm_utils_hwaddr_to_dbus() would serialize invalid hardware addresses as "'cloned-mac-address': <@ay []>". An empty array is treated the same as no hardware address set, so we should not serialize it in the first place. This is a change in behavior on how the connection is exported on D-Bus, but it should not have any bad consequences. We need this as we later want to deprecate the 'cloned-mac-address' D-Bus field and overwrite it via a 'assigned-mac-address' field. In this case, the "<@ay []>" is interfering. While it could be worked around by treating an empty MAC address as "unset", fix it instead and just not serialize it.
This commit is contained in:
parent
83d231776b
commit
76aa6f8e0d
|
@ -3316,17 +3316,20 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1,
|
|||
GVariant *
|
||||
_nm_utils_hwaddr_to_dbus (const GValue *prop_value)
|
||||
{
|
||||
const char *str = g_value_get_string (prop_value);
|
||||
const char *str;
|
||||
guint8 buf[NM_UTILS_HWADDR_LEN_MAX];
|
||||
int len;
|
||||
|
||||
if (str) {
|
||||
len = hwaddr_binary_len (str);
|
||||
g_return_val_if_fail (len > 0 && len <= NM_UTILS_HWADDR_LEN_MAX, NULL);
|
||||
if (!nm_utils_hwaddr_aton (str, buf, len))
|
||||
len = 0;
|
||||
} else
|
||||
len = 0;
|
||||
str = g_value_get_string (prop_value);
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
len = _nm_utils_hwaddr_length (str);
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
|
||||
if (!nm_utils_hwaddr_aton (str, buf, len))
|
||||
return NULL;
|
||||
|
||||
return g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, buf, len, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue