Changeset 2023
- Timestamp:
- 11/12/2007 04:02:47 PM (6 months ago)
- Files:
-
- branches/lighttpd-1.4.x/src/spawn-fcgi.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/lighttpd-1.4.x/src/spawn-fcgi.c
r2021 r2023 38 38 39 39 #ifdef HAVE_SYS_UN_H 40 int fcgi_spawn_connection(char *appPath, char * addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) {40 int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) { 41 41 int fcgi_fd; 42 42 int socket_type, status; … … 138 138 case 0: { 139 139 char cgi_childs[64]; 140 char *b;141 140 142 141 int i = 0; … … 161 160 162 161 /* fork and replace shell */ 163 b = malloc(strlen("exec ") + strlen(appPath) + 1); 164 strcpy(b, "exec "); 165 strcat(b, appPath); 166 167 /* exec the cgi */ 168 execl("/bin/sh", "sh", "-c", b, (char *)NULL); 162 if (appArgv) { 163 execv(appArgv[0], appArgv); 164 165 } else { 166 char *b = malloc(strlen("exec ") + strlen(appPath) + 1); 167 strcpy(b, "exec "); 168 strcat(b, appPath); 169 170 /* exec the cgi */ 171 execl("/bin/sh", "sh", "-c", b, (char *)NULL); 172 } 169 173 170 174 exit(errno); … … 240 244 241 245 void show_help () { 242 char *b = "spawn-fcgi" "-" PACKAGE_VERSION \ 243 " - spawns fastcgi processes\n" \ 244 "usage:\n" \ 246 char *b = \ 247 "Usage: spawn-fcgi [options] -- <fcgiapp> [fcgi app arguments]\n" \ 248 "\n" \ 249 "spawn-fcgi v" PACKAGE_VERSION " - spawns fastcgi processes\n" \ 250 "\n" \ 251 "Options:\n" \ 245 252 " -f <fcgiapp> filename of the fcgi-application\n" \ 246 253 " -a <addr> bind to ip address\n" \ … … 265 272 *groupname = NULL, *unixsocket = NULL, *pid_file = NULL, 266 273 *addr = NULL; 274 char **fcgi_app_argv = { NULL }; 267 275 unsigned short port = 0; 268 276 int child_count = 5; … … 275 283 i_am_root = (getuid() == 0); 276 284 277 while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) {285 while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) { 278 286 switch(o) { 279 287 case 'f': fcgi_app = optarg; break; … … 295 303 } 296 304 297 if (fcgi_app == NULL || (port == 0 && unixsocket == NULL)) { 305 if (optind < argc) { 306 fcgi_app_argv = &argv[optind]; 307 } 308 309 if ((fcgi_app == NULL && fcgi_app_argv == NULL) || (port == 0 && unixsocket == NULL)) { 298 310 show_help(); 299 311 return -1; … … 438 450 } 439 451 440 return fcgi_spawn_connection(fcgi_app, addr, port, unixsocket, child_count, pid_fd, nofork);452 return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, child_count, pid_fd, nofork); 441 453 } 442 454 #else

