Commit fe96dbc0 authored by Dan Williams's avatar Dan Williams Committed by Lubomir Rintel

settings/dbus: harden connection removal and object unexport

None of these functions was checking if the same operation had already
been performed, or if the object being removed/unexported was known.
parent 74ed416d
......@@ -96,6 +96,8 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct {
gboolean removed;
NMAgentManager *agent_mgr;
guint session_changed_id;
......@@ -1743,6 +1745,12 @@ impl_settings_connection_clear_secrets (NMSettingsConnection *self,
void
nm_settings_connection_signal_remove (NMSettingsConnection *self)
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
if (priv->removed)
g_return_if_reached ();
priv->removed = TRUE;
/* Emit removed first */
g_signal_emit_by_name (self, NM_SETTINGS_CONNECTION_REMOVED);
......
......@@ -808,6 +808,11 @@ static void
connection_removed (NMSettingsConnection *connection, gpointer user_data)
{
NMSettings *self = NM_SETTINGS (user_data);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
const char *cpath = nm_connection_get_path (NM_CONNECTION (connection));
if (!g_hash_table_lookup (priv->connections, cpath))
g_return_if_reached ();
g_object_ref (connection);
......@@ -823,8 +828,7 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data)
g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_ready_changed), self);
/* Forget about the connection internally */
g_hash_table_remove (NM_SETTINGS_GET_PRIVATE (user_data)->connections,
(gpointer) nm_connection_get_path (NM_CONNECTION (connection)));
g_hash_table_remove (priv->connections, (gpointer) cpath);
/* Notify D-Bus */
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connection);
......
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