libnm: merge branch 'th/empty-cloned-mac-address-rh1372799'
https://bugzilla.redhat.com/show_bug.cgi?id=1372799
This commit is contained in:
@@ -201,7 +201,8 @@ nmt_mac_entry_get_property (GObject *object,
|
|||||||
g_value_set_int (value, priv->mac_length);
|
g_value_set_int (value, priv->mac_length);
|
||||||
break;
|
break;
|
||||||
case PROP_MAC_ADDRESS:
|
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;
|
break;
|
||||||
case PROP_ENTRY_TYPE:
|
case PROP_ENTRY_TYPE:
|
||||||
g_value_set_int (value, priv->entry_type);
|
g_value_set_int (value, priv->entry_type);
|
||||||
|
@@ -2915,15 +2915,6 @@ set_cert_prop_helper (const GValue *value, const char *prop_name, GError **error
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
_g_value_dup_string_not_empty (const GValue *value)
|
|
||||||
{
|
|
||||||
const gchar *str;
|
|
||||||
|
|
||||||
str = g_value_get_string (value);
|
|
||||||
return str && str[0] ? g_strdup (str) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_property (GObject *object, guint prop_id,
|
set_property (GObject *object, guint prop_id,
|
||||||
const GValue *value, GParamSpec *pspec)
|
const GValue *value, GParamSpec *pspec)
|
||||||
@@ -2964,7 +2955,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
break;
|
break;
|
||||||
case PROP_SUBJECT_MATCH:
|
case PROP_SUBJECT_MATCH:
|
||||||
g_free (priv->subject_match);
|
g_free (priv->subject_match);
|
||||||
priv->subject_match = _g_value_dup_string_not_empty (value);
|
priv->subject_match = nm_strdup_not_empty (g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_ALTSUBJECT_MATCHES:
|
case PROP_ALTSUBJECT_MATCHES:
|
||||||
g_slist_free_full (priv->altsubject_matches, g_free);
|
g_slist_free_full (priv->altsubject_matches, g_free);
|
||||||
@@ -2972,7 +2963,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
break;
|
break;
|
||||||
case PROP_DOMAIN_SUFFIX_MATCH:
|
case PROP_DOMAIN_SUFFIX_MATCH:
|
||||||
g_free (priv->domain_suffix_match);
|
g_free (priv->domain_suffix_match);
|
||||||
priv->domain_suffix_match = _g_value_dup_string_not_empty (value);
|
priv->domain_suffix_match = nm_strdup_not_empty (g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_CLIENT_CERT:
|
case PROP_CLIENT_CERT:
|
||||||
if (priv->client_cert)
|
if (priv->client_cert)
|
||||||
@@ -3018,7 +3009,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
break;
|
break;
|
||||||
case PROP_PHASE2_SUBJECT_MATCH:
|
case PROP_PHASE2_SUBJECT_MATCH:
|
||||||
g_free (priv->phase2_subject_match);
|
g_free (priv->phase2_subject_match);
|
||||||
priv->phase2_subject_match = _g_value_dup_string_not_empty (value);
|
priv->phase2_subject_match = nm_strdup_not_empty (g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_PHASE2_ALTSUBJECT_MATCHES:
|
case PROP_PHASE2_ALTSUBJECT_MATCHES:
|
||||||
g_slist_free_full (priv->phase2_altsubject_matches, g_free);
|
g_slist_free_full (priv->phase2_altsubject_matches, g_free);
|
||||||
@@ -3026,7 +3017,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
break;
|
break;
|
||||||
case PROP_PHASE2_DOMAIN_SUFFIX_MATCH:
|
case PROP_PHASE2_DOMAIN_SUFFIX_MATCH:
|
||||||
g_free (priv->phase2_domain_suffix_match);
|
g_free (priv->phase2_domain_suffix_match);
|
||||||
priv->phase2_domain_suffix_match = _g_value_dup_string_not_empty (value);
|
priv->phase2_domain_suffix_match = nm_strdup_not_empty (g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_PHASE2_CLIENT_CERT:
|
case PROP_PHASE2_CLIENT_CERT:
|
||||||
if (priv->phase2_client_cert)
|
if (priv->phase2_client_cert)
|
||||||
|
@@ -3425,7 +3425,22 @@ _nm_utils_hwaddr_cloned_data_synth (NMSetting *setting,
|
|||||||
"cloned-mac-address",
|
"cloned-mac-address",
|
||||||
&addr,
|
&addr,
|
||||||
NULL);
|
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
|
gboolean
|
||||||
@@ -3443,7 +3458,7 @@ _nm_utils_hwaddr_cloned_data_set (NMSetting *setting,
|
|||||||
|
|
||||||
g_object_set (setting,
|
g_object_set (setting,
|
||||||
"cloned-mac-address",
|
"cloned-mac-address",
|
||||||
g_variant_get_string (value, NULL),
|
nm_str_not_empty (g_variant_get_string (value, NULL)),
|
||||||
NULL);
|
NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -302,6 +302,22 @@ _NM_IN_STRSET_streq (const char *x, const char *s)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define nm_str_not_empty(str) \
|
||||||
|
({ \
|
||||||
|
/* implemented as macro to preserve constness */ \
|
||||||
|
typeof (str) __str = (str); \
|
||||||
|
_nm_unused const char *__str_type_check = __str; \
|
||||||
|
((__str && __str[0]) ? __str : ((char *) NULL)); \
|
||||||
|
})
|
||||||
|
|
||||||
|
static inline char *
|
||||||
|
nm_strdup_not_empty (const char *str)
|
||||||
|
{
|
||||||
|
return str && str[0] ? g_strdup (str) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define NM_PRINT_FMT_QUOTED(cond, prefix, str, suffix, str_else) \
|
#define NM_PRINT_FMT_QUOTED(cond, prefix, str, suffix, str_else) \
|
||||||
(cond) ? (prefix) : "", \
|
(cond) ? (prefix) : "", \
|
||||||
(cond) ? (str) : (str_else), \
|
(cond) ? (str) : (str_else), \
|
||||||
|
Reference in New Issue
Block a user