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:
@@ -3316,17 +3316,20 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1,
|
|||||||
GVariant *
|
GVariant *
|
||||||
_nm_utils_hwaddr_to_dbus (const GValue *prop_value)
|
_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];
|
guint8 buf[NM_UTILS_HWADDR_LEN_MAX];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (str) {
|
str = g_value_get_string (prop_value);
|
||||||
len = hwaddr_binary_len (str);
|
if (!str)
|
||||||
g_return_val_if_fail (len > 0 && len <= NM_UTILS_HWADDR_LEN_MAX, NULL);
|
return NULL;
|
||||||
if (!nm_utils_hwaddr_aton (str, buf, len))
|
|
||||||
len = 0;
|
len = _nm_utils_hwaddr_length (str);
|
||||||
} else
|
if (len == 0)
|
||||||
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);
|
return g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, buf, len, 1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user