Bladeren bron

set the group when running starman

George Baugh 5 maanden geleden
bovenliggende
commit
488954157a
2 gewijzigde bestanden met toevoegingen van 9 en 1 verwijderingen
  1. 3 0
      Readme.md
  2. 6 1
      service/tpsgi.sh

+ 3 - 0
Readme.md

@@ -139,3 +139,6 @@ In general the operation is like so:
 1. nginx (or whatever) looks for a sock file owned $USER:$WEB\_GROUP, and reverse proxies to this
 1. nginx (or whatever) looks for a sock file owned $USER:$WEB\_GROUP, and reverse proxies to this
 2. tpsgi is actively listening on this sock file.
 2. tpsgi is actively listening on this sock file.
 
 
+Generally you'll just run bin/build\_service and then systemctl start $domain.
+It's configured to start as root, then drop privs thanks to Net::Server's capabilities inherited in starman.
+

+ 6 - 1
service/tpsgi.sh

@@ -4,6 +4,11 @@ USERNAME=$(bin/tpsgi-config --user)
 [[ -z $USERNAME ]] && USERNAME=$USER
 [[ -z $USERNAME ]] && USERNAME=$USER
 echo "tPSGI running as user $USERNAME"
 echo "tPSGI running as user $USERNAME"
 
 
+EGID=$(id -nu)
+GROUP=$(bin/tpsgi-config --http_user)
+[[ -z $GROUP ]] && GROUP=$EGID
+echo "tPSGI running with EGID $GROUP";
+
 [[ -e run/tpsgi.pid ]] && sudo pkill -F run/tpsgi.pid
 [[ -e run/tpsgi.pid ]] && sudo pkill -F run/tpsgi.pid
 
 
 # Bind the various dirs we need for chroot to work
 # Bind the various dirs we need for chroot to work
@@ -25,7 +30,7 @@ for bind in "${BIND_DIRS[@]}"; do
 done
 done
 
 
 # We should obey the PATH set by this user, whose homedir is right here, ideally.
 # We should obey the PATH set by this user, whose homedir is right here, ideally.
-bin/tpsgi --listen run/tpsgi.sock --workers 20 --user "$USERNAME" --daemonize --pid run/tpsgi.pid --chroot $(pwd)
+bin/tpsgi --listen run/tpsgi.sock --workers 20 --user "$USERNAME" --group "$GROUP" --daemonize --pid run/tpsgi.pid --chroot $(pwd)
 
 
 if [ $? -ne 0 ]
 if [ $? -ne 0 ]
 then
 then