File Quit-without-listening-socket.patch of Package fcgiwrap

From bb0316d5ba97296fc1a76625ca7780f33a0dc82f Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Thu, 7 Feb 2019 13:05:11 +0100
Subject: [PATCH] Quit without listening socket

Quit if systemd doesn't pass a valid socket, and no -s parameter
given. Otherwise fcgiwrap may try listening on stdin, with
bad results.
---
 fcgiwrap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fcgiwrap.c b/fcgiwrap.c
index 0fed56e..6ebc4be 100644
--- a/fcgiwrap.c
+++ b/fcgiwrap.c
@@ -804,7 +804,7 @@ int main(int argc, char **argv)
 {
 	int nchildren = 1;
 	char *socket_url = NULL;
-	int fd = 0;
+	int fd = -1;
 	int c;
 
 	while ((c = getopt(argc, argv, "c:hfs:p:")) != -1) {
@@ -866,12 +866,15 @@ int main(int argc, char **argv)
 		if (fd < 0) {
 			return 1;
 		}
+	} else {
+		fprintf(stderr, "No socket to listen on\n");
+		return 1;
 	}
 
 	prefork(nchildren);
 	fcgiwrap_main();
 
-	if (fd) {
+	if (fd >= 0) {
 		const char *p = socket_url;
 		close(fd);
 
-- 
2.20.1