[package] update hiawatha to 6.12 (#4854)
[openwrt/svn-archive/archive.git] / net / spawn-fcgi / patches / 100-spawn-fcgi_new_opt_directory.patch
1 diff -pruN spawn-fcgi-1.6.0.orig/src/spawn-fcgi.c spawn-fcgi-1.6.0/src/spawn-fcgi.c
2 --- spawn-fcgi-1.6.0.orig/src/spawn-fcgi.c 2009-03-05 16:43:00.160440493 +0100
3 +++ spawn-fcgi-1.6.0/src/spawn-fcgi.c 2009-03-05 16:55:17.840995588 +0100
4 @@ -59,7 +59,7 @@
5 typedef int socklen_t;
6 #endif
7
8 -static int 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) {
9 +static int fcgi_spawn_connection(char *appPath, const char *fcgi_dir, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int fork_count, int child_count, int pid_fd, int nofork) {
10 int fcgi_fd;
11 int socket_type, status, rc = 0;
12 struct timeval tv = { 0, 100 * 1000 };
13 @@ -206,6 +206,11 @@ static int fcgi_spawn_connection(char *a
14 strcat(b, appPath);
15
16 /* exec the cgi */
17 + if (fcgi_dir) {
18 + if (chdir(fcgi_dir) != 0) {
19 + exit(errno);
20 + }
21 + }
22 execl("/bin/sh", "sh", "-c", b, (char *)NULL);
23 }
24
25 @@ -347,6 +352,7 @@ static void show_help () {
26 "\n" \
27 "Options:\n" \
28 " -f <path> filename of the fcgi-application (ignored if <fcgiapp> is given)\n" \
29 +" -d <dir> chdir to directory before spawning\n" \
30 " -a <addr> bind to ip address\n" \
31 " -p <port> bind to tcp-port\n" \
32 " -s <path> bind to unix-domain socket\n" \
33 @@ -367,7 +373,7 @@ static void show_help () {
34
35
36 int main(int argc, char **argv) {
37 - char *fcgi_app = NULL, *changeroot = NULL, *username = NULL,
38 + char *fcgi_app = NULL, *fcgi_dir = NULL, *changeroot = NULL, *username = NULL,
39 *groupname = NULL, *unixsocket = NULL, *pid_file = NULL,
40 *addr = NULL;
41 char **fcgi_app_argv = { NULL };
42 @@ -386,9 +392,10 @@ int main(int argc, char **argv) {
43
44 i_am_root = (getuid() == 0);
45
46 - while (-1 != (o = getopt(argc, argv, "c:f:g:?hna:p:u:vC:F:s:P:"))) {
47 + while (-1 != (o = getopt(argc, argv, "c:f:d:g:?hna:p:u:vC:F:s:P:"))) {
48 switch(o) {
49 case 'f': fcgi_app = optarg; break;
50 + case 'd': fcgi_dir = optarg; break;
51 case 'a': addr = optarg;/* ip addr */ break;
52 case 'p': port = strtol(optarg, NULL, 10);/* port */ break;
53 case 'C': child_count = strtol(optarg, NULL, 10);/* */ break;
54 @@ -507,5 +514,5 @@ int main(int argc, char **argv) {
55 }
56 }
57
58 - return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, fork_count, child_count, pid_fd, nofork);
59 + return fcgi_spawn_connection(fcgi_app, fcgi_dir, fcgi_app_argv, addr, port, unixsocket, fork_count, child_count, pid_fd, nofork);
60 }