libnm: don't check if the agent is still registered when unregistering
authorLubomir Rintel <lkundrak@v3.sk>
Tue, 29 Mar 2016 12:34:26 +0000 (14:34 +0200)
committerLubomir Rintel <lkundrak@v3.sk>
Tue, 29 Mar 2016 13:08:19 +0000 (15:08 +0200)
The name_owner_chagned() unregisters the agent if NetworkManager goes away and
nmc_cleanup() also tries to unregister an agent, resulting in an assertion
failure:

  # nmcli c up conn666
  <daemon terminates>
  Error: Connection activation failed: Message recipient disconnected from message bus without replying
  (process:8746): libnm-CRITICAL **: nm_secret_agent_old_unregister: assertion 'priv->registered == TRUE' failed

_internal_unregister() already contains a priv->registered check and raising an
error on duplicate unregister attempt from a daemon after a restart is not a
problem either, since nmc_cleanup() doesn't care about the error returned
on teardown anyway.

libnm/nm-secret-agent-old.c

index 60b7a62..02a3f68 100644 (file)
@@ -746,9 +746,6 @@ nm_secret_agent_old_register_finish (NMSecretAgentOld *self,
  * indicating to NetworkManager that the agent will no longer provide or
  * store secrets on behalf of this user.
  *
- * It is a programmer error to attempt to unregister an agent that is not
- * registered.
- *
  * Returns: %TRUE if unregistration was successful, %FALSE on error
  **/
 gboolean
@@ -763,7 +760,6 @@ nm_secret_agent_old_unregister (NMSecretAgentOld *self,
 
        priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self);
 
-       g_return_val_if_fail (priv->registered == TRUE, FALSE);
        g_return_val_if_fail (priv->bus != NULL, FALSE);
        g_return_val_if_fail (priv->manager_proxy != NULL, FALSE);
 
@@ -811,9 +807,6 @@ unregister_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
  * Asynchronously unregisters the #NMSecretAgentOld with the NetworkManager secret
  * manager, indicating to NetworkManager that the agent will no longer provide
  * or store secrets on behalf of this user.
- *
- * It is a programmer error to attempt to unregister an agent that is not
- * registered.
  **/
 void
 nm_secret_agent_old_unregister_async (NMSecretAgentOld *self,
@@ -829,7 +822,6 @@ nm_secret_agent_old_unregister_async (NMSecretAgentOld *self,
 
        priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self);
 
-       g_return_if_fail (priv->registered == TRUE);
        g_return_if_fail (priv->bus != NULL);
        g_return_if_fail (priv->manager_proxy != NULL);