Avoid accidentally killing init or other important processes when

running 'service fcgiwrap onestop' if /var/run/fcgiwrap/fcgiwrap.pid
doesn't exist or contain the fcgiwrap PID.

This prevents killing any processes in process groups 0 or 1 or in the
caller's process group if the rc script cannot read the fcgiwrap
pidfile.

PR:		219724
Submitted by:	bblister@gmail.com
MFH:		2017Q2
This commit is contained in:
Matthew Seaman 2017-06-04 12:07:33 +00:00
parent 2596a3dc8f
commit 6d6ae0b87c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=442556
2 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,7 @@
PORTNAME= fcgiwrap
PORTVERSION= 1.1.0
PORTREVISION= 5
PORTREVISION= 6
CATEGORIES= www
MAINTAINER= ports@FreeBSD.org

View File

@ -88,8 +88,10 @@ fcgiwrap_postcmd() {
}
fcgiwrap_stop() {
fcgiwrap_pgrp=$(/bin/ps -o ppid= $(cat ${pidfile}))
if [ -z "$fcgiwrap_pgrp" ] || ! kill -0 $fcgiwrap_pgrp; then
if [ -s ${pidfile} ]; then
fcgiwrap_pgrp=$(/bin/ps -o ppid= $(cat ${pidfile}))
fi
if [ -z "$fcgiwrap_pgrp" -o "${fcgiwrap_pgrp:-0}" -le 1 ] || ! kill -0 $fcgiwrap_pgrp; then
[ -n "$rc_fast" ] && return 0
_run_rc_notrunning
return 1