ubusd: simplify/fix avl loop in ubusd_reply_add()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
Felix Fietkau 2015-12-09 19:39:24 +01:00
parent 0eff70a64c
commit 766d49876f

View file

@ -413,26 +413,28 @@ ubusd_reply_add(struct ubus_object *obj)
if (!obj->path.key) if (!obj->path.key)
return; return;
acl = avl_find_ge_element(&ubusd_acls, obj->path.key, acl, avl); acl = avl_find_ge_element(&ubusd_acls, obj->path.key, acl, avl);
while (acl && !avl_is_last(&ubusd_acls, &acl->avl) && avl_for_element_to_last(&ubusd_acls, acl, acl, avl) {
!ubusd_acl_match_path(obj->path.key, acl->avl.key, NULL)) { void *c;
if (acl->priv) { if (!acl->priv)
void *c = blobmsg_open_table(&b, NULL); continue;
blobmsg_add_string(&b, "obj", obj->path.key); if (!ubusd_acl_match_path(obj->path.key, acl->avl.key, NULL))
if (acl->user) continue;
blobmsg_add_string(&b, "user", acl->user);
if (acl->group)
blobmsg_add_string(&b, "group", acl->group);
if (acl->priv) c = blobmsg_open_table(&b, NULL);
blobmsg_add_field(&b, blobmsg_type(acl->priv), "acl", blobmsg_add_string(&b, "obj", obj->path.key);
blobmsg_data(acl->priv), blobmsg_data_len(acl->priv)); if (acl->user)
blobmsg_add_string(&b, "user", acl->user);
if (acl->group)
blobmsg_add_string(&b, "group", acl->group);
blobmsg_close_table(&b, c); blobmsg_add_field(&b, blobmsg_type(acl->priv), "acl",
} blobmsg_data(acl->priv), blobmsg_data_len(acl->priv));
acl = avl_next_element(acl, avl);
blobmsg_close_table(&b, c);
} }
} }
static int ubusd_reply_query(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr, struct blob_attr *msg) static int ubusd_reply_query(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr, struct blob_attr *msg)