diff options
author | Thomas Haller <thaller@redhat.com> | 2014-08-23 02:27:53 +0200 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-09-05 09:35:56 -0400 |
commit | 6325c596c093e34d290604e2ef24219427a1078d (patch) | |
tree | b552bb1f07b005376ca651e0d02cccd9a39e8f9b | |
parent | 85909d080f74c85f91f418909def3997fc4e898f (diff) | |
download | NetworkManager-6325c596c093e34d290604e2ef24219427a1078d.tar.gz |
libnm: handle all-default settings in nm_setting_to_hash() properly
Before, _nm_setting_to_dbus() would return NULL instead of an empty
hash. This would be the case, if all properties are default.
When exporting connections via DBUS, we eventually call
_nm_setting_to_dbus() to convert the connection into a hash of hashes.
By _nm_setting_to_hash() converting empty hashes to NULL, the setting
is missing. Not returning empty hashes means that to_dbus() and
new_from_dbus() don't make a valid round-trip conversion.
Fix that by always returning a hash from _nm_setting_to_dbus()
https://bugzilla.gnome.org/show_bug.cgi?id=735255
See-also: 4d32618264d7ca169036347a25f38689cce632f3
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | libnm-core/nm-setting.c | 6 | ||||
-rw-r--r-- | libnm-core/tests/test-secrets.c | 2 |
2 files changed, 1 insertions, 7 deletions
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index f65171f97e..535706d82d 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -744,12 +744,6 @@ _nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, NMConnectionS destroy_gvalue (value); } - /* Don't return empty hashes, except for base types */ - if (g_hash_table_size (hash) < 1 && !_nm_setting_is_base_type (setting)) { - g_hash_table_destroy (hash); - hash = NULL; - } - return hash; } diff --git a/libnm-core/tests/test-secrets.c b/libnm-core/tests/test-secrets.c index 221fc76028..22aa460ebc 100644 --- a/libnm-core/tests/test-secrets.c +++ b/libnm-core/tests/test-secrets.c @@ -678,7 +678,7 @@ test_update_secrets_whole_connection_empty_base_setting (void) connection = wifi_connection_new (); secrets = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); - g_assert_cmpint (g_hash_table_size (secrets), ==, 1); + g_assert_cmpint (g_hash_table_size (secrets), ==, 3); g_assert (g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SETTING_NAME)); success = nm_connection_update_secrets (connection, |