net: socat: add option user 16220/head
authorPaul Fertser <fercerpav@gmail.com>
Sun, 25 Jul 2021 18:19:42 +0000 (21:19 +0300)
committerPaul Fertser <fercerpav@gmail.com>
Sun, 25 Jul 2021 19:26:34 +0000 (22:26 +0300)
Allow UCI configuration to specify username to run this service as.
Defaults to root.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
net/socat/Makefile
net/socat/files/socat.config
net/socat/files/socat.init

index 081563f32fb7095ef0be7cd8a008f364ec60ec56..8b36f4dd77c9f55518715ae0ba878f779248dafa 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=socat
 PKG_VERSION:=1.7.3.4
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://www.dest-unreach.org/socat/download
index 7df6358be2058849269eed3ed34fb509c7a84414..196ab9c477c8998eb790055949dea534b0a21ded 100644 (file)
@@ -3,3 +3,4 @@
 config socat 'http'
        option enable '0'
        option SocatOptions '-d -d TCP6-LISTEN:8000,fork TCP4:192.168.1.20:80'
+       option user 'nobody'
index a4d3c8224a57e893c715a4281e6f2cf6e11e3524..03573a01ee716e95dc0183e40a7c02440543304c 100644 (file)
@@ -12,7 +12,8 @@ validate_section_socat()
 {
        uci_load_validate socat socat "$1" "$2" \
                'enable:bool:1' \
-               'SocatOptions:or(string, list(string))'
+               'SocatOptions:or(string, list(string))' \
+               'user:string:root'
 }
 
 append_param_command()
@@ -23,6 +24,7 @@ append_param_command()
 socat_instance()
 {
        local is_list
+       local user
 
        [ "$2" = 0 ] || {
                echo "validation failed"
@@ -39,6 +41,10 @@ socat_instance()
        else
                config_list_foreach "$1" SocatOptions append_param_command
        fi
+       config_get user "$1" user
+       if [ -n "$user" ]; then
+               procd_set_param user $user
+       fi
        procd_set_param stdout 1
        procd_set_param stderr 1
        procd_close_instance