summaryrefslogtreecommitdiff
path: root/src/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexec')
-rw-r--r--src/libexec/httpd.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c
index c2a5daf..5fc4825 100644
--- a/src/libexec/httpd.c
+++ b/src/libexec/httpd.c
@@ -20,30 +20,30 @@
/* just notes for environment variables for CGIs when I need them.
Key Value
-DOCUMENT_ROOT The root directory of your server
-HTTP_COOKIE The visitor's cookie, if one is set
-HTTP_HOST The hostname of the page being attempted
-HTTP_REFERER The URL of the page that called your program
-HTTP_USER_AGENT The browser type of the visitor
-HTTPS "on" if the program is being called through a secure server
-PATH The system path your server is running under
-QUERY_STRING The query string (see GET, below)
-REMOTE_ADDR The IP address of the visitor
-REMOTE_HOST The hostname of the visitor (if your server has
- reverse-name-lookups on; otherwise this is the IP address again)
-REMOTE_PORT The port the visitor is connected to on the web server
-REMOTE_USER The visitor's username (for .htaccess-protected pages)
-REQUEST_METHOD GET or POST
-REQUEST_URI The interpreted pathname of the requested document or CGI
- (relative to the document root)
-SCRIPT_FILENAME The full pathname of the current CGI
-SCRIPT_NAME The interpreted pathname of the current CGI (relative to
- the document root)
-SERVER_ADMIN The email address for your server's webmaster
-SERVER_NAME Your server's fully qualified domain name (e.g.
- www.cgi101.com)
-SERVER_PORT The port number your server is listening on
-SERVER_SOFTWARE The server software you're using (e.g. Apache 1.3)
+_ DOCUMENT_ROOT The root directory of your server
+x HTTP_COOKIE The visitor's cookie, if one is set
+x HTTP_HOST The hostname of the page being attempted
+x HTTP_REFERER The URL of the page that called your program
+x HTTP_USER_AGENT The browser type of the visitor
+_ HTTPS "on" if the program is being called through a secure server
+x PATH The system path your server is running under
+x QUERY_STRING The query string (see GET, below)
+x REMOTE_ADDR The IP address of the visitor
+x REMOTE_HOST The hostname of the visitor (if your server has
+ reverse-name-lookups on; otherwise this is the IP address again)
+x REMOTE_PORT The port the visitor is connected to on the web server
+_ REMOTE_USER The visitor's username (for .htaccess-protected pages)
+x REQUEST_METHOD GET or POST
+_ REQUEST_URI The interpreted pathname of the requested document or CGI
+ (relative to the document root)
+_ SCRIPT_FILENAME The full pathname of the current CGI
+_ SCRIPT_NAME The interpreted pathname of the current CGI (relative to
+ the document root)
+x SERVER_ADMIN The email address for your server's webmaster
+x SERVER_NAME Your server's fully qualified domain name (e.g.
+ www.cgi101.com)
+x SERVER_PORT The port number your server is listening on
+x SERVER_SOFTWARE The server software you're using (e.g. Apache 1.3)
*/
void standard_headers() {
@@ -53,6 +53,7 @@ void standard_headers() {
int main(int argc,char *argv[]) {
int fd;
+ char tmp[512];
char *name[10];
int s,n;
char *method;
@@ -77,8 +78,11 @@ int main(int argc,char *argv[]) {
syslog(LOG_WARNING,"getsockname: %m");
getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),p,sizeof(p),NI_NUMERICHOST|NI_NUMERICSERV);
setenv("SERVER_ADDR",h,1);
+ setenv("SERVER_HOST",h,1);//only IP for now
setenv("SERVER_PORT",p,1);
+ setenv("SERVER_SOFTWARE",SERVER,1);
+
if(!strchr(line,'\n')) {
printf("HTTP/1.1 413 Entity Too Large\r\n");
standard_headers();
@@ -114,6 +118,12 @@ int main(int argc,char *argv[]) {
return 0;
}
if(strchr(line,'\r')) *strchr(line,'\r')=0;
+ if(!strncasecmp(line,"Referer: ",9)) {
+ setenv("HTTP_REFERER",line+9,1);
+ }
+ if(!strncasecmp(line,"Cookie: ",8)) {
+ setenv("HTTP_COOKIE",line+8,1);
+ }
if(!strncasecmp(line,"Host: ",6)) {
setenv("HTTP_HOST",line+6,1);
}
@@ -156,6 +166,9 @@ int main(int argc,char *argv[]) {
exit(2);
}
}
+ snprintf(tmp,sizeof(tmp),"webmaster@%s",getenv("HTTP_HOST"));
+ setenv("SERVER_NAME",getenv("HTTP_HOST"),1);
+ setenv("SERVER_ADMIN",tmp,1);
if(strncmp(page,"/cgi-bin/",9)) {
for(;*page == '/';page++);
if(page[strlen(page)-1] == '/') {
@@ -205,7 +218,6 @@ int main(int argc,char *argv[]) {
printf("HTTP/1.1 200 OK\r\n");
standard_headers();
fflush(stdout);
- //what was this needed for? breaks ?page=ident if closed.
if(!strcmp(method,"GET")) close(STDIN_FILENO);
execv(name[0],name);
}