ubusd_acl: add support for wildcard in methods
[project/ubus.git] / ubusd_event.c
index 6e612a19070b19a2a65577a3143aefeeeab532d9..ef433f81a71ec6395eb5d40df32c928233db6cb2 100644 (file)
@@ -35,10 +35,9 @@ static void ubusd_delete_event_source(struct event_source *evs)
 
 void ubusd_event_cleanup_object(struct ubus_object *obj)
 {
-       struct event_source *ev;
+       struct event_source *ev, *tmp;
 
-       while (!list_empty(&obj->events)) {
-               ev = list_first_entry(&obj->events, struct event_source, list);
+       list_for_each_entry_safe(ev, tmp, &obj->events, list) {
                ubusd_delete_event_source(ev);
        }
 }
@@ -142,6 +141,9 @@ int ubusd_send_event(struct ubus_client *cl, const char *id,
        struct event_source *ev;
        int match_len = 0;
 
+       if (ubusd_acl_check(cl, id, NULL, UBUS_ACL_SEND))
+               return UBUS_STATUS_PERMISSION_DENIED;
+
        obj_event_seq++;
 
        /*
@@ -164,7 +166,7 @@ int ubusd_send_event(struct ubus_client *cl, const char *id,
                        if (!ev->partial)
                                continue;
 
-                       if (match_len != strlen(key))
+                       if (match_len != (int) strlen(key))
                                continue;
                }