session: expose rpc_session_access() function for testing session ACLs in other rpcd...
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 12 Aug 2013 11:51:51 +0000 (13:51 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 12 Aug 2013 11:51:51 +0000 (13:51 +0200)
session.c
session.h

index 35324bfd6c668dd8743d2ac3d63b9e7073333ec5..b43e7638fff193bbe499da802a235977cfcd51f1 100644 (file)
--- 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);
+}
index 0bcae7ba1752eea329433066b3cfa60262122ed3..3f50e779f23bc98ab6a5da112b6af95c19e8943b 100644 (file)
--- 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