Rename from "luci-rpcd" to "rpcd"
[project/rpcd.git] / session.c
index 9f42226..d970d45 100644 (file)
--- a/session.c
+++ b/session.c
@@ -1,5 +1,5 @@
 /*
 /*
- * luci-rpcd - LuCI UBUS RPC server
+ * rpcd - UBUS RPC server
  *
  *   Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
  *
  *   Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
@@ -142,6 +142,7 @@ rpc_session_dump_acls(struct rpc_session *ses, struct blob_buf *b)
                {
                        if (c) blobmsg_close_table(b, c);
                        c = blobmsg_open_table(b, acl_scope->avl.key);
                {
                        if (c) blobmsg_close_table(b, c);
                        c = blobmsg_open_table(b, acl_scope->avl.key);
+                       lastobj = NULL;
                }
 
                d = NULL;
                }
 
                d = NULL;
@@ -708,3 +709,14 @@ int rpc_session_api_init(struct ubus_context *ctx)
 
        return ubus_add_object(ctx, &obj);
 }
 
        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);
+}