From c6985dd5a60bf2aa48f7099cd8cb08edb1c8b561 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 12 Aug 2013 13:51:51 +0200 Subject: [PATCH] session: expose rpc_session_access() function for testing session ACLs in other rpcd subsystems --- session.c | 11 +++++++++++ session.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/session.c b/session.c index 35324bf..b43e763 100644 --- a/session.c +++ b/session.c @@ -709,3 +709,14 @@ int rpc_session_api_init(struct ubus_context *ctx) return ubus_add_object(ctx, &obj); } + +bool rpc_session_access(const char *sid, const char *scope, + const char *object, const char *function) +{ + struct rpc_session *ses = rpc_session_get(sid); + + if (!ses) + return false; + + return rpc_session_acl_allowed(ses, scope, object, function); +} diff --git a/session.h b/session.h index 0bcae7b..3f50e77 100644 --- a/session.h +++ b/session.h @@ -56,4 +56,7 @@ struct rpc_session_acl { int rpc_session_api_init(struct ubus_context *ctx); +bool rpc_session_access(const char *sid, const char *scope, + const char *object, const char *function); + #endif -- 2.30.2