summaryrefslogtreecommitdiff
path: root/src/nm-auth-utils.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-09 17:03:58 +0200
committerThomas Haller <thaller@redhat.com>2018-04-13 09:09:46 +0200
commitf0bddb44e03aed9d9ca8be0bf63d46dd7ebda15c (patch)
treee8236143f13924807f23931b611a01faa2566913 /src/nm-auth-utils.c
parent798b2a7527bddadcec37b48183da313fbc961e45 (diff)
downloadNetworkManager-f0bddb44e03aed9d9ca8be0bf63d46dd7ebda15c.tar.gz
auth-manager: add helper function nm_auth_call_result_eval()
This makes NMAuthCallResult not only usable from within a NMAuthChain. It makes sense to just call nm-auth-manager directly, but then we need a way to convert the more detailed result into an NMAuthCallResult value.
Diffstat (limited to 'src/nm-auth-utils.c')
-rw-r--r--src/nm-auth-utils.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/nm-auth-utils.c b/src/nm-auth-utils.c
index 83206352cd..c04dd987a0 100644
--- a/src/nm-auth-utils.c
+++ b/src/nm-auth-utils.c
@@ -247,7 +247,7 @@ pk_call_cb (NMAuthManager *auth_manager,
gpointer user_data)
{
AuthCall *call;
- NMAuthCallResult call_result = NM_AUTH_CALL_RESULT_UNKNOWN;
+ NMAuthCallResult call_result;
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
return;
@@ -262,17 +262,10 @@ pk_call_cb (NMAuthManager *auth_manager,
/* Don't ruin the chain. Just leave the result unknown. */
nm_log_warn (LOGD_CORE, "error requesting auth for %s: %s",
call->permission, error->message);
- } else {
- if (is_authorized) {
- /* Caller has the permission */
- call_result = NM_AUTH_CALL_RESULT_YES;
- } else if (is_challenge) {
- /* Caller could authenticate to get the permission */
- call_result = NM_AUTH_CALL_RESULT_AUTH;
- } else
- call_result = NM_AUTH_CALL_RESULT_NO;
}
+ call_result = nm_auth_call_result_eval (is_authorized, is_challenge, error);
+
nm_auth_chain_set_data (call->chain, call->permission, GUINT_TO_POINTER (call_result), NULL);
auth_call_complete (call);