procd: fix invalid JSON filter expression in procd_running()
authorJo-Philipp Wich <jo@mein.io>
Thu, 19 Sep 2019 05:16:49 +0000 (07:16 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 19 Sep 2019 05:21:47 +0000 (07:21 +0200)
Since service and instance names may contain characters which are not allowed
in JSON path labels, such as dashes or spaces, change the filter expression
to array square bracket notation to properly match these cases as well.

Fixes: 2c3dd70741 ("procd: add procd_running() helper for checking running state")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit c933b6d22478c1113629ef549beea6337f978d62)

package/system/procd/Makefile
package/system/procd/files/procd.sh

index 07deda58e983eab2ade90def27f4729b9275bf2d..1018bc65e6ce4dc2db9237cb45f12e6db7225174 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=procd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
index 8d6d4060125f7dc8c07f967ac323793fb7b32d3e..529ded1795d285de394e7e33d1fffa2ebfeb9f5e 100644 (file)
@@ -412,7 +412,7 @@ procd_running() {
 
        json_init
        json_add_string name "$service"
-       running=$(_procd_ubus_call list | jsonfilter -e "@.$service.instances.${instance}.running")
+       running=$(_procd_ubus_call list | jsonfilter -e "@['$service'].instances['$instance'].running")
 
        [ "$running" = "true" ]
 }