diff options
Diffstat (limited to 'src/libexec')
-rw-r--r-- | src/libexec/httpd.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c index 812e051..41339ae 100644 --- a/src/libexec/httpd.c +++ b/src/libexec/httpd.c @@ -5,6 +5,9 @@ #include <unistd.h> #include <syslog.h> #include <sys/wait.h> +#include <sys/socket.h> +#include <netdb.h> +#include <netinet/in.h> #define VHOST_ROOT "/var/www/vhosts" #define SITES_ROOT "/var/www/sites" @@ -26,8 +29,12 @@ int main(int argc,char *argv[]) { char *get_param; char line[getpagesize()]; fgets(line,sizeof(line)-1,stdin); -// syslog(LOG_INFO,"ADDRESS did a LINE"); -// syslog(LOG_WARNING,"httpd syslog test\n"); + struct sockaddr_in6 sa6; + unsigned int sl=sizeof(sa6); + char h[NI_MAXHOST]; + 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); + setenv("REMOTE_ADDR",h,1); if(!strchr(line,'\n')) { printf("HTTP/1.1 413 Entity Too Large\r\n"); standard_headers(); @@ -36,6 +43,7 @@ int main(int argc,char *argv[]) { return 0; } if(strchr(line,'\r')) *strchr(line,'\r')=0; + syslog(LOG_WARNING,"%s %s\n",h,line); method=strdup(line); if((page=strchr(method,' '))) { *page=0; |