diff -ruN ./thttpd-2.25b.orig/libhttpd.c ./thttpd-2.25b/libhttpd.c --- ./thttpd-2.25b.orig/libhttpd.c 2005-06-29 19:50:39.000000000 +0200 +++ ./thttpd-2.25b/libhttpd.c 2006-08-10 14:57:45.000000000 +0200 @@ -2998,6 +2998,16 @@ #endif /* SERVER_NAME_LIST */ +char* cget_www_dir; + +static char* get_www_dir() { + return cget_www_dir; +} + +void set_www_dir(char* tmp) { + cget_www_dir = tmp; +} + /* Set up environment variables. Be real careful here to avoid ** letting malicious clients overrun a buffer. We don't have ** to worry about freeing stuff since we're a sub-process. @@ -3042,9 +3052,20 @@ envp[envn++] = build_env( "PATH_TRANSLATED=%s", cp2 ); } } + envp[envn++] = build_env( "SCRIPT_NAME=/%s", strcmp( hc->origfilename, "." ) == 0 ? "" : hc->origfilename ); + + char* cp2; + size_t l; + l = strlen( get_www_dir() ) + strlen( hc->expnfilename ) + 2; + cp2 = NEW( char, l); + if ( cp2 != (char*) 0 ) { + (void) my_snprintf(cp2, l, "%s/%s", get_www_dir(), hc->expnfilename); + envp[envn++] = build_env("SCRIPT_FILENAME=%s", cp2 ); + } + if ( hc->query[0] != '\0') envp[envn++] = build_env( "QUERY_STRING=%s", hc->query ); envp[envn++] = build_env( diff -ruN ./thttpd-2.25b.orig/libhttpd.h ./thttpd-2.25b/libhttpd.h --- ./thttpd-2.25b.orig/libhttpd.h 2005-06-29 19:50:41.000000000 +0200 +++ ./thttpd-2.25b/libhttpd.h 2006-08-10 14:48:18.000000000 +0200 @@ -281,4 +281,7 @@ /* Generate debugging statistics syslog message. */ extern void httpd_logstats( long secs ); +static char* get_www_dir(); +void set_www_dir( char* d); + #endif /* _LIBHTTPD_H_ */ diff -ruN ./thttpd-2.25b.orig/thttpd.c ./thttpd-2.25b/thttpd.c --- ./thttpd-2.25b.orig/thttpd.c 2005-06-29 19:50:59.000000000 +0200 +++ ./thttpd-2.25b/thttpd.c 2006-08-10 14:44:16.000000000 +0200 @@ -1051,6 +1051,7 @@ { value_required( name, value ); dir = e_strdup( value ); + set_www_dir(dir); } else if ( strcasecmp( name, "chroot" ) == 0 ) {