Dropping privileges in a long-running bash script: setpriv vs runuser vs su, and why sudo -u is the wrong choice here
Last quarter I had a long-running bash daemon that needed to start as root (to bind a privileged port and read a key file in /etc) and then immediately drop to an unprivileged user before doing anything else. The …