auth-chain: split handling auth-call in idle
auth_call_complete() had two callers: once from the idle handler, and once from pk_call_cb(). The conditions are slightly different, split the function in two. For one, this allows to unset the obsolete call_idle_id.
This commit is contained in:
@@ -62,6 +62,16 @@ typedef struct {
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ASSERT_call (AuthCall *call)
|
||||||
|
{
|
||||||
|
nm_assert (call);
|
||||||
|
nm_assert (call->chain);
|
||||||
|
nm_assert (nm_c_list_contains_entry (&call->chain->auth_call_lst_head, call, auth_call_lst));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
auth_call_free (AuthCall *call)
|
auth_call_free (AuthCall *call)
|
||||||
{
|
{
|
||||||
@@ -207,18 +217,15 @@ auth_chain_finish (gpointer user_data)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
auth_call_complete (AuthCall *call)
|
auth_call_complete (AuthCall *call)
|
||||||
{
|
{
|
||||||
NMAuthChain *self;
|
NMAuthChain *self;
|
||||||
|
|
||||||
nm_assert (call);
|
_ASSERT_call (call);
|
||||||
|
|
||||||
self = call->chain;
|
self = call->chain;
|
||||||
|
|
||||||
nm_assert (self);
|
|
||||||
nm_assert (nm_c_list_contains_entry (&self->auth_call_lst_head, call, auth_call_lst));
|
|
||||||
|
|
||||||
c_list_unlink (&call->auth_call_lst);
|
c_list_unlink (&call->auth_call_lst);
|
||||||
|
|
||||||
if (c_list_is_empty (&self->auth_call_lst_head)) {
|
if (c_list_is_empty (&self->auth_call_lst_head)) {
|
||||||
@@ -227,6 +234,17 @@ auth_call_complete (AuthCall *call)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auth_call_free (call);
|
auth_call_free (call);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
auth_call_complete_idle_cb (gpointer user_data)
|
||||||
|
{
|
||||||
|
AuthCall *call = user_data;
|
||||||
|
|
||||||
|
_ASSERT_call (call);
|
||||||
|
|
||||||
|
call->call_idle_id = 0;
|
||||||
|
auth_call_complete (call);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +316,7 @@ nm_auth_chain_add_call (NMAuthChain *self,
|
|||||||
|| !nm_auth_manager_get_polkit_enabled (auth_manager)) {
|
|| !nm_auth_manager_get_polkit_enabled (auth_manager)) {
|
||||||
/* Root user or non-polkit always gets the permission */
|
/* Root user or non-polkit always gets the permission */
|
||||||
nm_auth_chain_set_data (self, permission, GUINT_TO_POINTER (NM_AUTH_CALL_RESULT_YES), NULL);
|
nm_auth_chain_set_data (self, permission, GUINT_TO_POINTER (NM_AUTH_CALL_RESULT_YES), NULL);
|
||||||
call->call_idle_id = g_idle_add ((GSourceFunc) auth_call_complete, call);
|
call->call_idle_id = g_idle_add (auth_call_complete_idle_cb, call);
|
||||||
} else {
|
} else {
|
||||||
/* Non-root always gets authenticated when using polkit */
|
/* Non-root always gets authenticated when using polkit */
|
||||||
#if WITH_POLKIT
|
#if WITH_POLKIT
|
||||||
@@ -316,7 +334,7 @@ nm_auth_chain_add_call (NMAuthChain *self,
|
|||||||
NM_MANAGER_ERROR_FAILED,
|
NM_MANAGER_ERROR_FAILED,
|
||||||
"Polkit support is disabled at compile time");
|
"Polkit support is disabled at compile time");
|
||||||
}
|
}
|
||||||
call->call_idle_id = g_idle_add ((GSourceFunc) auth_call_complete, call);
|
call->call_idle_id = g_idle_add (auth_call_complete_idle_cb, call);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user