summaryrefslogtreecommitdiffstats
path: root/src/afb-hook.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-11-29 11:12:31 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2019-12-03 18:51:51 +0100
commitb70caad7da2eaea85db06dec8377b1cbebcec997 (patch)
tree32e3cfa6b7da57ced019357d8f592b0d90dd7563 /src/afb-hook.c
parent98b214e0454f1b55c5ce665bd5c848354d18c9e6 (diff)
afb-context: Move credentials to context
The split between context and credentials in requests was somehow artificial and awkward. This change move the credentials to the context and removes as many references to credentials as possible in favor of working on contexts. Change the value returned by afb_auth_check to be 1 if validated, 0 or less than zero if not validated. Bug-AGL: SPEC-2968 Signed-off-by: José Bollo <jose.bollo@iot.bzh> Change-Id: I979dc841e03247e126e3fa8433a1cc0d4108adf0
Diffstat (limited to 'src/afb-hook.c')
-rw-r--r--src/afb-hook.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/afb-hook.c b/src/afb-hook.c
index 1379caf8..909c5126 100644
--- a/src/afb-hook.c
+++ b/src/afb-hook.c
@@ -217,16 +217,18 @@ static void _hook_xreq_(const struct afb_xreq *xreq, const char *format, ...)
static void hook_xreq_begin_cb(void *closure, const struct afb_hookid *hookid, const struct afb_xreq *xreq)
{
- if (!xreq->cred)
+ struct afb_cred *cred = xreq->context.credentials;
+
+ if (!cred)
_hook_xreq_(xreq, "BEGIN");
else
_hook_xreq_(xreq, "BEGIN uid=%d=%s gid=%d pid=%d label=%s id=%s",
- (int)xreq->cred->uid,
- xreq->cred->user,
- (int)xreq->cred->gid,
- (int)xreq->cred->pid,
- xreq->cred->label?:"(null)",
- xreq->cred->id?:"(null)"
+ (int)cred->uid,
+ cred->user,
+ (int)cred->gid,
+ (int)cred->pid,
+ cred->label?:"(null)",
+ cred->id?:"(null)"
);
}