CGI scripts
Tobias Poschwatta
tp at fonz.de
Fri Nov 14 15:58:45 UTC 2008
Hi,
I recently started to use the busybox HTTP server and I found that
that the CGI environment passed to scripts is incomplete.
While the CGI spec ( http://hoohoo.ncsa.uiuc.edu/cgi/env.html ) says
"the header lines received from the client [...] are placed into the
environment with the prefix HTTP_", I found only code for Cookie,
Content-Type, Referer and User-Agent.
I don't see a need to really pass all HTTP headers, but I'm missing
HTTP_HOST. Patch against 1.12.2 below.
Tobias
--- busybox-1.12.2.orig/networking/httpd.c 2008-11-14 16:17:15 +0100
+++ busybox-1.12.2/networking/httpd.c 2008-11-14 16:30:16 +0100
@@ -254,6 +254,7 @@ struct globals {
USE_FEATURE_HTTPD_BASIC_AUTH(char *remoteuser;)
USE_FEATURE_HTTPD_CGI(char *referer;)
USE_FEATURE_HTTPD_CGI(char *user_agent;)
+ USE_FEATURE_HTTPD_CGI(char *host;)
off_t file_size; /* -1 - unknown */
#if ENABLE_FEATURE_HTTPD_RANGES
@@ -298,6 +299,7 @@ struct globals {
#define g_realm (G.g_realm )
#define remoteuser (G.remoteuser )
#define referer (G.referer )
+#define host (G.host )
#define user_agent (G.user_agent )
#define file_size (G.file_size )
#if ENABLE_FEATURE_HTTPD_RANGES
@@ -1398,6 +1400,7 @@ static void send_cgi_and_exit(
#endif
if (referer)
setenv1("HTTP_REFERER", referer);
+ setenv1("HTTP_HOST", host);
xpiped_pair(fromCgi);
xpiped_pair(toCgi);
@@ -2005,6 +2008,8 @@ static void handle_incoming_and_exit(con
referer = xstrdup(skip_whitespace(iobuf + sizeof("Referer:")-1));
} else if (STRNCASECMP(iobuf, "User-Agent:") == 0) {
user_agent = xstrdup(skip_whitespace(iobuf + sizeof("User-Agent:")-1));
+ } else if (STRNCASECMP(iobuf, "Host:") == 0) {
+ host = xstrdup(skip_whitespace(iobuf + sizeof("Host:")-1));
}
#endif
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
More information about the busybox
mailing list