summaryrefslogtreecommitdiff
path: root/src/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexec')
-rw-r--r--src/libexec/httpd.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c
index f22e139..c2a5daf 100644
--- a/src/libexec/httpd.c
+++ b/src/libexec/httpd.c
@@ -64,11 +64,21 @@ int main(int argc,char *argv[]) {
struct sockaddr_in6 sa6;
unsigned int sl=sizeof(sa6);
char h[NI_MAXHOST];
+ char p[NI_MAXSERV];
openlog("httpd",LOG_PID,LOG_DAEMON);
+
if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1)
syslog(LOG_WARNING,"getpeername: %m");
- getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),0,0,NI_NUMERICHOST);
+ getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),p,sizeof(p),NI_NUMERICHOST|NI_NUMERICSERV);
setenv("REMOTE_ADDR",h,1);
+ setenv("REMOTE_PORT",p,1);
+
+ if(getsockname(0,(struct sockaddr *)&sa6,&sl) == -1)
+ 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_PORT",p,1);
+
if(!strchr(line,'\n')) {
printf("HTTP/1.1 413 Entity Too Large\r\n");
standard_headers();
@@ -116,7 +126,7 @@ int main(int argc,char *argv[]) {
}
alarm(0);//no more timeout.
//
- syslog(LOG_WARNING,"%s: %s %s %s\n",h,getenv("HTTP_USER_AGENT"),page,get_param);
+ syslog(LOG_WARNING,"%s: %s %s %s %s\n",h,getenv("HTTP_HOST"),getenv("HTTP_USER_AGENT"),page,get_param);
//TODO: sanitize this.
if(chdir(VHOST_ROOT) == -1) {
printf("HTTP/1.1 500 Internal Server Error\r\n");
@@ -195,6 +205,8 @@ 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);
}
return 0;