mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 15:50:07 +01:00
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.
This commit is contained in:
parent
74ed416d84
commit
fe96dbc0ee
2 changed files with 14 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue