summaryrefslogtreecommitdiffstats
path: root/package/uhttpd/src/uhttpd-cgi.c
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-08-14 00:54:24 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-08-14 00:54:24 +0000
commit2540dbba3ba74ff9a4c81890397f3db069b27968 (patch)
tree17bc5dc1b3511e6b222aeb5d83d1d62a758d43b5 /package/uhttpd/src/uhttpd-cgi.c
parente3198ce2ac7ff4602d1f2642e2a121f51dfff0fe (diff)
[package] uhttpd:
- more robust handling of network failures on static file serving - support unlimited amount of authentication realms, listener and client sockets - support for interpreters (.php => /usr/bin/php-cgi) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22630 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/uhttpd/src/uhttpd-cgi.c')
-rw-r--r--package/uhttpd/src/uhttpd-cgi.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/package/uhttpd/src/uhttpd-cgi.c b/package/uhttpd/src/uhttpd-cgi.c
index 086124916..f9dd9810d 100644
--- a/package/uhttpd/src/uhttpd-cgi.c
+++ b/package/uhttpd/src/uhttpd-cgi.c
@@ -135,8 +135,10 @@ static int uh_cgi_error_500(struct client *cl, struct http_request *req, const c
}
-void uh_cgi_request(struct client *cl, struct http_request *req, struct path_info *pi)
-{
+void uh_cgi_request(
+ struct client *cl, struct http_request *req,
+ struct path_info *pi, struct interpreter *ip
+) {
int i, hdroff, bufoff;
int hdrlen = 0;
int buflen = 0;
@@ -199,9 +201,9 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf
dup2(rfd[1], 1);
dup2(wfd[0], 0);
- /* check for regular, world-executable file */
- if( (pi->stat.st_mode & S_IFREG) &&
- (pi->stat.st_mode & S_IXOTH)
+ /* check for regular, world-executable file _or_ interpreter */
+ if( ((pi->stat.st_mode & S_IFREG) &&
+ (pi->stat.st_mode & S_IXOTH)) || (ip != NULL)
) {
/* build environment */
clearenv();
@@ -320,14 +322,17 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf
if( chdir(pi->root) )
perror("chdir()");
- execl(pi->phys, pi->phys, NULL);
+ if( ip != NULL )
+ execl(ip->path, ip->path, pi->phys, NULL);
+ else
+ execl(pi->phys, pi->phys, NULL);
/* in case it fails ... */
printf(
"Status: 500 Internal Server Error\r\n\r\n"
"Unable to launch the requested CGI program:\n"
" %s: %s\n",
- pi->phys, strerror(errno)
+ ip ? ip->path : pi->phys, strerror(errno)
);
}