From 21afacf4e3b5b03b15243a486a6e888a245c0052 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Sun, 21 Jun 2015 23:21:11 -0500 Subject: added HOST and USER env vars to httpd --- src/libexec/httpd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c index 5fc4825..d6e99ba 100644 --- a/src/libexec/httpd.c +++ b/src/libexec/httpd.c @@ -9,6 +9,7 @@ #include #include #include +#include #define VHOST_ROOT "/var/www/vhosts" #define SITES_ROOT "/var/www/sites" @@ -60,6 +61,7 @@ int main(int argc,char *argv[]) { char *page; char *version; char *get_param; + struct passwd *pwd; char line[getpagesize()]; fgets(line,sizeof(line)-1,stdin); struct sockaddr_in6 sa6; @@ -71,6 +73,12 @@ int main(int argc,char *argv[]) { if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1) syslog(LOG_WARNING,"getpeername: %m"); getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),p,sizeof(p),NI_NUMERICHOST|NI_NUMERICSERV); + if((pwd=getpwuid(getuid()))) { + setenv("USER",pwd->pw_name,1); + } + if(gethostname(h,NI_MAXHOST) != -1) { + setenv("HOST",h,1); + } setenv("REMOTE_ADDR",h,1); setenv("REMOTE_PORT",p,1); -- cgit v1.2.3