diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-01-19 19:45:25 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2014-01-19 19:45:25 +0000 |
commit | 967d815022082a63e1489b5eda5e7a9d7a9d5e82 (patch) | |
tree | 436964d75762822d666f0a32b436ba065778ff03 | |
parent | 49f6e218a4bb4cc68ba7fdceae0badaa7726685f (diff) | |
download | rpcd-967d815022082a63e1489b5eda5e7a9d7a9d5e82.tar.gz |
session: make object and function arguments of session.access optional, dump effective acls in this case
-rw-r--r-- | session.c | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -580,22 +580,31 @@ rpc_handle_access(struct ubus_context *ctx, struct ubus_object *obj, blobmsg_parse(perm_policy, __RPC_SP_MAX, tb, blob_data(msg), blob_len(msg)); - if (!tb[RPC_SP_SID] || !tb[RPC_SP_OBJECT] || !tb[RPC_SP_FUNCTION]) + if (!tb[RPC_SP_SID]) return UBUS_STATUS_INVALID_ARGUMENT; ses = rpc_session_get(blobmsg_data(tb[RPC_SP_SID])); if (!ses) return UBUS_STATUS_NOT_FOUND; - if (tb[RPC_SP_SCOPE]) - scope = blobmsg_data(tb[RPC_SP_SCOPE]); + blob_buf_init(&buf, 0); - allow = rpc_session_acl_allowed(ses, scope, - blobmsg_data(tb[RPC_SP_OBJECT]), - blobmsg_data(tb[RPC_SP_FUNCTION])); + if (tb[RPC_SP_OBJECT] && tb[RPC_SP_FUNCTION]) + { + if (tb[RPC_SP_SCOPE]) + scope = blobmsg_data(tb[RPC_SP_SCOPE]); + + allow = rpc_session_acl_allowed(ses, scope, + blobmsg_data(tb[RPC_SP_OBJECT]), + blobmsg_data(tb[RPC_SP_FUNCTION])); + + blobmsg_add_u8(&buf, "access", allow); + } + else + { + rpc_session_dump_acls(ses, &buf); + } - blob_buf_init(&buf, 0); - blobmsg_add_u8(&buf, "access", allow); ubus_send_reply(ctx, req, buf.head); return 0; |