- uh_foreach_matching_acl_prefix(acl, ses, object, function) {
- if (!strcmp(acl->object, object) &&
- !strcmp(acl->function, function))
- return 0;
+ acl_scope = avl_find_element(&ses->acls, scope, acl_scope, avl);
+
+ if (acl_scope) {
+ uh_foreach_matching_acl_prefix(acl, &acl_scope->acls, object, function) {
+ if (!strcmp(acl->object, object) &&
+ !strcmp(acl->function, function))
+ return 0;
+ }
+ }
+
+ if (!acl_scope) {
+ acl_scope = calloc_a(sizeof(*acl_scope),
+ &new_scope, strlen(scope) + 1);
+
+ if (!acl_scope)
+ return UBUS_STATUS_UNKNOWN_ERROR;
+
+ acl_scope->avl.key = strcpy(new_scope, scope);
+ avl_init(&acl_scope->acls, avl_strcmp, true, NULL);
+ avl_insert(&ses->acls, &acl_scope->avl);