Changeset 2025

Show
Ignore:
Timestamp:
11/12/2007 04:12:50 PM (6 months ago)
Author:
glen
Message:

- use execv() directly to fcgi app if used as argument. resolves #1428

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/NEWS

    r2015 r2025  
    1010  * fixed network-backend-solaris-sendfilev (EINVAL in writev()) 
    1111  * fixed initgroups() called after chroot (#1384) 
     12  * execute fcgi app without /bin/sh if used as argument to spawn-fcgi (#1428) 
    1213 
    1314- 1.5.0-r19.. -  
     
    1516  * replaced mod_fastcgi, mod_scgi, mod_proxy with mod_proxy_core + backends 
    1617  * added query-string parsing for mod_uploadprogress 
    17   * added threaded stat()  
     18  * added threaded stat() 
    1819  * added threaded disk-read() support 
    1920  * added dir-listing.set-footer in mod_dirlisting (#1277) 
    2021  * added logging of the PID and UID of the sending process for SIGTERM and SIGINT 
    2122  * added support for AJP13 to mod_proxy_core 
    22   * fixed the out-of-fd support  
     23  * fixed the out-of-fd support 
    2324  * fixed crash in mod_expire if 'modification' is used and stat() failed (#1063) 
    2425  * fixed hardcoded font-sizes in mod_dirlisting (#1267) 
     
    3536  * fixed missing check for base64 encoded string in mod_auth and Basic auth 
    3637    (reported by Stefan Esser) 
    37   * fixed possible crash in Auth-Digest header parser on trailing WS in  
     38  * fixed possible crash in Auth-Digest header parser on trailing WS in 
    3839    mod_auth (reported by Stefan Esser) 
  • trunk/src/spawn-fcgi.c

    r2022 r2025  
    4242 
    4343#ifdef HAVE_SYS_UN_H 
    44 int fcgi_spawn_connection(char *appPath, char *addr, unsigned short port, const char *unixsocket, int fork_count, int child_count, int pid_fd, int nofork) { 
     44int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int fork_count, int child_count, int pid_fd, int nofork) { 
    4545        int fcgi_fd; 
    4646        int socket_type, status; 
     
    144144                        case 0: { 
    145145                                char cgi_childs[64]; 
    146                                 char *b; 
    147146                                int max_fd = 0; 
    148147 
     
    181180 
    182181                                /* fork and replace shell */ 
    183                                 b = malloc(strlen("exec ") + strlen(appPath) + 1); 
    184                                 strcpy(b, "exec "); 
    185                                 strcat(b, appPath); 
    186  
    187                                 /* exec the cgi */ 
    188                                 execl("/bin/sh", "sh", "-c", b, (char *)NULL); 
     182                                if (appArgv) { 
     183                                        execv(appArgv[0], appArgv); 
     184 
     185                                } else { 
     186                                        char *b = malloc(strlen("exec ") + strlen(appPath) + 1); 
     187                                        strcpy(b, "exec "); 
     188                                        strcat(b, appPath); 
     189 
     190                                        /* exec the cgi */ 
     191                                        execl("/bin/sh", "sh", "-c", b, (char *)NULL); 
     192                                } 
    189193 
    190194                                exit(errno); 
     
    265269 
    266270void show_help () { 
    267         char *b = "spawn-fcgi" "-" PACKAGE_VERSION \ 
    268 " - spawns fastcgi processes\n" \ 
    269 "usage:\n" \ 
     271        char *b = \ 
     272"Usage: spawn-fcgi [options] -- <fcgiapp> [fcgi app arguments]\n" \ 
     273"\n" \ 
     274"spawn-fcgi v" PACKAGE_VERSION " - spawns fastcgi processes\n" \ 
     275"\n" \ 
     276"Options:\n" \ 
    270277" -f <fcgiapp> filename of the fcgi-application\n" \ 
    271278" -a <addr>    bind to ip address\n" \ 
     
    291298               *groupname = NULL, *unixsocket = NULL, *pid_file = NULL, 
    292299                *addr = NULL; 
     300        char **fcgi_app_argv = { NULL }; 
    293301        unsigned short port = 0; 
    294302        int child_count = 5; 
     
    301309        i_am_root = (getuid() == 0); 
    302310 
    303        while (-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:F:s:P:"))) { 
     311       while (-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:F:s:P:"))) { 
    304312                switch(o) { 
    305313                case 'f': fcgi_app = optarg; break; 
     
    322330        } 
    323331 
    324         if (fcgi_app == NULL || (port == 0 && unixsocket == NULL)) { 
     332        if (optind < argc) { 
     333                fcgi_app_argv = &argv[optind]; 
     334        } 
     335 
     336        if ((fcgi_app == NULL && fcgi_app_argv == NULL) || (port == 0 && unixsocket == NULL)) { 
    325337                show_help(); 
    326338                return -1; 
     
    462474        } 
    463475 
    464        return fcgi_spawn_connection(fcgi_app, addr, port, unixsocket, fork_count, child_count, pid_fd, nofork); 
     476       return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, fork_count, child_count, pid_fd, nofork); 
    465477} 
    466478#else