Ticket #1428: lighttpd-spawn-fcgi-argv.patch
| File lighttpd-spawn-fcgi-argv.patch, 2.4 kB (added by glen, 6 months ago) |
|---|
-
src/spawn-fcgi.c
old new 37 37 #endif 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; 43 43 struct timeval tv = { 0, 100 * 1000 }; … … 137 137 switch (child) { 138 138 case 0: { 139 139 char cgi_childs[64]; 140 char *b;141 140 142 141 int i = 0; 143 142 … … 160 159 putenv(cgi_childs); 161 160 162 161 /* fork and replace shell */ 163 b = malloc(strlen("exec ") + strlen(appPath) + 1); 164 strcpy(b, "exec "); 165 strcat(b, appPath); 162 if (appArgv) { 163 execv(appArgv[0], appArgv); 166 164 167 /* exec the cgi */ 168 execl("/bin/sh", "sh", "-c", b, (char *)NULL); 165 } else { 166 char *b = malloc(strlen("exec ") + strlen(appPath) + 1); 167 strcpy(b, "exec "); 168 strcat(b, appPath); 169 169 170 /* exec the cgi */ 171 execl("/bin/sh", "sh", "-c", b, (char *)NULL); 172 } 173 170 174 exit(errno); 171 175 172 176 break; … … 264 268 char *fcgi_app = NULL, *changeroot = NULL, *username = NULL, 265 269 *groupname = NULL, *unixsocket = NULL, *pid_file = NULL, 266 270 *addr = NULL; 271 char **fcgi_app_argv = { NULL }; 267 272 unsigned short port = 0; 268 273 int child_count = 5; 269 274 int i_am_root, o; … … 274 279 275 280 i_am_root = (getuid() == 0); 276 281 277 while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) {282 while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) { 278 283 switch(o) { 279 284 case 'f': fcgi_app = optarg; break; 280 285 case 'a': addr = optarg;/* ip addr */ break; … … 294 299 } 295 300 } 296 301 297 if (fcgi_app == NULL || (port == 0 && unixsocket == NULL)) { 302 if (optind < argc) { 303 fcgi_app_argv = &argv[optind]; 304 } 305 306 if ((fcgi_app == NULL && fcgi_app_argv == NULL) || (port == 0 && unixsocket == NULL)) { 298 307 show_help(); 299 308 return -1; 300 309 } … … 437 446 } 438 447 } 439 448 440 return fcgi_spawn_connection(fcgi_app, addr, port, unixsocket, child_count, pid_fd, nofork);449 return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, child_count, pid_fd, nofork); 441 450 } 442 451 #else 443 452 int main() {

