summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2013-11-22 17:04:23 +0100
committerThomas Haller <thaller@redhat.com>2013-11-22 18:13:29 +0100
commit81a93820ec0c19aa770c4894224873d3bf832b22 (patch)
tree18a058c0d7248767760dd3b75a490aa7903dba7c
parentd2e0e1dacce391ad5110b6aa84f7fe3b524f2bef (diff)
downloadNetworkManager-81a93820ec0c19aa770c4894224873d3bf832b22.tar.gz
core: nm-manager-auth.c: make cancellable only when needed
The cancellable is only needed when calling polkit_authority_check_authorization(). AuthCall objects are either passed on for cleanup to g_idle_add or to polkit. Not both at the same time, so this also makes it clear, which type we have at hand. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/nm-manager-auth.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nm-manager-auth.c b/src/nm-manager-auth.c
index b5b9fc717b..7380578b41 100644
--- a/src/nm-manager-auth.c
+++ b/src/nm-manager-auth.c
@@ -326,7 +326,6 @@ auth_call_new (NMAuthChain *chain, const char *permission)
call = g_malloc0 (sizeof (AuthCall));
call->chain = chain;
call->permission = g_strdup (permission);
- call->cancellable = g_cancellable_new ();
chain->calls = g_slist_append (chain->calls, call);
return call;
}
@@ -335,7 +334,8 @@ static void
auth_call_cancel (AuthCall *call)
{
call->disposed = TRUE;
- g_cancellable_cancel (call->cancellable);
+ if (call->cancellable)
+ g_cancellable_cancel (call->cancellable);
}
static void
@@ -344,7 +344,7 @@ auth_call_free (AuthCall *call)
g_return_if_fail (call != NULL);
g_free (call->permission);
- g_object_unref (call->cancellable);
+ g_clear_object (&call->cancellable);
if (call->call_idle_id)
g_source_remove (call->call_idle_id);
memset (call, 0, sizeof (*call));
@@ -454,6 +454,7 @@ _add_call_polkit (NMAuthChain *self,
if (allow_interaction)
flags = POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION;
+ call->cancellable = g_cancellable_new ();
polkit_authority_check_authorization (self->authority,
subject,
permission,