summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2015-06-21 23:21:11 -0500
committerepochqwert <epoch@hacking.allowed.org>2015-06-21 23:21:11 -0500
commit21afacf4e3b5b03b15243a486a6e888a245c0052 (patch)
tree1475830047b6e4d4eced8a574f154a87dc997403
parentd8104b6c07c5ec374a4af4f2812b6033f5e69988 (diff)
downloadmisc-21afacf4e3b5b03b15243a486a6e888a245c0052.tar.gz
misc-21afacf4e3b5b03b15243a486a6e888a245c0052.zip
added HOST and USER env vars to httpd
-rw-r--r--src/libexec/httpd.c8
1 files changed, 8 insertions, 0 deletions
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 <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <pwd.h>
#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);