Re: [OpenWrt-Devel] [PATCH libubox] json_script: enable custom expr handler callback
On 2017-05-18 09:39, Denis Osvald wrote: > This wires in custom expression handler functionality, which was > present in json script since the original version, but never used. To add a bit of context: Experimenting with procd service triggers, it was noticed that when adding triggers for a network interface, trigger is activated too often. I saw discussions related to both netifd (as sender of network interface trigger events) and procd side of the problem a few times during past months on the list, e.g.: http://lists.infradead.org/pipermail/lede-dev/2017-April/007065.html http://lists.infradead.org/pipermail/lede-dev/2017-April/007162.html http://lists.infradead.org/pipermail/lede-dev/2017-March/006927.html Quote from the last link: > be nice if [...] there were ways to be better refine the interface > triggers to only a true interface reconfiguration As one way of solving the problem, I wanted to make a trigger-handling json_script which itself would check the trigger details, and decide whether the event was relevant enough to warrant a reload. I tried this via a patch to procd: http://public.inteno.se/?p=iopsys.git;a=commitdiff;h=3cdd8f80433e21eacfb593e69361e8f217aba30c However, json_script turned out not to support custom expression handlers, hence this patch. Regards, Denis ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [LEDE-DEV] [PATCH ubus 0/3] ubusd: fix ACL checking
On 2016-09-05 14:00, Felix Fietkau wrote: > On 2016-09-05 10:21, Denis Osvald wrote: >> Ping? > I've applied patch 1 and 3. I need more time to properly review patch 2. > > - Felix > Any news? If there was a working case which the patch breaks, please point it out so I can send a revised version. Thanks, Denis ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH ubus 0/3] ubusd: fix ACL checking
Ping? On 2016-08-25 13:54, Denis Osvald wrote: > Denis Osvald (3): > ubusd: don't check ACL when object is NULL > ubusd: fallback to linear search on ACLs to fix wildcards > ubusd: fix inverted check in ubusd_reply_add > > ubusd_acl.c | 20 +--- > 1 file changed, 9 insertions(+), 11 deletions(-) > ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH ubus 3/3] ubusd: fix inverted check in ubusd_reply_add
Signed-off-by: Denis Osvald <denis.osv...@sartura.hr> --- ubusd_acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubusd_acl.c b/ubusd_acl.c index 2db515e..0028431 100644 --- a/ubusd_acl.c +++ b/ubusd_acl.c @@ -432,7 +432,7 @@ ubusd_reply_add(struct ubus_object *obj) if (!acl->priv) continue; - if (!ubusd_acl_match_path(obj->path.key, acl->avl.key, NULL)) + if (ubusd_acl_match_path(obj->path.key, acl->avl.key, NULL)) continue; c = blobmsg_open_table(, NULL); -- 2.9.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH ubus 2/3] ubusd: fallback to linear search on ACLs to fix wildcards
Change ACL search loop to go from exact match towards beginning. The linear search fallback (continue instead of break) is needed because the ACLs matching one object need not be consecutive in the AVL tree. For example, if we have ACLs for "foo.*", "foo.abc" and "foo.xyz", then object "foo.xyz" is matched by first and third rules which can't be consecutive in any sorting order. Also, this makes the ACL searching loops logically same as in rpcd, with the same quirk that "net*" won't match "net", effectively making '*' represent _one_ or more characters. Signed-off-by: Denis Osvald <denis.osv...@sartura.hr> --- ubusd_acl.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ubusd_acl.c b/ubusd_acl.c index 2700c86..2db515e 100644 --- a/ubusd_acl.c +++ b/ubusd_acl.c @@ -104,15 +104,13 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj, if (!cl->uid || !obj) return 0; - acl = avl_find_ge_element(_acls, obj, acl, avl); + acl = avl_find_le_element(_acls, obj, acl, avl); if (!acl) return -1; - avl_for_element_to_last(_acls, acl, acl, avl) { - int diff = ubusd_acl_match_path(obj, acl->avl.key, NULL); - - if (diff) - break; + avl_for_first_to_element_reverse(_acls, acl, acl, avl) { + if (ubusd_acl_match_path(obj, acl->avl.key, NULL)) + continue; if (ubusd_acl_match_cred(cl, acl)) continue; @@ -424,11 +422,11 @@ ubusd_reply_add(struct ubus_object *obj) if (!obj->path.key) return; - acl = avl_find_ge_element(_acls, obj->path.key, acl, avl); + acl = avl_find_le_element(_acls, obj->path.key, acl, avl); if (!acl) return; - avl_for_element_to_last(_acls, acl, acl, avl) { + avl_for_first_to_element_reverse(_acls, acl, acl, avl) { void *c; if (!acl->priv) @@ -489,7 +487,7 @@ static int ubusd_acl_recv(struct ubus_client *cl, struct ubus_msg_buf *ub, const void ubusd_acl_init(void) { - avl_init(_acls, ubusd_acl_match_path, true, NULL); + avl_init(_acls, avl_strcmp, true, NULL); acl_obj = ubusd_create_object_internal(NULL, UBUS_SYSTEM_OBJECT_ACL); acl_obj->recv_msg = ubusd_acl_recv; } -- 2.9.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH ubus 1/3] ubusd: don't check ACL when object is NULL
If there are any ACLs present other than global wildcard "*", the AVL tree comparator will compare ACL key to object name. However, object name can be NULL in cases where ACL check is done on call to internal ubus objects (e.g. ubus monitor). With this change we skip checking ACLs on such NULL objects. Signed-off-by: Denis Osvald <denis.osv...@sartura.hr> --- ubusd_acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubusd_acl.c b/ubusd_acl.c index 85ada5d..2700c86 100644 --- a/ubusd_acl.c +++ b/ubusd_acl.c @@ -101,7 +101,7 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj, struct blob_attr *cur; int rem; - if (!cl->uid) + if (!cl->uid || !obj) return 0; acl = avl_find_ge_element(_acls, obj, acl, avl); -- 2.9.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH ubus 0/3] ubusd: fix ACL checking
Denis Osvald (3): ubusd: don't check ACL when object is NULL ubusd: fallback to linear search on ACLs to fix wildcards ubusd: fix inverted check in ubusd_reply_add ubusd_acl.c | 20 +--- 1 file changed, 9 insertions(+), 11 deletions(-) -- 2.9.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] [rpcd] iwinfo: zero out ccode buffer since library doesn't
Making an ubus call iwinfo countrylist '{"device":"radio0"}' will result in some entries having garbage uninitialized stack bytes in the "code" fields. With this patch we zero-initialize the buffer that libiwinfo writes to, making it NUL-terminated so that behavior doesn't happen anymore. Signed-off-by: Denis Osvald <denis.osv...@sartura.hr> --- iwinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iwinfo.c b/iwinfo.c index 325c07a..b24d0f5 100644 --- a/iwinfo.c +++ b/iwinfo.c @@ -588,7 +588,7 @@ rpc_iwinfo_countrylist(struct ubus_context *ctx, struct ubus_object *obj, int rv, len; char cur[3]; char iso3166[3]; - char res[IWINFO_BUFSIZE]; + char res[IWINFO_BUFSIZE] = {0}; const char *ccode; const struct iwinfo_iso3166_label *l; void *c, *d; -- 2.8.2 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel