Commit 395c385b authored by Lubomir Rintel's avatar Lubomir Rintel 🥕

libnm-core: don't serialize synthetic properties in nm_setting_to_string()

Fixes: f957ea2b

https://github.com/NetworkManager/NetworkManager/pull/245
parent 32857a09
Pipeline #7825 passed with stages
in 13 minutes and 5 seconds
......@@ -121,6 +121,8 @@ typedef enum { /*< flags >*/
NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
/* 0x80000000 is used for a private flag */
} NMConnectionSerializationFlags;
GVariant *nm_connection_to_dbus (NMConnection *connection,
......
......@@ -174,6 +174,13 @@ NMSettingPriority _nm_setting_get_setting_priority (NMSetting *setting);
gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
/* NM_CONNECTION_SERIALIZE_NO_SYNTH: This flag is passed to _nm_setting_to_dbus()
* by nm_setting_to_string() to let it know that it shouldn't serialize the
* synthetic properties. It wouldn't be able to do so, since the full connection
* is not available, only the setting alone.
*/
#define NM_CONNECTION_SERIALIZE_NO_SYNTH ((NMConnectionSerializationFlags) 0x80000000)
/*****************************************************************************/
GHashTable *_nm_setting_gendata_hash (NMSetting *setting,
......
......@@ -685,10 +685,15 @@ _nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, NMConnectionS
continue;
}
if (property->synth_func)
dbus_value = property->synth_func (setting, connection, property->name);
else
if (property->synth_func) {
if (!(flags & NM_CONNECTION_SERIALIZE_NO_SYNTH))
dbus_value = property->synth_func (setting, connection, property->name);
else
dbus_value = NULL;
} else {
dbus_value = get_property_for_dbus (setting, property, TRUE);
}
if (dbus_value) {
/* Allow dbus_value to be either floating or not. */
g_variant_take_ref (dbus_value);
......@@ -2013,7 +2018,8 @@ nm_setting_to_string (NMSetting *setting)
string = g_string_new (nm_setting_get_name (setting));
g_string_append_c (string, '\n');
variant = _nm_setting_to_dbus (setting, NULL, NM_CONNECTION_SERIALIZE_ALL);
variant = _nm_setting_to_dbus (setting, NULL, NM_CONNECTION_SERIALIZE_ALL
| NM_CONNECTION_SERIALIZE_NO_SYNTH);
g_variant_iter_init (&iter, variant);
while ((child = g_variant_iter_next_value (&iter))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment