busybox: sysntpd: make use of new ubus hotplug.ntp object
authorDaniel Golle <daniel@makrotopia.org>
Fri, 1 Jan 2021 12:45:48 +0000 (12:45 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 8 Feb 2021 00:57:14 +0000 (00:57 +0000)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/utils/busybox/Makefile
package/utils/busybox/files/ntpd-hotplug
package/utils/busybox/files/ntpd_acl.json [new file with mode: 0644]
package/utils/busybox/files/sysntpd

index e62cef0713790bd2db090dc0f0a256e268bf393d..366a767e88f07ecfd31ca3f903b6b4e90d1717e4 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=busybox
 PKG_VERSION:=1.31.1
-PKG_RELEASE:=8
+PKG_RELEASE:=9
 PKG_FLAGS:=essential
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
@@ -145,8 +145,9 @@ endif
 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
        $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
        $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
-       $(INSTALL_DIR) $(1)/etc/capabilities/
+       $(INSTALL_DIR) $(1)/etc/capabilities $(1)/usr/share/acl.d
        $(INSTALL_DATA) ./files/ntpd.capabilities $(1)/etc/capabilities/ntpd.json
+       $(INSTALL_DATA) ./files/ntpd_acl.json $(1)/usr/share/acl.d/ntpd.json
 endif
        -rm -rf $(1)/lib64
 endef
index 8d6d6091661998d86e456606e52f2b638fcb70ab..f09f5bbb7fc6bcae6f3eb6e5f41c54f4e1c42a80 100755 (executable)
@@ -1,2 +1,12 @@
 #!/bin/sh
-ACTION="$1" /sbin/hotplug-call ntp
+
+. /usr/share/libubox/jshn.sh
+
+addenv="$( env | while read line; do echo "json_add_string \"\" \"$line\";"; done )"
+json_init
+json_add_array env
+json_add_string "" "ACTION=$1"
+eval "$addenv"
+json_close_array env
+
+ubus call hotplug.ntp call "$(json_dump)"
diff --git a/package/utils/busybox/files/ntpd_acl.json b/package/utils/busybox/files/ntpd_acl.json
new file mode 100644 (file)
index 0000000..991793d
--- /dev/null
@@ -0,0 +1,8 @@
+{
+       "user": "ntp",
+       "access": {
+               "hotplug.ntp": {
+                       "methods": [ "call" ]
+               }
+       }
+}
index 19571a2306ae7ae27152334a5d462a8b1d1eadd4..e4a070762f2e6be299db8a7af7a8383062b0cf57 100755 (executable)
@@ -56,7 +56,12 @@ start_ntpd_instance() {
        done
        procd_set_param respawn
        [ -x /sbin/ujail -a -e /etc/capabilities/ntpd.json ] && {
-               procd_add_jail ntpd
+               procd_add_jail ntpd ubus
+               procd_add_jail_mount "$HOTPLUG_SCRIPT"
+               procd_add_jail_mount "/usr/share/libubox/jshn.sh"
+               procd_add_jail_mount "/usr/bin/env"
+               procd_add_jail_mount "/usr/bin/jshn"
+               procd_add_jail_mount "/bin/ubus"
                procd_set_param capabilities /etc/capabilities/ntpd.json
                procd_set_param user ntp
                procd_set_param group ntp