diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-11-02 10:33:27 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-11-07 15:36:44 +0100 |
commit | 395c385b9b3dfd469c50144ab7a53b2adf72c2c8 (patch) | |
tree | 6b32fb765fd93d2e3f7505c3244bfd55c0a11532 | |
parent | 32857a093b3ee4aca44e94dbf06f57fbd43d01cc (diff) | |
download | NetworkManager-395c385b9b3dfd469c50144ab7a53b2adf72c2c8.tar.gz |
libnm-core: don't serialize synthetic properties in nm_setting_to_string()
Fixes: f957ea2b343828ad1fa2014bc7a4dedaf854f3bc
https://github.com/NetworkManager/NetworkManager/pull/245
-rw-r--r-- | libnm-core/nm-connection.h | 2 | ||||
-rw-r--r-- | libnm-core/nm-core-internal.h | 7 | ||||
-rw-r--r-- | libnm-core/nm-setting.c | 14 |
3 files changed, 19 insertions, 4 deletions
diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h index 8d64a4cebc..fb1f901cc6 100644 --- a/libnm-core/nm-connection.h +++ b/libnm-core/nm-connection.h @@ -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, diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index bd004d195e..6ffa484465 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -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, diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index e5e9ab9655..4324f0a4dc 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -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))) { |