SHA256
8
0
forked from pool/FastCGI

43 Commits

Author SHA256 Message Date
209ec9944c Accepting request 1293233 from devel:libraries:c_c++
- Update to 2.4.6 (boo#1243325 CVE-2025-23016)
  switch to https://github.com/FastCGI-Archives/fcgi2
  lots of small bugs fixes and incorporation of patches that
  distros carried in the past
- drop patches which are included upstream
  FastCGI-clientdata_pointer.patch
  FastCGI-gcc44.patch
  FastCGI-makefile.am_cppflags.patch
  FastCGI-supervise_cgi-fcgi.patch
  fastcgi-2.4.0_missing_call_to_fclose.patch
- drop patches obsoleted by changes to the perl building
  FastCGI-fix_deprecated_api.patch
  FastCGI-perl514.patch
  FastCGI-perl526.patch

OBS-URL: https://build.opensuse.org/request/show/1293233
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=34
2025-07-17 15:17:23 +00:00
f40c9ef493 Accepting request 1206336 from devel:libraries:c_c++
- add the normalized provides for perl(FCGI) until auto provides is
  fixed

OBS-URL: https://build.opensuse.org/request/show/1206336
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=33
2024-10-09 20:03:08 +00:00
094a1b95d9 use the format the perl team prefers
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=49
2024-10-08 14:37:18 +00:00
558b988331 - add the normalized provides for perl(FCGI) until auto provides is
fixed

OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=48
2024-10-08 14:35:54 +00:00
0e46b31932 Accepting request 1180339 from devel:libraries:c_c++
Forwarded request #1180337 from dimstar

- Rename perl-FastCGI subpackage to perl-FCGI: adjust the package
  name to the actual perl module name.

OBS-URL: https://build.opensuse.org/request/show/1180339
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=32
2024-06-14 16:57:13 +00:00
1615a7e430 Accepting request 1180337 from home:dimstar:Factory
- Rename perl-FastCGI subpackage to perl-FCGI: adjust the package
  name to the actual perl module name.

OBS-URL: https://build.opensuse.org/request/show/1180337
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=46
2024-06-13 09:01:17 +00:00
386956ab26 Accepting request 1178131 from devel:libraries:c_c++
OBS-URL: https://build.opensuse.org/request/show/1178131
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=31
2024-06-04 10:50:57 +00:00
f9cfc2be1c Accepting request 1174150 from home:dimstar:Factory
- Use %autosetup macro: allows us to eliminate usage of deprecated
  %patchN syntax.
- Rebase FastCGI-perl526.patch to apply with -p0, like all the
  other patches.

OBS-URL: https://build.opensuse.org/request/show/1174150
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=44
2024-06-02 10:00:46 +00:00
a963c7f0d3 Accepting request 1087201 from devel:libraries:c_c++
OBS-URL: https://build.opensuse.org/request/show/1087201
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=30
2023-05-16 12:15:52 +00:00
619c603c36 Accepting request 1086782 from home:fcrozat:branches:devel:libraries:c_c++
- Fix url for website and source, upstream is dead for a while.

OBS-URL: https://build.opensuse.org/request/show/1086782
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=42
2023-05-15 10:48:28 +00:00
5b3bae058f Accepting request 528599 from devel:libraries:c_c++
1

OBS-URL: https://build.opensuse.org/request/show/528599
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=29
2017-10-02 14:43:46 +00:00
259a92e6cc Accepting request 528487 from home:coolo:branches:openSUSE:Factory
- add FastCGI-perl526.patch as perl 5.26 no longer has . in @INC

OBS-URL: https://build.opensuse.org/request/show/528487
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=40
2017-09-25 09:02:49 +00:00
a3bdd468fd Accepting request 266433 from devel:libraries:c_c++
1

OBS-URL: https://build.opensuse.org/request/show/266433
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=28
2014-12-29 23:49:36 +00:00
Tomáš Chvátal
6bb0867dd5 Accepting request 266001 from home:jengelh:branches:devel:libraries:c_c++
- "libfcgi++-0" package name is wrong (should be "libfcgi++0");
  change to libfcgi0 (due to libfcgi.so.0 being present, which is
  the main one).

OBS-URL: https://build.opensuse.org/request/show/266001
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=38
2014-12-26 11:18:24 +00:00
c4e6faab1d revert that unintended commit; making a branch with notification first
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=37
2014-12-20 12:05:57 +00:00
5678cc99ce .
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=36
2014-12-20 12:03:49 +00:00
81de5715fe Accepting request 265077 from devel:libraries:c_c++
1

OBS-URL: https://build.opensuse.org/request/show/265077
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=27
2014-12-16 13:48:44 +00:00
Ismail Dönmez
5033cb2ff9 Accepting request 265073 from home:posophe:branches:devel:libraries:c_c++
Split out library

OBS-URL: https://build.opensuse.org/request/show/265073
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=34
2014-12-13 15:26:10 +00:00
Stephan Kulow
bd5345def8 Accepting request 247026 from devel:libraries:c_c++
1

OBS-URL: https://build.opensuse.org/request/show/247026
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=26
2014-09-03 06:30:15 +00:00
Ismail Dönmez
ff9173f980 Accepting request 247021 from home:fcrozat:branches:devel:libraries:c_c++
- Update license tag to spdx 1.2.

OBS-URL: https://build.opensuse.org/request/show/247021
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=32
2014-09-01 08:32:33 +00:00
Stephan Kulow
3f210304aa Accepting request 160245 from devel:libraries:c_c++
- re-enable SLE support as %perl_requires is too new (forwarded request 160239 from bmanojlovic)

OBS-URL: https://build.opensuse.org/request/show/160245
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=23
2013-03-21 08:53:13 +00:00
Ismail Dönmez
5749e02db4 Accepting request 160239 from home:bmanojlovic:branches:devel:libraries:c_c++
- re-enable SLE support as %perl_requires is too new

OBS-URL: https://build.opensuse.org/request/show/160239
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=30
2013-03-20 13:20:54 +00:00
Stephan Kulow
1bbccaab18 Accepting request 124477 from devel:libraries:c_c++
- require the right version of perl (forwarded request 124456 from coolo)

OBS-URL: https://build.opensuse.org/request/show/124477
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=20
2012-06-13 14:23:46 +00:00
a9dc1805f4 Accepting request 124456 from home:coolo:branches:openSUSE:Factory
- require the right version of perl

OBS-URL: https://build.opensuse.org/request/show/124456
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=28
2012-06-11 15:03:33 +00:00
Stephan Kulow
f4396abe6d Accepting request 111336 from devel:libraries:c_c++
license update: SUSE-OML
Use SUSE- proprietary prefix until license is accepted upstream by SPDX.org. Fedora tracks this as OML. (forwarded request 111326 from babelworx)

OBS-URL: https://build.opensuse.org/request/show/111336
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=19
2012-04-02 08:29:06 +00:00
Ismail Dönmez
1d32336734 Accepting request 111326 from home:babelworx:ldig:branches:devel:libraries:c_c++
license update: SUSE-OML
Use SUSE- proprietary prefix until license is accepted upstream by SPDX.org. Fedora tracks this as OML.

OBS-URL: https://build.opensuse.org/request/show/111326
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=26
2012-03-27 09:00:35 +00:00
Stephan Kulow
3f2c01970f Accepting request 97778 from devel:libraries:c_c++
- added FastCGI-fix_deprecated_api.patch: (bnc#735882)
  Fixes an issue where CGI.pm received CGI variables from previous
  requests. CVE-2011-2766 (forwarded request 97777 from darix)

OBS-URL: https://build.opensuse.org/request/show/97778
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=18
2011-12-25 16:34:01 +00:00
Ismail Dönmez
0027213963 Accepting request 97777 from home:darix:branches:OBS_Maintained:FastCGI
- added FastCGI-fix_deprecated_api.patch: (bnc#735882)
  Fixes an issue where CGI.pm received CGI variables from previous
  requests. CVE-2011-2766

OBS-URL: https://build.opensuse.org/request/show/97777
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=24
2011-12-21 16:26:41 +00:00
Lars Vogdt
45791b8701 Accepting request 88033 from devel:libraries:c_c++
add libtool as buildrequire to avoid a hidden require from projconfig (forwarded request 87942 from coolo)

OBS-URL: https://build.opensuse.org/request/show/88033
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=16
2011-10-16 10:39:40 +00:00
Cristian Rodríguez
5934706f91 Accepting request 87942 from home:coolo:removelibtool
add libtool as buildrequire to avoid a hidden require from projconfig

OBS-URL: https://build.opensuse.org/request/show/87942
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=22
2011-10-15 18:44:36 +00:00
Lars Vogdt
75d4bfa54b Accepting request 82658 from devel:libraries:c_c++
- Remove redundant tags/sections from specfile
- Enable parallel build (forwarded request 82634 from jengelh)

OBS-URL: https://build.opensuse.org/request/show/82658
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=15
2011-09-19 13:24:33 +00:00
Ismail Dönmez
bcc282ddab Accepting request 82634 from home:jengelh:bl
- Remove redundant tags/sections from specfile
- Enable parallel build

OBS-URL: https://build.opensuse.org/request/show/82634
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=20
2011-09-17 10:05:33 +00:00
Sascha Peilicke
3c342dd651 Autobuild autoformatter for 71613
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=14
2011-05-27 10:16:31 +00:00
OBS User buildservice-autocommit
3db19e9138 Updating link to change in openSUSE:Factory/FastCGI revision 14.0
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=b7081e423eda4ed8c59a927d6cf1d8cb
2011-05-27 10:16:31 +00:00
Sascha Peilicke
d992ce8943 Accepting request 71613 from devel:libraries:c_c++
Add FastCGI-perl514.patch: fix compilation with Perl 5.14 (forwarded request 71556 from namtrac)

OBS-URL: https://build.opensuse.org/request/show/71613
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=13
2011-05-27 10:16:17 +00:00
Stephan Kulow
26608821d9 Accepting request 71556 from home:namtrac:branches:devel:libraries:c_c++
Add FastCGI-perl514.patch: fix compilation with Perl 5.14

OBS-URL: https://build.opensuse.org/request/show/71556
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/FastCGI?expand=0&rev=18
2011-05-27 07:57:07 +00:00
5da2a9247c Autobuild autoformatter for 54835
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=11
2010-12-07 17:39:16 +00:00
1257100315 Accepting request 54835 from devel:libraries:c_c++
Accepted submit request 54835 from user coolo

OBS-URL: https://build.opensuse.org/request/show/54835
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=10
2010-12-07 17:39:04 +00:00
OBS User autobuild
21eb1fe950 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=7 2010-03-18 14:32:01 +00:00
OBS User autobuild
f062bebd6b Accepting request 27556 from devel:libraries:c_c++
Copy from devel:libraries:c_c++/FastCGI based on submit request 27556 from user coolo

OBS-URL: https://build.opensuse.org/request/show/27556
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=6
2009-12-26 10:35:20 +00:00
OBS User unknown
e9c2e2ad9d OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=4 2009-06-17 17:32:01 +00:00
OBS User unknown
8b91cd4865 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=3 2009-03-02 00:32:55 +00:00
OBS User unknown
6ba5006c90 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FastCGI?expand=0&rev=1 2007-01-15 22:49:03 +00:00
10 changed files with 0 additions and 398 deletions

BIN
2.4.0.tar.gz (Stored with Git LFS)

Binary file not shown.

View File

@@ -1,88 +0,0 @@
--- cgi-fcgi/cgi-fcgi.c
+++ cgi-fcgi/cgi-fcgi.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include "fcgi_config.h"
@@ -145,7 +146,7 @@
static int bytesToRead; /* number of bytes to read from Web Server */
-static int appServerSock = -1; /* Socket connected to FastCGI application,
+static size_t appServerSock = -1; /* Socket connected to FastCGI application,
* used by AppServerReadHandler and
* AppServerWriteHandler. */
static Buffer fromAS; /* Bytes read from the FCGI application server. */
@@ -640,7 +641,7 @@
}
if((av[ac] = (char *)malloc(strlen(tp1)+1)) == NULL) {
fprintf(stderr, "Cannot allocate %d bytes\n",
- strlen(tp1)+1);
+ (int)strlen(tp1)+1);
exit(-1);
}
strcpy(av[ac++], tp1);
--- examples/threaded.c
+++ examples/threaded.c
@@ -24,7 +24,7 @@
static void *doit(void *a)
{
- int rc, i, thread_id = (int)a;
+ size_t rc, i, thread_id = (size_t)a;
pid_t pid = getpid();
FCGX_Request request;
char *server_name;
@@ -53,7 +53,7 @@
"<h1>FastCGI Hello! (multi-threaded C, fcgiapp library)</h1>"
"Thread %d, Process %ld<p>"
"Request counts for %d threads running on host <i>%s</i><p><code>",
- thread_id, pid, THREAD_COUNT, server_name ? server_name : "?");
+ (int)thread_id, pid, THREAD_COUNT, server_name ? server_name : "?");
sleep(2);
@@ -71,7 +71,7 @@
int main(void)
{
- int i;
+ size_t i;
pthread_t id[THREAD_COUNT];
FCGX_Init();
--- include/fcgios.h
+++ include/fcgios.h
@@ -93,7 +93,7 @@
# if defined(__STDC__) || defined(__cplusplus)
typedef void *ClientData;
# else
- typedef int *ClientData;
+ typedef size_t *ClientData;
# endif /* __STDC__ */
#define _CLIENTDATA
#endif
--- libfcgi/os_unix.c
+++ libfcgi/os_unix.c
@@ -1155,7 +1155,7 @@
for (;;) {
do {
-#ifdef HAVE_SOCKLEN
+#ifdef HAVE_SYS_SOCKET_H
socklen_t len = sizeof(sa);
#else
int len = sizeof(sa);
@@ -1255,7 +1255,7 @@
struct sockaddr_in in;
struct sockaddr_un un;
} sa;
-#ifdef HAVE_SOCKLEN
+#ifdef HAVE_SYS_SOCKET_H
socklen_t len = sizeof(sa);
#else
int len = sizeof(sa);

View File

@@ -1,53 +0,0 @@
From: Florian Ragwitz <rafl@debian.org>
Date: Sat, 24 Sep 2011 07:54:33 +0000 (+0200)
Subject: Stop leaking information across requests
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2Ffcgi2.git;a=commitdiff_plain;h=297693dc8362d25bb25e473899c72508a0f71d2e
Stop leaking information across requests
%hash is false if the hash hasn't been assigned to, *or* if the hash is simply
empty. This causes the environment from the *second* request (that is, the
environment produced by the first request) to be saved as default if the first
request had empty environment. This way, request after the first can get access
to credentials set up by the first request.
Instead of fixing this, I'd much rather remove this old and buggy
interface. However, 10 years of deprecation don't seem to have been enough for
CGI::Fast to switch to the new and properly supported interface. :-(
This is CVE-2011-2766.
---
Index: perl/FCGI.PL
===================================================================
--- perl/FCGI.PL.orig 2002-12-15 21:02:48.000000000 +0100
+++ perl/FCGI.PL 2011-12-12 11:24:08.885998082 +0100
@@ -291,14 +291,14 @@ sub Request(;***$*$) {
sub accept() {
warn "accept called as a method; you probably wanted to call Accept" if @_;
- if (defined %FCGI::ENV) {
- %ENV = %FCGI::ENV;
+ if ( defined($FCGI::ENV) ) {
+ %ENV = %$FCGI::ENV;
} else {
- %FCGI::ENV = %ENV;
+ $FCGI::ENV = {%ENV};
}
my $rc = Accept($global_request);
- for (keys %FCGI::ENV) {
- $ENV{$_} = $FCGI::ENV{$_} unless exists $ENV{$_};
+ for (keys %$FCGI::ENV) {
+ $ENV{$_} = $FCGI::ENV->{$_} unless exists $ENV{$_};
}
# not SFIO
@@ -310,7 +310,7 @@ sub accept() {
sub finish() {
warn "finish called as a method; you probably wanted to call Finish" if @_;
- %ENV = %FCGI::ENV if (defined %FCGI::ENV);
+ %ENV = %$FCGI::ENV if defined($FCGI::ENV);
# not SFIO
if (tied (*STDIN)) {

View File

@@ -1,10 +0,0 @@
--- libfcgi/fcgio.cpp
+++ libfcgi/fcgio.cpp
@@ -23,6 +23,7 @@
#endif
#include <limits.h>
+#include <stdio.h>
#include "fcgio.h"
using std::streambuf;

View File

@@ -1,33 +0,0 @@
--- cgi-fcgi/Makefile.am
+++ cgi-fcgi/Makefile.am
@@ -2,7 +2,7 @@
bin_PROGRAMS = cgi-fcgi
INCLUDEDIR = ../include
-CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/include
+AM_CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/include
INCLUDE_FILES = $(INCLUDEDIR)/fastcgi.h \
$(INCLUDEDIR)/fcgiapp.h \
--- examples/Makefile.am
+++ examples/Makefile.am
@@ -11,7 +11,7 @@
EXTRA_PROGRAMS = threaded echo-cpp
INCLUDEDIR = ../include
-CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/include
+AM_CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/include
INCLUDE_FILES = $(INCLUDEDIR)/fastcgi.h \
$(INCLUDEDIR)/fcgiapp.h \
--- libfcgi/Makefile.am
+++ libfcgi/Makefile.am
@@ -1,7 +1,7 @@
# $Id: Makefile.am,v 1.9 2001/12/22 03:16:20 robs Exp $
INCLUDEDIR = ../include
-CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/include
+AM_CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/include
INCLUDE_FILES = $(INCLUDEDIR)/fastcgi.h \
$(INCLUDEDIR)/fcgiapp.h \

View File

@@ -1,26 +0,0 @@
--- perl/Makefile.PL 2002-12-15 20:40:19.000000000 +0100
+++ perl/Makefile.PL 2011-05-26 22:28:06.673024204 +0200
@@ -99,10 +99,7 @@
# the contents of the Makefile that is written.
# Work around bug in previous versions of MakeMaker
-WriteMakefile(NAME => 'FCGI')
- if $ExtUtils::MakeMaker::VERSION <= 5.4302;
-
-$mm = MM->new({
+WriteMakefile(
'NAME' => 'FCGI',
'VERSION_FROM' => 'version.pm',
'dist' => { 'COMPRESS' => 'gzip -9f',
@@ -123,10 +120,7 @@
'PL_FILES' => $plfiles,
PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
@extras,
-});
-# don't install oldinterface pod
-delete $mm->{MAN3PODS}{oldinterface.pod};
-$mm->flush;
+);
exit if -f 'fcgi_config.h' or $libfound or $pure;

View File

@@ -1,13 +0,0 @@
Index: fcgi-2.4.0/perl/FCGI.PL
===================================================================
--- perl/FCGI.PL
+++ perl/FCGI.PL
@@ -1,7 +1,7 @@
use Config;
use ExtUtils::MakeMaker;
-do 'FCGI.cfg' or die "no FCGI.cfg";
+do './FCGI.cfg' or die "no FCGI.cfg";
open OUT, ">FCGI.pm";

View File

@@ -1,121 +0,0 @@
Index: cgi-fcgi/cgi-fcgi.c
===================================================================
--- cgi-fcgi/cgi-fcgi.c.orig
+++ cgi-fcgi/cgi-fcgi.c
@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
#include "fcgi_config.h"
@@ -583,7 +585,7 @@
#define MAXARGS 16
static int ParseArgs(int argc, char *argv[],
int *doBindPtr, int *doStartPtr,
- char *connectPathPtr, char *appPathPtr, int *nServersPtr) {
+ char *connectPathPtr, char *appPathPtr, int *nServersPtr, int *doDaemonPtr) {
int i,
x,
err = 0,
@@ -599,6 +601,7 @@
*connectPathPtr = '\0';
*appPathPtr = '\0';
*nServersPtr = 0;
+ *doDaemonPtr = TRUE;
for(i = 0; i < MAXARGS; i++)
av[i] = NULL;
@@ -649,7 +652,7 @@
}
}
err = ParseArgs(ac, av, doBindPtr, doStartPtr,
- connectPathPtr, appPathPtr, nServersPtr);
+ connectPathPtr, appPathPtr, nServersPtr, doDaemonPtr);
for(x = 1; x < ac; x++) {
ASSERT(av[x] != NULL);
free(av[x]);
@@ -673,7 +676,9 @@
} else {
strcpy(connectPathPtr, argv[i]);
}
- } else {
+ } else if(!strcmp(argv[i], "-supervise")) {
+ *doDaemonPtr = FALSE;
+ } else {
fprintf(stderr, "Unknown option %s\n", argv[i]);
err++;
}
@@ -718,6 +723,15 @@
return err;
}
+void handle_shutdown(int s)
+{
+ /* Kill our children processes */
+ signal(s, SIG_IGN);
+ kill(0, s);
+
+ exit(0);
+}
+
int main(int argc, char **argv)
{
char **envp = environ;
@@ -728,20 +742,22 @@
int headerLen, valueLen;
char *equalPtr;
FCGI_BeginRequestRecord beginRecord;
- int doBind, doStart, nServers;
+ int doBind, doStart, nServers, doDaemon;
char appPath[MAXPATHLEN], bindPath[MAXPATHLEN];
+ int pid;
if(ParseArgs(argc, argv, &doBind, &doStart,
- (char *) &bindPath, (char *) &appPath, &nServers)) {
+ (char *) &bindPath, (char *) &appPath, &nServers, &doDaemon)) {
fprintf(stderr,
"Usage:\n"
" cgi-fcgi -f <cmdPath> , or\n"
" cgi-fcgi -connect <connName> <appPath> [<nServers>] , or\n"
-" cgi-fcgi -start -connect <connName> <appPath> [<nServers>] , or\n"
+" cgi-fcgi -start -connect [-supervise] <connName> <appPath> [<nServers>] , or\n"
" cgi-fcgi -bind -connect <connName> ,\n"
"where <connName> is either the pathname of a UNIX domain socket\n"
"or (if -bind is given) a hostName:portNumber specification\n"
-"or (if -start is given) a :portNumber specification (uses local host).\n");
+"or (if -start is given) a :portNumber specification (uses local host).\n"
+"-supervise is for running with runit or daemontools.\n");
exit(1);
}
@@ -757,12 +773,27 @@
bytesToRead = 0;
}
+ /* Become a process group leader */
+ setsid();
+
+ /* Register our signal handler */
+ signal(SIGHUP, handle_shutdown);
+ signal(SIGINT, handle_shutdown);
+ signal(SIGTERM, handle_shutdown);
+
if(doBind) {
appServerSock = OS_FcgiConnect(bindPath);
}
if(doStart && (!doBind || appServerSock < 0)) {
FCGI_Start(bindPath, appPath, nServers);
if(!doBind) {
+ if(!doDaemon) {
+ for(pid=nServers; pid != 0; pid--) {
+ wait(0);
+ }
+ }
+ signal(SIGTERM, SIG_IGN);
+ kill(0, SIGTERM);
exit(0);
} else {
appServerSock = OS_FcgiConnect(bindPath);

View File

@@ -1,39 +0,0 @@
taken from http://rubyists.com/articles/2005/05/03/spawn-fcgi-in-the-foreground:
spawn-fcgi in the foreground!
by Bougyman Tue, 03 May 2005 11:00:00 GMT
Been looking for a clean way to spawn fastcgi listeners in the foreground and I
believe Trey has figured it out. This patch should take care of it by keeping
spawn-fcgi from losing track of the copied listening processes and allow full
supervison. To use, call your cgi-fcgi -start -connect $host:$port script with
the -supervise option, like:
cgi-fcgi -start -supervise -connect 127.0.0.1:1791 /path/to/dispatch.fcgi
Full Supervise run script becomes
#!/bin/sh
RAIL_NUMBER=$(basename $PWD|awk -F'-' '{print $2}')
RAILS_HOST=$(<env/RAILS_HOST)
RAILS_ROOT=$(<env/RAILS_ROOT)
RAILS_PORT=179$RAIL_NUMBER
exec envdir ./env \
cgi-fcgi -supervise -start -connect \
$RAILS_HOST:$RAILS_PORT \
$RAILS_ROOT/public/dispatch.fcgi
This would be in a script called run in your ~/service/someapp-$RAIL_NUMBER
directory, where $RAIL_NUMBER is 1-99. The references to ./env require a
directory named env to be set up in the same directory as the run script.
This should have at least 3 files in it:
RAILS_ROOT => contains one line that is the full path to your rails root directory.
RAILS_ENV => contains one word, either production or development
RAILS_HOST => contains one IP address or FQDN
You can set any other environment variables in this way by simply creating a
file with the variable name and its contents will become the value of that
environment variable. Because of the envdir ./env call before the cgi-fcgi
call, your rails application has access to any variables set in this way.

View File

@@ -1,12 +0,0 @@
Index: cgi-fcgi/cgi-fcgi.c
===================================================================
--- cgi-fcgi/cgi-fcgi.c.orig 2009-09-17 18:14:16.000000000 +0200
+++ cgi-fcgi/cgi-fcgi.c 2009-09-17 18:19:16.139029013 +0200
@@ -651,6 +651,7 @@ static int ParseArgs(int argc, char *arg
tp1 = tp2;
}
}
+ fclose(fp);
err = ParseArgs(ac, av, doBindPtr, doStartPtr,
connectPathPtr, appPathPtr, nServersPtr, doDaemonPtr);
for(x = 1; x < ac; x++) {