From 687209143fef21c0c0811631cd97f72432ef2df6 Mon Sep 17 00:00:00 2001 From: Shoudi Li Date: Fri, 21 Aug 2026 12:14:14 +0800 Subject: [PATCH] debian: create fastrpc group and add user to it in postinstall The postinstall script creates a 'fastrpc' system group via systemd-sysusers, falling back to 'addgroup --system', and adds the installing user to it. $SUDO_USER is preferred over $USER because during package installation $USER resolves to root; $SUDO_USER captures the real caller when invoked via 'sudo apt install ./pkg.deb'. Signed-off-by: Shoudi Li --- debian/fastrpc-support.postinst | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 debian/fastrpc-support.postinst diff --git a/debian/fastrpc-support.postinst b/debian/fastrpc-support.postinst new file mode 100755 index 0000000..efa6dcb --- /dev/null +++ b/debian/fastrpc-support.postinst @@ -0,0 +1,33 @@ +#!/bin/sh +set -e + +case "$1" in + configure) + # Create fastrpc group via systemd-sysusers + if command -v systemd-sysusers >/dev/null 2>&1; then + systemd-sysusers /usr/lib/sysusers.d/fastrpc.conf || true + fi + + # Fallback in case systemd-sysusers is unavailable or failed + if ! getent group fastrpc >/dev/null; then + addgroup --system fastrpc + fi + + # Add target user to fastrpc group + # + # Do NOT use $USER directly here: + # during package installation, $USER is usually root. + # + # If package is installed via sudo apt install ./xxx.deb, + # SUDO_USER may contain the real invoking user. + if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then + if getent passwd "$SUDO_USER" >/dev/null; then + usermod -aG fastrpc "$SUDO_USER" || true + fi + fi + ;; +esac + +#DEBHELPER# + +exit 0