Skip Menu |

This queue is for tickets about the FCGI CPAN distribution.

Report information
The Basics
Id: 97374
Status: new
Priority: 0/
Queue: FCGI

People
Owner: Nobody in particular
Requestors: Mario.Klebsch [...] ime-actia.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug in FCGI-0.74 (file descriptor gets inherited to child processes)
Date: Mon, 21 Jul 2014 13:40:29 +0000
To: "bug-FCGI [...] rt.cpan.org" <bug-FCGI [...] rt.cpan.org>
From: "Klebsch, Mario" <Mario.Klebsch [...] ime-actia.de>
Hello, I observed a problem with FCGI version 0.74. The socket, that is used to get FCGI Requests from the web browser, gets inherited to child processes. Here is a small perl script to demonstrate the Problem on Linux: ----8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<--- #!/usr/bin/perl use FCGI; my $socket = FCGI::OpenSocket(":8889",5); print "$^F\n"; open F, "ls -l /proc/self/fd |"; print while (<F>); ----8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<--- It shows, that the socket is inherited to the ls process. I have made a small patch, to correct it: ----8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<--- diff -ruNd FCGI-0.74.4patch/os_unix.c FCGI-0.74/os_unix.c --- FCGI-0.74.4patch/os_unix.c 2014-07-21 10:04:20.000000000 +0200 +++ FCGI-0.74/os_unix.c 2014-07-21 10:06:50.853424278 +0200 @@ -20,6 +20,10 @@ static const char rcsid[] = "$Id: os_unix.c,v 1.38 2003/06/22 00:16:43 robs Exp $"; #endif /* not lint */ + +#include "EXTERN.h" +#include "perl.h" + #include "fcgi_config.h" #include <sys/types.h> @@ -339,6 +343,9 @@ if(listenSock < 0) { return -1; } +#if defined(HAS_FCNTL) && defined(F_SETFD) + fcntl(listenSock, F_SETFD, listenSock > PL_maxsysfd); /* ensure close-on-exec */ +#endif /* * Bind the listening socket. ----8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<--- I am not familiar with perl module writing, so I am not sure, that I #include the correct files. Additionally this problem might also occur on active FCGI sockets. I saw, that a newer version of FCGI is out, but I was not able to find a fix like mine in os_unix.c. So I thought, I'd better report this bug, since the current version might be affected, too. 73, Mario -- Mario Klebsch Actia I+ME GmbH Mario.klebsch@ime-actia.de<mailto:Mario.klebsch@ime-actia.de> Dresdenstrasse 17/18 Fon: +49 531 38 701 716 38124 Braunschweig Fax: +49 531 38 701 88 Germany