From eea23747ce812260dd78a4a5d859945af48235fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Wed, 19 Jun 2013 17:45:52 +0200 Subject: [PATCH] ifcfg-rh: fix storing connections in the hash table We have to copy the UUID (key) because otherwise the pointer can be invalidated when the connection is destroyed and problems will start. The issue showed up as an unability to delete a conenction via D-Bus. Reproducer: $ nmcli con add type eth con-name AAA ifname blah $ nmcli con delete AAA $ nmcli con add type eth con-name AAA ifname blah $ nmcli con delete AAA -- here the connection is not removed from NM (even though ifcfg- file) was removed -- --- src/settings/plugins/ifcfg-rh/plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index 034737c6d6..b7a8751943 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -145,7 +145,7 @@ _internal_new_connection (SCPluginIfcfg *self, g_assert (cid); g_hash_table_insert (priv->connections, - (gpointer) nm_connection_get_uuid (NM_CONNECTION (connection)), + g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), connection); PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", cid); @@ -733,7 +733,7 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin) GFile *file; GFileMonitor *monitor; - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); + priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); /* We watch SC_NETWORK_FILE via NMInotifyHelper (which doesn't track file creation but * *does* track modifications made via other hard links), since we expect it to always