[busybox][patch] add DOCUMENT_ROOT and SCRIPT_FILENAME to Env (for php cgi scripts)
Jon Nalley
jon at nalleynet.com
Fri May 14 02:19:17 UTC 2004
The attached patch adds DOCUMENT_ROOT and SCRIPT_FILENAME to the
environment for cgi scripts. This is needed for executing php CGI
scripts.
-------------- next part --------------
--- busybox-1.00-pre10/networking/httpd.c.orig Mon Mar 15 02:28:48 2004
+++ busybox-1.00-pre10/networking/httpd.c Wed Apr 14 15:49:35 2004
@@ -120,6 +120,7 @@
static const char default_path_httpd_conf[] = "/etc";
static const char httpd_conf[] = "httpd.conf";
static const char home[] = "./";
+static const char *home_httpd = "./";
#ifdef CONFIG_LFS
# define cont_l_fmt "%lld"
@@ -1077,6 +1078,7 @@
if (!pid) {
/* child process */
char *script;
+ char *scriptfilename;
char *purl = strdup( url );
char realpath_buff[MAXPATHLEN];
@@ -1115,6 +1117,7 @@
}
*script = '/'; /* is directory, find next '/' */
}
+ addEnv("DOCUMENT_ROOT", "", home_httpd);
addEnv("PATH", "INFO", script); /* set /PATH_INFO or NULL */
addEnv("PATH", "", getenv("PATH"));
addEnv("REQUEST", "METHOD", request);
@@ -1130,6 +1133,13 @@
*script = '\0'; /* reduce /PATH_INFO */
/* set SCRIPT_NAME as full path: /cgi-bin/dirs/script.cgi */
addEnv("SCRIPT_NAME", "", purl);
+
+ scriptfilename = strdup(home_httpd);
+ strcat(scriptfilename, purl);
+
+ /* Create the Script File Name */
+ addEnv("SCRIPT_FILENAME", "", scriptfilename);
+
addEnv("QUERY_STRING", "", urlArgs);
addEnv("SERVER", "SOFTWARE", httpdVersion);
addEnv("SERVER", "PROTOCOL", "HTTP/1.0");
@@ -1899,7 +1909,7 @@
#endif
{
unsigned long opt;
- const char *home_httpd = home;
+ home_httpd = home;
char *url_for_decode;
#ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
const char *url_for_encode;
More information about the busybox
mailing list