syncthing: fix relay and discovery args and permissions
authorGeorge Sapkin <[email protected]>
Sun, 29 Jun 2025 11:13:55 +0000 (14:13 +0300)
committerJosef Schlehofer <[email protected]>
Wed, 2 Jul 2025 06:03:42 +0000 (08:03 +0200)
Fixes: #26829
Signed-off-by: George Sapkin <[email protected]>
utils/syncthing/Makefile
utils/syncthing/files/stdiscosrv.init
utils/syncthing/files/strelaysrv.init

index 114f4db0a17a24f07bcb8322e3f4414da3030aa6..4bb388e58e4c2c297e32116387b66db06c8b1ef8 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=syncthing
 PKG_VERSION:=1.29.7
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=syncthing-source-v$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/syncthing/syncthing/releases/download/v$(PKG_VERSION)
@@ -42,12 +42,12 @@ define Package/syncthing/Default
   DEPENDS:=$(GO_ARCH_DEPENDS)
   SECTION:=utils
   CATEGORY:=Utilities
+  USERID:=syncthing=499:syncthing=499
 endef
 
 define Package/syncthing
   $(call Package/syncthing/Default)
   TITLE:=Continuous file synchronization program
-  USERID:=syncthing=499:syncthing=499
 endef
 
 define Package/stdiscosrv
index 112ea5dbdc2598f3843eb6c5a3212f3c76db8593..566fb12eb5799645aac01c33a8e576287e8b8f70 100644 (file)
@@ -43,31 +43,35 @@ start_service() {
        # Options with default value different with the syncthing should be defined explicitly here
        local enabled=0
        local listen=":8443"
-       local cert="/etc/stdiscosrv/cert.pem"
-       local key="/etc/stdiscosrv/key.pem"
-       local db_dir="/etc/stdiscosrv/discovery.db"
+       local conf_dir="/etc/stdiscosrv"
+       local cert="$conf_dir/cert.pem"
+       local key="$conf_dir/key.pem"
+       local db_dir="$conf_dir/discovery.db"
        local nice=0
+       local user="syncthing"
 
        config_load "stdiscosrv"
 
        [ "$enabled" -gt 0 ] || return 0
 
+       local group=$(id -gn $user)
+
        [ -d "$db_dir" ] || mkdir -p "$db_dir"
-       [ -d "$db_dir" ] && chown -R nobody:nogroup "$db_dir"
+       [ -d "$conf_dir" ] && chown -R "$user":"$group" "$conf_dir"
 
        config_get nice stdiscosrv nice "0"
 
        procd_open_instance
        procd_set_param command "$PROG"
-       procd_append_param command -listen="$listen"
-       procd_append_param command -db-dir="$db_dir"
-       procd_append_param command -cert="$cert"
-       procd_append_param command -key="$key"
+       procd_append_param command --listen="$listen"
+       procd_append_param command --db-dir="$db_dir"
+       procd_append_param command --cert="$cert"
+       procd_append_param command --key="$key"
        [ -z "$extra_args" ] || procd_append_param command "$extra_args"
 
        procd_set_param nice "$nice"
        procd_set_param term_timeout 15
-       procd_set_param user "nobody"
+       procd_set_param user "$user"
        procd_set_param respawn
        procd_set_param stdout 1
        procd_set_param stderr 1
index 166f4a8df33d6c8fcbdacaa8f9473a6ad1fd58b9..ced126b10ab7ce8405017a31e39a807840e42df9 100644 (file)
@@ -44,13 +44,16 @@ start_service() {
        local enabled=0
        local keys="/etc/strelaysrv"
        local nice=0
+       local user="syncthing"
 
        config_load "strelaysrv"
 
        [ "$enabled" -gt 0 ] || return 0
 
+       local group=$(id -gn $user)
+
        [ -d "$keys" ] || mkdir -p "$keys"
-       [ -d "$keys" ] && chown -R nobody:nogroup "$keys"
+       [ -d "$keys" ] && chown -R "$user":"$group" "$keys"
 
        config_get nice strelaysrv nice "0"
 
@@ -65,7 +68,7 @@ start_service() {
 
        procd_set_param nice "$nice"
        procd_set_param term_timeout 15
-       procd_set_param user "nobody"
+       procd_set_param user "$user"
        procd_set_param respawn
        procd_set_param stdout 1
        procd_set_param stderr 1