Files
Reid Linnemann c0a12f594b sysutils/check_reload_status: Handle socket closure correctly. Fixes #14386
In adverse conditions it is possible that php-fpm can actually close a
connection from an instance of fcgi-cli and not send a respone at all. This was
not handled correctly by the recv loops, which did not recognize the return
value 0 on the blocking socket as a closed socket condition. If php-fpm closes
the socket prematurely because it is out of resources or hits some other error
condition while fcgicli is trying to read a response, this can make it loop
indefinitely.

Additionally, if read_packet returns a buffer but the header type is not
identifiable, the program goes back into another iteration of the reading loop
where again the socket may be closed and read_packet loops trying to read the
eight byte header.

To remedy the problem, the header and body loops are changed to recognize a recv
result of 0 as an error condition and drop out returning an NULL buffer
pointer. Additionally, the main program loop is changed to bail out if it
receives a packet with a header type that is not recognized.
2024-02-08 11:16:35 -07:00

42 lines
1.3 KiB
Makefile

# $FreeBSD$
PORTNAME= check_reload_status
PORTVERSION= 0.0.16
CATEGORIES?= sysutils
MASTER_SITES= # empty
DISTFILES= # none
EXTRACT_ONLY= # empty
MAINTAINER= coreteam@pfsense.org
COMMENT= run various pfSense scripts on event.
LICENSE= APACHE20
WHERE= sbin
PLIST_FILES= ${WHERE}/${PORTNAME} ${WHERE}/pfSctl ${WHERE}/fcgicli
CFLAGS+= -I/usr/local/include -L/usr/local/lib
CFLAGS+= -Wsystem-headers -Werror -Wall -Wno-format-y2k -W \
-Wno-unused-parameter -Wstrict-prototypes \
-Wmissing-prototypes -Wpointer-arith -Wreturn-type \
-Wcast-qual -Wwrite-strings -Wswitch -Wshadow \
-Wunused-parameter -Wchar-subscripts -Winline \
-Wnested-externs -Wredundant-decls -Wno-pointer-sign
LIB_DEPENDS= libevent.so:devel/libevent
do-extract:
mkdir -p ${WRKSRC}
do-build:
${CC} ${CFLAGS} -lsbuf -levent -o ${WRKSRC}/${PORTNAME} ${FILESDIR}/${PORTNAME}.c
${CC} ${CFLAGS} -o ${WRKSRC}/pfSctl ${FILESDIR}/pfSctl.c
${CC} ${CFLAGS} -lsbuf -o ${WRKSRC}/fcgicli ${FILESDIR}/fcgicli.c
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/${WHERE}/
${INSTALL_PROGRAM} ${WRKSRC}/pfSctl ${STAGEDIR}${PREFIX}/${WHERE}/
${INSTALL_PROGRAM} ${WRKSRC}/fcgicli ${STAGEDIR}${PREFIX}/${WHERE}/
.include <bsd.port.mk>