From ac3dc699c398ddd40bf055ba972a1ff9f735c21a Mon Sep 17 00:00:00 2001 From: mesher2024 Date: Mon, 21 Oct 2024 10:02:33 +0800 Subject: [PATCH] debian: fixup debian packaging build scripts (#1722) * debian: fix up postinst bad substitution Fix up postinst bad substitution caused by Bash string manipulation in the Dash script. * debian: update compat file Fix up the warning caused by compatibility levels before 10 are deprecated. * debian: replace user nobody in systemd file with dynamicuser * debian: remove dependency on apg and pwgen in control file * debian: update shadowsocks-rust-server@.service Add `DynamicUser=yes` in shadowsocks-rust-server@.service * debian: update shadowsocks-rust-local@.service Add `DynamicUser=yes` in shadowsocks-rust-local@.service --------- Co-authored-by: mesher2024 --- debian/compat | 2 +- debian/control | 2 +- debian/shadowsocks-rust-local@.service | 1 + debian/shadowsocks-rust-server@.service | 1 + debian/shadowsocks-rust.postinst | 3 +-- debian/shadowsocks-rust.service | 3 +-- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/debian/compat b/debian/compat index ec635144f600..f599e28b8ab0 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -9 +10 diff --git a/debian/control b/debian/control index 94d0284728c4..ea233796f04e 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: shadowsocks-rust Section: net Priority: optional Maintainer: Y. T. Chung -Build-Depends: debhelper (>=9), rustc, cargo, apg | pwgen, libcap2-bin [linux-any] +Build-Depends: debhelper (>=9), rustc, cargo, libcap2-bin [linux-any] Standards-Version: 3.9.6 Homepage: https://github.com/shadowsocks/shadowsocks-rust diff --git a/debian/shadowsocks-rust-local@.service b/debian/shadowsocks-rust-local@.service index 05a99643b517..ec609b92aeb3 100644 --- a/debian/shadowsocks-rust-local@.service +++ b/debian/shadowsocks-rust-local@.service @@ -13,6 +13,7 @@ After=network.target Type=simple CapabilityBoundingSet=CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_BIND_SERVICE +DynamicUser=yes ExecStart=/usr/bin/ssservice local --log-without-time -c /etc/shadowsocks-rust/%i.json [Install] diff --git a/debian/shadowsocks-rust-server@.service b/debian/shadowsocks-rust-server@.service index 0f129e782ebd..73f59d561de2 100644 --- a/debian/shadowsocks-rust-server@.service +++ b/debian/shadowsocks-rust-server@.service @@ -13,6 +13,7 @@ After=network.target Type=simple CapabilityBoundingSet=CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_BIND_SERVICE +DynamicUser=yes ExecStart=/usr/bin/ssservice server --log-without-time -c /etc/shadowsocks-rust/%i.json [Install] diff --git a/debian/shadowsocks-rust.postinst b/debian/shadowsocks-rust.postinst index 12fc0bbb6013..e8a2be7e24b5 100644 --- a/debian/shadowsocks-rust.postinst +++ b/debian/shadowsocks-rust.postinst @@ -27,8 +27,7 @@ case "$1" in if [ ! -f /etc/shadowsocks-rust/config.json ]; then set +e passwd=$(/usr/bin/ssservice genkey -m "chacha20-ietf-poly1305") - passwd="${passwd//+/\\+}" - passwd="${passwd//\//\\/}" + passwd=$(echo $passwd | sed "s/+/\\\\+/g" | sed "s/\\//\\\\\\//g") set -e mkdir -p /etc/shadowsocks-rust sed "s/barfoo/$passwd/" /usr/share/shadowsocks-rust/config.json \ diff --git a/debian/shadowsocks-rust.service b/debian/shadowsocks-rust.service index af56887d7e9c..f4b807d43eb5 100644 --- a/debian/shadowsocks-rust.service +++ b/debian/shadowsocks-rust.service @@ -11,8 +11,7 @@ After=network.target [Service] Type=simple EnvironmentFile=/etc/default/shadowsocks-rust -User=nobody -Group=nogroup +DynamicUser=yes LimitNOFILE=32768 ExecStart=/usr/bin/ssservice server -c ${CONFFILE} ${DAEMON_ARGS}