From 3145f7d29121874be139556a3b0e6317c3045e3f Mon Sep 17 00:00:00 2001
From: I am not me ");
diff --git a/cgi-src/phf.c b/cgi-src/phf.c
old mode 100755
new mode 100644
diff --git a/cgi-src/query.c b/cgi-src/query.c
old mode 100755
new mode 100644
diff --git a/cgi-src/util.c b/cgi-src/util.c
index f02eb06..c3d5d65 100644
--- a/cgi-src/util.c
+++ b/cgi-src/util.c
@@ -139,7 +139,7 @@ void escape_shell_cmd(char *cmd) {
l=strlen(cmd);
for(x=0;cmd[x];x++) {
- if(ind("&;`'\"|*?~<>^()[]{}$\\",cmd[x]) != -1){
+ if(ind("&;`'\"|*?~<>^()[]{}$\\\x0A",cmd[x]) != -1){
for(y=l+1;y>x;y--)
cmd[y] = cmd[y-1];
l++; /* length has been increased */
diff --git a/conf/httpd.conf-dist b/conf/httpd.conf-dist
index ae97f4c..973b293 100644
--- a/conf/httpd.conf-dist
+++ b/conf/httpd.conf-dist
@@ -160,13 +160,13 @@ AccessConfig conf/access.conf
LogOptions Separate
-# LogDirGroupWriteOk, LogDirPublicWriteOk: Define either of these if you
+# LogDirGroupWriteOk, LogDirOtherWriteOk: Define either of these if you
# want the server to start even if you have write permissions on the log
# directory. Having write permissions set is a potential security hole.
# Only makes a difference if the server process is started by root.
#LogDirGroupWriteOk
-#LogDirPublicWriteOk
+#LogDirOtherWriteOk
# RefererIgnore: If you don't want to keep track of links from certain
# servers (like your own), place it here. If you want to log them all,
diff --git a/conf/srm.conf-dist b/conf/srm.conf-dist
index 70881f5..1d713fb 100644
--- a/conf/srm.conf-dist
+++ b/conf/srm.conf-dist
@@ -43,6 +43,19 @@ Alias /icons/ /usr/local/etc/httpd/icons/
ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/
+#===========================================================================
+# OpenMarket's FCGI Support Options (http://www.fastcgi.com/
+#---------------------------------------------------------------------------
+# FCGIScritpAlias: Same as ScriptAlias, except for FCGI scripts
+# Format: FCGIScriptAlias fakename realname
+
+FCGIScriptAlias /fcgi-bin/ /usr/local/etc/httpd/fcgi-devel-kit/examples/
+
+# Define the AppClasses. These get hit when requests come in for
+# /fcgi-bin/tiny-fcgi.fcgi or /fcgi-bin/tiny-fcgi2.fcgi
+AppClass /usr/local/etc/httpd/fcgi-devel-kit/examples/tiny-fcgi.fcgi -listen-queue-depth 10 -processes 2
+AppClass /usr/local/etc/httpd/fcgi-devel-kit/examples/tiny-fcgi2.fcgi -listen-queue-depth 10 -processes 2
+
#===========================================================================
# Directory Indexing
#---------------------------------------------------------------------------
@@ -122,8 +135,8 @@ DefaultType text/plain
# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
# information on the fly. Note: Not all browsers support this.
-#AddEncoding x-compress Z
-#AddEncoding x-gzip gz
+#AddEncoding compress Z
+#AddEncoding gzip gz
# The following are known to the server as "Magic Mime Types" They allow
# you to change how the server perceives a document by the extension
@@ -137,6 +150,7 @@ DefaultType text/plain
#AddType text/x-server-parsed-html .shtml
#AddType text/x-imagemap .map
#AddType application/x-httpd-cgi .cgi
+#AddType application/x-httpd-fcgi .fcgi
#===========================================================================
# Misc Server Resources
diff --git a/src/CHANGES b/src/CHANGES
new file mode 100644
index 0000000..7343828
--- /dev/null
+++ b/src/CHANGES
@@ -0,0 +1,16 @@
+
+Fixes for 1.5.2
+------------------
+*) Changed getline rfc822 line wrap to check for validity of the next bits
+ before attempting to see them
+*) Changed imagemap.c so relative URLs actually work
+*) Don't core dump on a method only request
+*) reset errno to 0 in send_fp so we break out of loop
+*) somewhere we stopped killing cgi scripts on SIGALRM and SIGPIPE
+*) changed group handling support to support multiple groups again
+*) reset content_length before scanning cgi headers, not after
+*) don't free env var in replace (it uses allocate now)
+*) Only look for path_info if its part of the requested URL (as opposed
+ to keep looking until you hit a real directory)
+*) Make make_dirstr() in util.c return / instead of null if n = 1
+
diff --git a/src/FEATURE_REQUESTS b/src/FEATURE_REQUESTS
new file mode 100644
index 0000000..2efed4f
--- /dev/null
+++ b/src/FEATURE_REQUESTS
@@ -0,0 +1,37 @@
+
+Port configurable per VirtualHost
+ kadow@msg.net (Kevin Kadow)
+Server Parse CGI output
+ not feasible because SSI parser using buffered I/O, CGI uses getline()
+ (server buffered I/O)
+ But, we did it anyways. See CGI_SSI_HACK in config.h
+Allow extra CGI environment variables to be specified via configuration
+ Kevin Kadow (kadow@msg.net) and Brian Millett (bpm@techapp.com)
+ Shouldn't be too hard, probably in 1.5.1b4
+ Ok, maybe in 1.5.2
+AuthUserScript - Heiner Schorn (Heiner.Schorn@informatik.umu.se)
+ Pass a user name to a script, it returns the password to check against
+ the one the client sent to the server. This is safe from someone
+ writing a script to gather passwords, because the given password is
+ never sent to the script. This is unsafe on the server system because
+ it will return the password of a user. That could be made safer by
+ making the mechanism employ crypt on the password before hand..
+ Shouldn't be too hard, but needs some design work. Perhaps 1.5.1b4
+ Ok, maybe 1.5.2
+Have separate UID/GID per CGI script - Marc Evans (marc@destek.net)
+ With Patch (NF-1.5b7-marc_cgi_uid_hack)
+ Basically, changes calls from setuid to seteuid, so it changes the
+ effective user id of the server. This makes any security hole
+ potentially dangerous, such as the one in 1.3, since the program
+ that you can force to run can set the euid back to root.
+ Look at it for 1.5.1b4, probably always have to be a #define for the
+ more security conscious users of NCSA HTTPd
+ Push off to 1.5.2
+SHTTP
+ Alpha is done, but we need to test it more
+SSL
+ Again, alpha code is in place, but it needs to be tested more
+RADIUS
+ Ok, I was expecting something slightly different. Doesn't quite fit
+ the current way of doing things, but shouldn't be too hard to figure
+ out either. Probably 1.5.2
diff --git a/src/HTTP_HEADERS b/src/HTTP_HEADERS
new file mode 100644
index 0000000..f57d1ad
--- /dev/null
+++ b/src/HTTP_HEADERS
@@ -0,0 +1,81 @@
+
+The following is NCSA HTTPd treatment of HTTP headers. By Supported,
+we mean that the server explicitly manipulates the headers. This
+doesn't include forwarding of headers to CGI scripts or including
+headers from CGI scripts.
+
+In
+HTTP HEADER HTTP Section Sup to/why length Used for?
+Date 1.0 General N Do I care what the clients date is?
+MIME-Version 1.0 General N The server isn't MIME Compliant
+Pragma 1.0 General N Only no-cache is defined, and this isn't a proxy server
+Authorization 1.0 Request Y reqInfo->inh_auth_line HUGE_STRING_LEN Authentication (Basic/MD5/Keberos)
+From 1.0 Request N no one uses it
+If-Modified-Since 1.0 Request Y reqInfo->inh_if_mod MAX_STRING_LEN 304 Use Local Copy response
+Referer 1.0 Request Y reqInfo->inh_referer HUGE_STRING_LEN Logs
+User-agent 1.0 Request Y reqInfo->inh_agent HUGE_STRING_LEN Logs
+Allow 1.0 Entity N not clear how useful in request
+Content-Encoding 1.0 Entity N
+Content-Length 1.0 Entity Y reqInfo->inh_content_length int POST content length
+Content-Type 1.0 Entity Y reqInfo->inh_content_type MAX_STRING_LEN POST content should be application/x-www-form-urlencoded
+Expires 1.0 Entity N time request expires?
+Last-Modified 1.0 Entity N last time request was modified?
+Cache-Control 1.1 General N
+Connection 1.1 General Y Keep-Alive
+Forwarded 1.1 General N
+Keep-Alive 1.1 General N max= timeout= same
+Upgrade 1.1 General N
+Accept 1.1 Request N
+Accept-Charset 1.1 Request N
+Accept-Encoding 1.1 Request N
+Accept-Language 1.1 Request N
+Host 1.1 Request Y reqInfo->inh_called_hostname MAX_STRING_LEN to provide virtual host support with CNAMES
+Proxy-Authorization 1.1 Request N
+Range 1.1 Request N
+Unless 1.1 Request N
+Content-Language 1.1 Entity N
+Content-MD5 1.1 Entity N
+Content-Range 1.1 Entity N
+Content-Version 1.1 Entity N
+Derived-From 1.1 Entity N
+Link 1.1 Entity N
+Title 1.1 Entity N
+Transfer-Encoding 1.1 Entity N
+URI-header 1.1 Entity N
+Extension
+
+
+Out
+HTTP HEADER HTTP Section Sup from/why
+Date 1.0 General Y GMT Date in rfc 822 format
+MIME-Version 1.0 General N The server isn't MIME Compliant
+Pragma 1.0 General N Only no-cache is defined, and this isn't a proxy server
+Location 1.0 Response Y reqInfo->outh_location HUGE_STRING_LEN redirects
+Server 1.0 Response Y #define SERVER_VERSION
+WWW-Authenticate 1.0 Response Y reqInfo->outh_www_auth HUGE_STRING_LEN
+Allow 1.0 Entity N We could make a list in evaluate_access(), but wouldn't that be a security hole?
+Content-Encoding 1.0 Entity Y reqInfo->outh_content_encoding MAX_STRING_LEN AddEncoding
+Content-Length 1.0 Entity Y reqInfo->outh_content_length int
+Content-Type 1.0 Entity Y reqInfo->outh_content_type MAX_STRING_LEN
+Expires 1.0 Entity N could add an AddExpires config option
+Last-Modified 1.0 Entity Y reqInfo->outh_last_mod MAX_STRING_LEN client caching
+Cache-Control 1.1 General N
+Connection 1.1 General Y keep_alive. stuff Keep-Alive
+Forwarded 1.1 General N
+Keep-Alive 1.1 General Y max= timeout= same
+Upgrade 1.1 General N
+Proxy-Authenticate 1.1 Response N
+Public 1.1 Response N
+Retry-After 1.1 Response N
+Content-Language 1.1 Entity N
+Content-MD5 1.1 Entity Y reqInfo->outh_content_md5 allocated do you get what you asked for
+Content-Range 1.1 Entity N
+Content-Version 1.1 Entity N
+Derived-From 1.1 Entity N
+Link 1.1 Entity N
+Title 1.1 Entity N
+Transfer-Encoding 1.1 Entity N
+URI-header 1.1 Entity N
+Annotations-cgi reqInfo->hostInfo->annotation_server
+Extension: Domain-Restricted reqInfo->bNotifyDomainRestricted &&
+ reqInfo->bSatisfiedDomain
diff --git a/src/HTTPd_REQ_PATH b/src/HTTPd_REQ_PATH
new file mode 100644
index 0000000..d081916
--- /dev/null
+++ b/src/HTTPd_REQ_PATH
@@ -0,0 +1,212 @@
+child_main httpd.c
+ GetDescriptor httpd.c
+ setproctitle
+ recv_fd
+ GetRemoteLogName httpd.c
+ getpeername
+ rfc931
+ initialize_request http_request.c
+ malloc
+ reset_security http_access.c
+ free
+ init_header_vars http_mime.c
+ free
+ RequestMain http_request.c
+ signal
+ getline
+ setproctitle
+ decode_request http_request.c
+ strtok
+ MapMethod http_request.c
+ get_mime_headers
+ getline
+ strchr
+ isspace
+ strcasecmp
+ http2cgi util.c
+ merge_header env.c
+ realloc
+ make_env_str env.c
+ malloc
+ realloc
+ unescape_url util.c
+ which_host_conf
+ get_local_addr
+ getsockname
+ get_remote_host util.c
+ getpeername
+ strdup
+ gethostbyaddr
+ gethostbyname
+ inet_ntoa
+ process_request http_request.c
+ translate_name http_alias.c
+ getparents util.c
+ make_full_path util.c
+ log_reason
+ malloc
+ log_error util.c
+ free
+ send_node http_send.c
+ stat
+ extract_path_info http_send.c
+ count_dirs util.c
+ make_dirstr util.c
+ stat
+ evaluate_access http_access.c
+ no2slash util.c
+ reset_mime_vars http_mime.c
+ is_matchexp util.c
+ strcmp_match util.c
+ check_dir_access http_access.c
+ find_allow http_access.c
+ in_ip http_access.c
+ get_remote_host_min util.c
+ getpeername
+ gethostbyaddr
+ in_domain http_access.c
+ find_deny http_access.c
+ in_ip http_access.c
+ get_remote_host_min util.c
+ in_domain http_access.c
+ parse_htaccess http_config.c
+ stat
+ FOpen fdwrap.c
+ parse_access_dir http_config.c
+ cfg_getline util.c
+ access_syntax_error http_config.c
+ cfg_getword util.c
+ add_type http_mime.c
+ malloc
+ strdup
+ add_encoding http_mime.c
+ malloc
+ strdup
+ add_desc http_dir.c
+ new_item http_dir.c
+ malloc
+ strdup
+ add_ignore http_dir.c
+ new_item http_dir.c
+ add_icon http_dir.c
+ add_alt http_dir.c
+ new_item http_dir.c
+ new_item http_dir.c
+ add_readme http_dir.c
+ new_item http_dir.c
+ add_header http_dir.c
+ new_item http_dir.c
+ add_opts http_dir.c
+ cfg_getword util.c
+ add_opts_int http_dir.c
+ new_item http_dir.c
+ strdup
+ FClose fdwrap.c
+ readlink
+ check_auth http_auth.c
+ auth_bong
+ uudecode
+ getword
+ get_pw
+ crypt
+ Digest_Check
+ k4_server_auth
+ k5_server_auth
+ check_krb_restrict
+ init_group http_auth.c
+ FOpen fdwrap.c
+ malloc
+ fread
+ FClose fdwrap.c
+ DBM_Open fdwrap.c
+ in_group http_auth.c
+ DBM_Close fdwrap.c
+ send_dir http_send.c
+ construct_url
+ escape_url
+ index_directory http_dir.c
+ Opendir
+ send_http_header
+ CloseDir
+ find_opts
+ find_header
+ insert_readme
+ make_dir_entry
+ malloc
+ qsort
+ output_directories
+ free
+ find_readme
+ insert_readme
+ log_transaction
+ probe_content_type http_mime.c
+ find_ct http_mime.c
+ send_cgi cgi.c
+ add_common_vars cgi.c
+ make_env_str env.c
+ cgi_stub cgi.c
+ can_exec util.c
+ Pipe fdwrap.c
+ fork
+ add_cgi_vars
+ error_log2stderr
+ execle/execve
+ getline util.c
+ write
+ read
+ scan_script_header cgi.c
+ getline util.c
+ strdup
+ realloc
+ waitpid
+ send_http_header http_mime.c
+ set_stat_line http_mime.c
+ free
+ strdup
+ begin_http_header http_log.c
+ dump_default_header http_mime.c
+ send_script cgi.c
+ alarm
+ getline
+ write
+ read
+ kill_children cgi.c
+ sleep
+ kill
+ waitpid
+ log_transaction
+ send_file http_send.c
+ set_content_type http_mime.c
+ find_ct http_mime.c
+ send_parsed_file http_include.c
+ FOpen fdwrap.c
+ set_content_length http_mime.c
+ set_last_modified http_mime.c
+ gmtime
+ strftime
+ later_than util.c
+ send_http_header http_mime.c
+ send_fd http_send.c
+ signal
+ fread
+ write
+ log_transaction http_log.c
+ FClose fdwrap.c
+ probe_content_type http_mime.c
+ send_cgi cgi.c
+ send_imagemap imagemap.c
+ FOpen fdwrap.c
+ pointinpoly imagemap.c
+ sendmsg imagemap.c
+ pointincircle imagemap.c
+ pointinrect imagemap.c
+ FClose fdwrap.c
+ send_file http_send.c
+ exec_cgi_script cgi.c
+ get_path_info
+ evaluate_access
+ add_common_vars
+ cgi_stub
+ CompleteRequest httpd.c
+ CloseAll fd_wrap.c
+ free_request http_request.c
diff --git a/src/Makefile b/src/Makefile
index 3dfc6aa..381b9b9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,12 +1,13 @@
# NCSA HTTPd 1.5
#
# For normal machines with ANSI compilers
-# CC= cc
+#CC= cc
# For Suns or other non-ANSI platforms.
CC= gcc
-QUANTIFY=/hdf2/pure/quantify-2.0-sunos4/quantify
-PURIFY=purify
-
+#CC = xlc
+QUANTIFY=/hdf2/pure/quantify-2.0.1-sunos4/quantify
+PURIFY=/hdf2/pure/purify-3.2-sunos4/purify
+#PURIFY=/X11/sgi5/purify3.1/purify
# CFLAGS, compile flags.
#
@@ -14,12 +15,17 @@ PURIFY=purify
# All other defines are in config.h
# If you want to ensure that CGI scripts can't mess with the log files,
# use -DSECURE_LOGS
-#
-CFLAGS= -g
+CFLAGS= -g
#CFLAGS= -pg -DPROFILE
-#CFLAGS= -g -Wall -ansi -pedantic
+#CFLAGS= -g -ansi -pedantic -Wall -DAIX_BROKEN_HEADERS
+# FCGI Support
+#
+# To enable Openmarkets FCGI, uncomment the following
+# Currently uses the TCL library for strings, which requires the math library
+
+#FCGI_CFLAGS = -DFCGI_SUPPORT -I/local/include
# DIGEST AUTHENTICATION
#
@@ -46,8 +52,8 @@ KRB5_CFLAGS = -DKRB5 -I$(KRB5_DIR)/include -I$(KRB5_DIR)/include/krb5
# Comment out the following two lines to exclude Kerberos support
-# KRB_CFLAGS = $(KRB4_CFLAGS) $(KRB5_CFLAGS) # -DKRB-ENCRYPT
-# KRB_LIBS = $(KRB4_LIBS) $(KRB5_LIBS)
+#KRB_CFLAGS = $(KRB4_CFLAGS) $(KRB5_CFLAGS) # -DKRB-ENCRYPT
+#KRB_LIBS = $(KRB4_LIBS) $(KRB5_LIBS)
# DBM
@@ -81,7 +87,7 @@ LFLAGS= # -pg -DPROFILE
# EXTRA_LIBS= -lresolv
# For Solaris 2.x
# AUX_CFLAGS= -DSOLARIS2
-# EXTRA_LIBS= -lsocket -lnsl
+# EXTRA_LIBS= -lsocket -lnsl
# For SGI IRIX. Use the EXTRA_LIBS line if you're using NIS and want
# user-supported directories
# AUX_CFLAGS= -DIRIX
@@ -89,7 +95,7 @@ LFLAGS= # -pg -DPROFILE
# For HP-UX
# AUX_CFLAGS= -DHPUX
# For AIX3
- AUX_CFLAGS= -DAIX3
+# AUX_CFLAGS= -DAIX3 -D_ALL_SOURCE # For xlc compiler
# For AIX4
# AUX_CFLAGS= -DAIX4
# For Ultrix
@@ -101,7 +107,8 @@ LFLAGS= # -pg -DPROFILE
# For Sequent
# AUX_CFLAGS= -DSEQUENT
# For Linux -m486 ONLY IF YOU HAVE 486 BINARY SUPPORT IN KERNEL
-# AUX_CFLAGS= -DLINUX
+# AUX_CFLAGS= -DLINUX # -DFD_LINUX for Linux 1.2.13
+# DBM_LIBS = -lgdbm
# For NetBSD 1.0
# May not need -lcrypt if its included in your libc
# AUX_CFLAGS= -DNetBSD
@@ -120,6 +127,9 @@ LFLAGS= # -pg -DPROFILE
# For SCO SVR3.2
# AUX_CFLAGS= -DSCO3
# EXTRA_LIBS= -lPW -lsocket -lmalloc -lintl -lcrypt
+# For SCO OpenServer 5
+# AUX_CFLAGS= -DSCO5
+# EXTRA_LIBS= -lPW -lsocket -lmalloc -lintl -lcrypt
# For SVR4
# AUX_CFLAGS= -DSVR4
# EXTRA_LIBS= -lsocket -lnsl -lc
@@ -142,18 +152,21 @@ LFLAGS= # -pg -DPROFILE
# -------------- You shouldn't have to edit anything else -----------------
# -------------------------------------------------------------------------
-SEC_CFLAGS = $(MD5_CFLAGS) $(PGP_CFLAGS) $(KRB_CFLAGS)
-SEC_LIBS = $(KRB_LIBS)
+SEC_CFLAGS = $(MD5_CFLAGS) $(KRB_CFLAGS)
+SEC_LIBS = $(KRB_LIBS)
+
+ALL_CFLAGS = $(CFLAGS) $(AUX_CFLAGS) $(SEC_CFLAGS) $(DBM_CFLAGS) $(FCGI_CFLAGS)
+ALL_LIBS = $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
OBJS=httpd.o http_config.o http_request.o util.o http_dir.o \
http_alias.o http_log.o http_mime.o http_access.o http_auth.o \
http_send.o cgi.o http_include.o rfc931.o imagemap.o \
http_ipc.o digest.o md5.o md5c.o env.o host_config.o fdwrap.o \
-open_logfile.o
+open_logfile.o allocate.o debug.o blackout.o fcgi.o
.c.o: Makefile config.h portability.h constants.h
- $(CC) -c $(CFLAGS) $(AUX_CFLAGS) $(SEC_CFLAGS) $(DBM_CFLAGS) $<
+ $(CC) -c $(ALL_CFLAGS) $<
all: httpd
@@ -176,6 +189,10 @@ hp-cc:
linux:
make tar AUX_CFLAGS=-DLINUX CC=gcc CFLAGS=-O2 DBM_LIBS=-lgdbm
+linux2: linux
+linux1:
+ make tar AUX_CFLAGS="-DLINUX -DFD_LINUX" CC=gcc CFLAGS=-O2 DBM_LIBS=-lgdbm
+
netbsd:
make tar AUX_CFLAGS=-DNETBSD EXTRA_LIBS=-lcrypt CC=cc CFLAGS=-O2
@@ -185,6 +202,9 @@ next:
osf1:
make tar AUX_CFLAGS=-DOSF1 CC=cc CFLAGS="-O2 -Olimit 750"
+sco5:
+ make tar AUX_CFLAGS=-DSCO5 CC=icc CFLAGS="" EXTRA_LIBS="-lPW -lsocket -lmalloc -lintl -lcrypt" DBM_LIBS=-ldbm
+
sgi:
make tar AUX_CFLAGS=-DIRIX EXTRA_LIBS=-lsun CC=cc CFLAGS=-O2
@@ -203,21 +223,22 @@ ultrix:
make tar AUX_CFLAGS=-DULTRIX CC=gcc CFLAGS=-O2
httpd: $(OBJS)
- $(CC) $(LFLAGS) -o httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
+ $(CC) $(LFLAGS) -o httpd $(OBJS) $(ALL_LIBS)
+# -logfile=/X11/blong/httpd/logs/pure_log
purify: $(OBJS)
- $(PURIFY) -logfile=/X11/blong/httpd/logs/pure_log \
- -program-name=/X11/blong/httpd/src/httpd \
+ $(PURIFY) -program-name=/X11/blong/httpd/src/httpd \
-follow-child-processes=yes \
- $(CC) $(LFLAGS) -o httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
+ $(CC) $(LFLAGS) -o httpd $(OBJS) $(ALL_LIBS)
quantify: $(OBJS)
$(QUANTIFY) -record-child-process-data=yes \
- -avoid-recording-system-calls=93,113,114 \
- $(CC) $(LFLAGS) -o httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
+ -record-data=no \
+ -avoid-recording-system-calls=1,6,93,113,114 \
+ $(CC) $(LFLAGS) -o httpd $(OBJS) $(ALL_LIBS)
tar: $(OBJS)
- $(CC) $(LFLAGS) -o ../httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
+ $(CC) $(LFLAGS) -o ../httpd $(OBJS) $(ALL_LIBS)
http_access.o: Makefile config.h portability.h constants.h http_access.h \
@@ -248,13 +269,15 @@ http_log.o: config.h portability.h constants.h http_log.h \
http_mime.o: Makefile config.h portability.h constants.h http_mime.h \
http_log.h util.h http_config.h http_access.h env.h
http_request.o: Makefile config.h portability.h constants.h http_request.h \
- util.h http_mime.h http_config.h http_log.h http_auth.h \
- httpd.h http_send.h cgi.h http_access.h host_config.h \
- http_alias.h env.h
-imagemap.o: Makefile constants.h imagemap.h
+ allocate.h cgi.h env.h http_access.h http_alias.h \
+ host_config.h http_config.h http_log.h http_send.h util.h
+imagemap.o: Makefile constants.h imagemap.h allocate.h
cgi.o: Makefile config.h portability.h constants.h cgi.h \
http_log.h http_request.h util.h http_mime.h http_access.h \
http_auth.h http_alias.h http_config.h
+fcgi.o: Makefile config.h portability.h constants.h fcgi.h \
+ fdwrap.h cgi.h env.h http_request.h http_log.h http_access.h \
+ http_mime.h http_config.h http_auth.h http_alias.h util.h
httpd.o: Makefile config.h portability.h constants.h httpd.h \
http_request.h http_config.h http_log.h http_auth.h \
http_dir.h http_access.h util.h http_ipc.h host_config.h \
@@ -265,6 +288,8 @@ env.o: config.h portability.h constants.h http_log.h env.h
rfc931.o: config.h portability.h
open_logfile.o: config.h portability.h constants.h open_logfile.h \
http_config.h util.h
+allocate.o: config.h portability.h constants.h host_config.h http_log.h \
+ allocate.h
# file descriptor scoreboarding
fdwrap.o: config.h portability.h constants.h fdwrap.h
@@ -282,5 +307,5 @@ SRC = $(OBJS:%.o=%.c)
codecenter:
#setopt ansi
#setopt print_string 128
- #setopt load_flags $(CFLAGS) $(AUX_CFLAGS) $(SEC_CFLAGS) $(DBM_CFLAGS)
- #load $(LFLAGS) $(SRC) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
+ #setopt load_flags $(ALL_FLAGS)
+ #load $(LFLAGS) $(SRC) $(ALL_LIBS)
diff --git a/src/allocate.c b/src/allocate.c
new file mode 100644
index 0000000..0c66607
--- /dev/null
+++ b/src/allocate.c
@@ -0,0 +1,267 @@
+/************************************************************************
+ * NCSA HTTPd Server
+ * Software Development Group
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * 605 E. Springfield, Champaign, IL 61820
+ * httpd@ncsa.uiuc.edu
+ *
+ * Copyright (C) 1995, Board of Trustees of the University of Illinois
+ *
+ ************************************************************************
+ *
+ * allocate.c,v 1.5 1996/04/05 18:54:28 blong Exp
+ *
+ ************************************************************************
+ *
+ * allocate.c: Functions to allocate data types as needed
+ *
+ */
+
+#include "config.h"
+#include "portability.h"
+
+#include Mapping Server Error
");
printf("This server encountered an error:
My World Wide Web Pages are black for 48 hours to protest second-class treatment from the US Government for free speech. Read about it at this WWW page.");
+ alarm(0);
+ signal(SIGALRM,SIG_IGN);
+ signal(SIGPIPE,SIG_IGN);
+ freeString(buf);
+ return total_bytes_sent;
+}
+
+#endif /* BLACKOUT_CODE */
diff --git a/src/blackout.h b/src/blackout.h
new file mode 100644
index 0000000..32cb23c
--- /dev/null
+++ b/src/blackout.h
@@ -0,0 +1,26 @@
+/************************************************************************
+ * NCSA HTTPd Server
+ * Software Development Group
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * 605 E. Springfield, Champaign, IL 61820
+ * httpd@ncsa.uiuc.edu
+ *
+ * Copyright (C) 1995, Board of Trustees of the University of Illinois
+ *
+ ************************************************************************
+ *
+ * blackout.h,v 1.1 1996/02/08 18:01:02 blong Exp
+ *
+ ************************************************************************
+ *
+ */
+
+#ifndef _BLACKOUT_H
+#define _BLACKOUT_H
+
+/* function prototypes */
+long send_fp_black(per_request *reqInfo, FILE *f, void (*onexit)(void));
+
+#endif /* _BLACKOUT_H */
+
diff --git a/src/cgi.c b/src/cgi.c
index 86b8a32..631bf03 100644
--- a/src/cgi.c
+++ b/src/cgi.c
@@ -10,33 +10,14 @@
*
************************************************************************
*
- * cgi.c,v 1.34 1995/11/28 09:01:37 blong Exp
+ * cgi.c,v 1.44 1996/04/05 18:54:31 blong Exp
*
************************************************************************
*
* cgi: keeps all script-related ramblings together.
- *
- * Based on NCSA HTTPd 1.3 by Rob McCool
*
- * 03-07-95 blong
- * Added support for variable REMOTE_GROUP from access files
- *
- * 03-20-95 sguillory
- * Moved to more dynamic memory management of environment arrays
- *
- * 04-03-95 blong
- * Added support for variables DOCUMENT_ROOT, ERROR_REQINFO->STATUS
- * ERROR_URL, ERROR_REQUEST
- *
- * 04-20-95 blong
- * Added Apache patch "B18" from Rob Hartill to allow nondelayed redirects
- *
- * 05-02-95 blong
- * Since Apache is using REDIRECT_ as the env variables, I've decided to
- * go with this in the interest of general Internet Harmony and Peace.
*/
-
#include "config.h"
#include "portability.h"
@@ -56,21 +37,34 @@
#include
%c",LF); + if(rule) rprintf(reqInfo,"%c",LF); return 1; } @@ -361,15 +365,18 @@ char *find_title(per_request *reqInfo, char *filename) { char filebak[MAX_STRING_LEN]; FILE *thefile; int x,y,n,p; + char *file_type, *file_encoding; + + file_type = newString(MAX_STRING_LEN,STR_TMP); + file_encoding = newString(MAX_STRING_LEN,STR_TMP); - content_encoding[0] = '\0'; strcpy(filebak,filename); - set_content_type(reqInfo,filebak); - if(((!strcmp(content_type,"text/html")) || - (strcmp(content_type, INCLUDES_MAGIC_TYPE) == 0)) - && (!content_encoding[0])) { + get_content_type(reqInfo,filebak,file_type,file_encoding); + if(((!strcmp(file_type,"text/html")) || + (strcmp(file_type, INCLUDES_MAGIC_TYPE) == 0)) + && (!file_encoding[0])) { if(!(thefile = FOpen(filename,"r"))) - return NULL; + goto not_found; n = fread(titlebuf,sizeof(char),MAX_STRING_LEN - 1,thefile); titlebuf[n] = '\0'; for(x=0,p=0;titlebuf[x];x++) { @@ -382,14 +389,17 @@ char *find_title(per_request *reqInfo, char *filename) { if((titlebuf[y] == CR) || (titlebuf[y] == LF)) titlebuf[y] = ' '; FClose(thefile); + freeString(file_type); + freeString(file_encoding); return strdup(&titlebuf[x]); } } else p=0; } FClose(thefile); - return NULL; } - content_encoding[0] = '\0'; + not_found: + freeString(file_type); + freeString(file_encoding); return NULL; } @@ -454,9 +464,10 @@ struct ent *make_dir_entry(per_request *reqInfo, char *path, p->alt = NULL; p->desc = NULL; if(S_ISDIR(finfo.st_mode)) { - if(!(p->icon = find_icon(reqInfo,t,1))) + if(!(p->icon = find_icon(reqInfo,t,1))) { if (p->icon != NULL) free(p->icon); p->icon = find_icon(reqInfo,"^^DIRECTORY^^",1); + } if(!(tmp = find_alt(reqInfo,t,1))){ p->alt = (char *) malloc(sizeof(char)*4); strcpy(p->alt,"DIR"); @@ -495,22 +506,19 @@ struct ent *make_dir_entry(per_request *reqInfo, char *path, void send_size(per_request *reqInfo, size_t size) { if(size == -1) { - fputs(" -",reqInfo->out); - reqInfo->bytes_sent += 5; + rputs(" -",reqInfo); } else { if(!size) { - fputs(" 0K",reqInfo->out); - reqInfo->bytes_sent += 5; + rputs(" 0K",reqInfo); } else if(size < 1024) { - fputs(" 1K",reqInfo->out); - reqInfo->bytes_sent += 5; + rputs(" 1K",reqInfo); } else if(size < 1048576) - reqInfo->bytes_sent += fprintf(reqInfo->out,"%4dK",size / 1024); + rprintf(reqInfo,"%4dK",size / 1024); else - reqInfo->bytes_sent += fprintf(reqInfo->out,"%4dM",size / 1048576); + rprintf(reqInfo,"%4dM",size / 1048576); } } @@ -550,30 +558,28 @@ void output_directories(per_request *reqInfo, struct ent **ar,int n,char *name) name[0] = '/'; name[1] = '\0'; } /* aaaaargh Solaris sucks. */ - fflush(reqInfo->out); + rflush(reqInfo); if(dir_opts & FANCY_INDEXING) { - fputs("
%c",LF); + rprintf(reqInfo,"%c",LF); } - else if(rule) reqInfo->bytes_sent += fprintf(reqInfo->out,"%c",LF); + if(plaintext) rprintf(reqInfo,"
%c",LF); + else if(rule) rprintf(reqInfo,"
%c",LF); if(!(r = FOpen(fn,"r"))) return 0; send_fp(reqInfo,r,NULL); FClose(r); - if(plaintext) - reqInfo->bytes_sent += fprintf(reqInfo->out,"
",reqInfo->out); - (reqInfo->bytes_sent) += 5; + rputs("",reqInfo); if((tp = find_icon(reqInfo,"^^BLANKICON^^",1))) - reqInfo->bytes_sent += (fprintf(reqInfo->out, - "",tp)); - reqInfo->bytes_sent += fprintf(reqInfo->out,"Name "); + rprintf(reqInfo,"
",tp); + rprintf(reqInfo,"Name "); if(!(dir_opts & SUPPRESS_LAST_MOD)) - reqInfo->bytes_sent += fprintf(reqInfo->out,"Last modified "); + rprintf(reqInfo,"Last modified "); if(!(dir_opts & SUPPRESS_SIZE)) - reqInfo->bytes_sent += fprintf(reqInfo->out,"Size "); + rprintf(reqInfo,"Size "); if(!(dir_opts & SUPPRESS_DESC)) - reqInfo->bytes_sent += fprintf(reqInfo->out,"Description"); - reqInfo->bytes_sent += fprintf(reqInfo->out,"%c
%c",LF,LF); + rprintf(reqInfo,"Description"); + rprintf(reqInfo,"%c
%c",LF,LF); } else { - fputs("
out);
- ++(reqInfo->bytes_sent);
+ rputc(str[x],reqInfo);
}
}
- putc(c,reqInfo->out);
- ++(reqInfo->bytes_sent);
+ rputc(c,reqInfo);
}
p=0;
}
@@ -211,9 +210,6 @@ int get_directive(FILE *fp, char *d) {
/* --------------------------- Action handlers ---------------------------- */
-void send_parsed_content(per_request *reqInfo, FILE *f, char *path_args,
- int noexec);
-
int send_included_file(per_request *reqInfo, char *fn)
{
FILE *fp;
@@ -227,13 +223,14 @@ int send_included_file(per_request *reqInfo, char *fn)
if(!allow)
return -1;
set_content_type(reqInfo,reqInfo->filename);
- if((op & OPT_INCLUDES) && (!strcmp(content_type,INCLUDES_MAGIC_TYPE))) {
+ if((op & OPT_INCLUDES) &&
+ (!strcmp(reqInfo->outh_content_type,INCLUDES_MAGIC_TYPE))) {
if(!(fp = FOpen(reqInfo->filename,"r")))
return -1;
- send_parsed_content(reqInfo,fp,"",op & OPT_INCNOEXEC);
+ send_parsed_content(reqInfo,fp,op & OPT_INCNOEXEC);
chdir_file(fn); /* grumble */
}
- else if(!strcmp(content_type,CGI_MAGIC_TYPE))
+ else if(!strcmp(reqInfo->outh_content_type,CGI_MAGIC_TYPE))
return -1;
else {
if(!(fp=FOpen(reqInfo->filename,"r")))
@@ -245,20 +242,30 @@ int send_included_file(per_request *reqInfo, char *fn)
}
int handle_include(per_request *reqInfo, FILE *fp, char *error) {
- char tag[MAX_STRING_LEN],errstr[MAX_STRING_LEN];
+ char *tag,*errstr;
char *tag_val;
+ tag = newString(MAX_STRING_LEN,STR_TMP);
+ errstr = newString(MAX_STRING_LEN,STR_TMP);
+
while(1) {
- if(!(tag_val = get_tag(fp,tag)))
+ if(!(tag_val = get_tag(fp,tag))) {
+ freeString(tag);
+ freeString(errstr);
return 1;
+ }
if(!strcmp(tag,"file")) {
- char dir[MAX_STRING_LEN],to_send[MAX_STRING_LEN];
+ char *dir,*to_send;
per_request *newInfo;
+ dir = newString(MAX_STRING_LEN,STR_TMP);
+ to_send = newString(MAX_STRING_LEN,STR_TMP);
+
getparents(tag_val); /* get rid of any nasties */
- getwd(dir);
+ getcwd(dir,MAX_STRING_LEN);
make_full_path(dir,tag_val,to_send);
- newInfo = continue_request(reqInfo,NEW_URL | KEEP_ENV);
+ newInfo = continue_request(reqInfo, KEEP_ENV | KEEP_AUTH);
+ newInfo->http_version = P_HTTP_0_9;
strcpy(newInfo->url,tag_val);
strcpy(newInfo->args,reqInfo->args);
strcpy(newInfo->filename,to_send);
@@ -266,18 +273,21 @@ int handle_include(per_request *reqInfo, FILE *fp, char *error) {
sprintf(errstr,"unable to include %s in parsed file %s",
newInfo->filename,reqInfo->filename );
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
}
reqInfo->bytes_sent += newInfo->bytes_sent;
free_request(newInfo,ONLY_LAST);
+ freeString(dir);
+ freeString(to_send);
}
else if(!strcmp(tag,"virtual")) {
per_request *newInfo;
- newInfo = continue_request(reqInfo, NEW_URL | KEEP_ENV);
+ newInfo = continue_request(reqInfo, KEEP_ENV | KEEP_AUTH);
+ newInfo->http_version = P_HTTP_0_9;
strcpy(newInfo->url,tag_val);
if(translate_name(newInfo,newInfo->url,newInfo->filename)
!= A_STD_DOCUMENT) {
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
sprintf(errstr,"unable to include %s in parsed file %s, non standard document",newInfo->filename, reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
} else {
@@ -285,19 +295,22 @@ int handle_include(per_request *reqInfo, FILE *fp, char *error) {
sprintf(errstr,"unable to include %s in parsed file %s",
newInfo->filename, reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
}
reqInfo->bytes_sent += newInfo->bytes_sent;
}
free_request(newInfo,ONLY_LAST);
}
- else if(!strcmp(tag,"done"))
+ else if(!strcmp(tag,"done")) {
+ freeString(tag);
+ freeString(errstr);
return 0;
+ }
else {
sprintf(errstr,"unknown parameter %s to tag echo in %s",tag,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
}
}
}
@@ -305,23 +318,22 @@ int handle_include(per_request *reqInfo, FILE *fp, char *error) {
#ifndef NO_YOW
#include "httpy.h"
-int print_yow(per_request *reqInfo, int yow_num) {
+void print_yow(per_request *reqInfo, int yow_num) {
int i = 0;
int href_on = FALSE;
int tmp;
if (yow_num >= MAX_YOW) yow_num = MAX_YOW-1;
while (yow_lines[yow_num][i]) {
- putc(yow_lines[yow_num][i],reqInfo->out);
+ rputc(yow_lines[yow_num][i],reqInfo);
if (yow_lines[yow_num][i] == ' ') {
tmp = href_on;
href_on = (rand() % 100 < 50) ? 1 : 0;
if (tmp != href_on) {
if (!tmp)
- reqInfo->bytes_sent += fprintf(reqInfo->out,"",
- reqInfo->url);
+ rprintf(reqInfo,"", reqInfo->url);
else
- reqInfo->bytes_sent += fprintf(reqInfo->out,"");
+ rprintf(reqInfo,"");
}
i++;
while ((yow_lines[yow_num][i] == ' ') && yow_lines[yow_num][i++]);
@@ -332,19 +344,23 @@ int print_yow(per_request *reqInfo, int yow_num) {
i++;
}
if (href_on) {
- reqInfo->bytes_sent += fprintf(reqInfo->out,"");
+ rprintf(reqInfo,"");
}
}
#endif /* NO_YOW */
int handle_echo(per_request *reqInfo, FILE *fp, char *error) {
- char tag[MAX_STRING_LEN];
+ char *tag;
char *tag_val;
+ tag = newString(MAX_STRING_LEN,STR_TMP);
+
while(1) {
- if(!(tag_val = get_tag(fp,tag)))
+ if(!(tag_val = get_tag(fp,tag))) {
+ freeString(tag);
return 1;
+ }
if(!strcmp(tag,"var")) {
int x,i,len;
@@ -352,13 +368,12 @@ int handle_echo(per_request *reqInfo, FILE *fp, char *error) {
for(x=0;reqInfo->env[x] != NULL; x++) {
i = ind(reqInfo->env[x],'=');
if((i == len) && !(strncmp(reqInfo->env[x],tag_val,i))) {
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",
- &(reqInfo->env[x][i+1]));
+ rprintf(reqInfo,"%s",&(reqInfo->env[x][i+1]));
break;
}
}
if(!(reqInfo->env[x]))
- reqInfo->bytes_sent += fprintf(reqInfo->out,"(none)");
+ rprintf(reqInfo,"(none)");
}
#ifndef NO_YOW
else if(!strcmp(tag,"yow")) {
@@ -366,19 +381,26 @@ int handle_echo(per_request *reqInfo, FILE *fp, char *error) {
print_yow(reqInfo,num);
}
#endif /* NO_YOW */
- else if(!strcmp(tag,"done"))
+ else if(!strcmp(tag,"done")) {
+ freeString(tag);
return 0;
+ }
else {
- char errstr[MAX_STRING_LEN];
+ char *errstr;
+
+ errstr = newString(MAX_STRING_LEN,STR_TMP);
+
sprintf(errstr,"unknown parameter %s to tag echo in %s",tag,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
+
+ freeString(errstr);
}
}
}
-int include_cgi(per_request *reqInfo, char *pargs) {
+int include_cgi(per_request *reqInfo) {
char op;
int allow,check_cgiopt;
struct stat finfo;
@@ -390,10 +412,12 @@ int include_cgi(per_request *reqInfo, char *pargs) {
return -1;
check_cgiopt=0;
} else {
- char dir[MAX_STRING_LEN];
- getwd(dir);
+ char *dir;
+ dir = newString(MAX_STRING_LEN, STR_TMP);
+ getcwd(dir,MAX_STRING_LEN);
make_full_path(dir,reqInfo->url,reqInfo->filename);
check_cgiopt=1;
+ freeString(dir);
}
/* No hardwired path info or query allowed */
if(stat(reqInfo->filename,&finfo) == -1)
@@ -404,43 +428,51 @@ int include_cgi(per_request *reqInfo, char *pargs) {
if((!allow) || (check_cgiopt && (!(op & OPT_EXECCGI))))
return -1;
- if(cgi_stub(reqInfo,pargs,&finfo) == SC_REDIRECT_TEMP)
- reqInfo->bytes_sent += fprintf(reqInfo->out,
- "%s",location,location);
+ if(cgi_stub(reqInfo,&finfo,op) == SC_REDIRECT_TEMP)
+ rprintf(reqInfo, "%s",reqInfo->outh_location,
+ reqInfo->outh_location);
return 0;
}
static int ipid;
void kill_include_child(void) {
- char errstr[MAX_STRING_LEN];
+ char *errstr;
+
+ errstr = newString(MAX_STRING_LEN,STR_TMP);
+
sprintf(errstr,"killing command process %d",ipid);
log_error(errstr,gCurrentRequest->hostInfo->error_log);
kill(ipid,SIGKILL);
waitpid(ipid,NULL,0);
+
+ freeString(errstr);
}
-int include_cmd(per_request *reqInfo, char *s, char *pargs) {
+int include_cmd(per_request *reqInfo, char *s) {
int p[2];
- FILE *fp;
if(Pipe(p) == -1)
- die(reqInfo,SC_SERVER_ERROR,"httpd: could not create IPC pipe");
+ die(reqInfo,SC_SERVER_ERROR,"HTTPd: could not create IPC pipe");
if((ipid = fork()) == -1) {
Close(p[0]);
Close(p[1]);
- die(reqInfo,SC_SERVER_ERROR,"httpd: could not fork new process");
+ die(reqInfo,SC_SERVER_ERROR,"HTTPd: could not fork new process");
}
if(!ipid) {
char *argv0;
- if(pargs[0] || reqInfo->args[0]) {
- if(pargs[0]) {
- char p2[HUGE_STRING_LEN];
+ if(reqInfo->path_info[0] || reqInfo->args[0]) {
+ if(reqInfo->path_info[0]) {
+ char *p2;
- escape_shell_cmd(pargs);
- make_env_str(reqInfo,"PATH_INFO",pargs);
- translate_name(reqInfo,pargs,p2);
+ p2 = newString(HUGE_STRING_LEN,STR_TMP);
+
+ escape_shell_cmd(reqInfo->path_info);
+ make_env_str(reqInfo,"PATH_INFO",reqInfo->path_info);
+ translate_name(reqInfo,reqInfo->path_info,p2);
make_env_str(reqInfo,"PATH_TRANSLATED",p2);
+
+ freeString(p2);
}
if(reqInfo->args[0]) {
make_env_str(reqInfo,"QUERY_STRING",reqInfo->args);
@@ -455,72 +487,76 @@ int include_cmd(per_request *reqInfo, char *s, char *pargs) {
dup2(p[1],STDOUT_FILENO);
Close(p[1]);
}
+ close(reqInfo->in);
close(reqInfo->connection_socket);
error_log2stderr(reqInfo->hostInfo->error_log);
if(!(argv0 = strrchr(SHELL_PATH,'/')))
argv0=SHELL_PATH;
if(execle(SHELL_PATH,argv0,"-c",s,(char *)0,reqInfo->env) == -1) {
- fprintf(stderr,"httpd: exec of %s failed, errno is %d\n",
+ fprintf(stderr,"HTTPd: exec of %s failed, errno is %d\n",
SHELL_PATH,errno);
exit(1);
}
}
Close(p[1]);
-/* if(!(fp=FdOpen(p[0],"r"))) {
- waitpid(ipid,NULL,0);
- return -1;
- } */
send_fd(reqInfo,p[0],kill_include_child);
-/* FClose(fp); */
Close(p[0]);
waitpid(ipid,NULL,0);
return 0;
}
-int handle_exec(per_request *reqInfo, FILE *fp, char *path_args,
- char *error)
+int handle_exec(per_request *reqInfo, FILE *fp, char *error)
{
- char tag[MAX_STRING_LEN],errstr[MAX_STRING_LEN];
+ char *tag,*errstr;
char *tag_val;
+ tag = newString(MAX_STRING_LEN,STR_TMP);
+ errstr = newString(MAX_STRING_LEN,STR_TMP);
+
while(1) {
- if(!(tag_val = get_tag(fp,tag)))
+ if(!(tag_val = get_tag(fp,tag))) {
+ freeString(tag);
+ freeString(errstr);
return 1;
+ }
if(!strcmp(tag,"cmd")) {
- if(include_cmd(reqInfo,tag_val,path_args) == -1) {
+ if(include_cmd(reqInfo,tag_val) == -1) {
sprintf(errstr,"invalid command exec %s in %s",tag_val,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
}
/* just in case some stooge changed directories */
chdir_file(reqInfo->filename);
}
else if(!strcmp(tag,"cgi")) {
per_request *newInfo;
- newInfo = continue_request(reqInfo,NEW_URL | KEEP_ENV);
+ newInfo = continue_request(reqInfo, KEEP_ENV | KEEP_AUTH);
+ newInfo->http_version = P_HTTP_0_9;
strcpy(newInfo->url,tag_val);
- if(include_cgi(newInfo,path_args) == -1) {
+ if(include_cgi(newInfo) == -1) {
sprintf(errstr,"invalid CGI ref %s in %s",newInfo->filename,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
}
reqInfo->bytes_sent += newInfo->bytes_sent;
free_request(newInfo,ONLY_LAST);
/* grumble groan */
chdir_file(reqInfo->filename);
}
- else if(!strcmp(tag,"done"))
+ else if(!strcmp(tag,"done")) {
+ freeString(errstr);
+ freeString(tag);
return 0;
+ }
else {
- char errstr[MAX_STRING_LEN];
sprintf(errstr,"unknown parameter %s to tag echo in %s",tag,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
}
}
@@ -528,12 +564,16 @@ int handle_exec(per_request *reqInfo, FILE *fp, char *path_args,
int handle_config(per_request *reqInfo, FILE *fp, char *error,
char *tf, int *sizefmt) {
- char tag[MAX_STRING_LEN];
+ char *tag;
char *tag_val;
+ tag = newString(MAX_STRING_LEN,STR_TMP);
+
while(1) {
- if(!(tag_val = get_tag(fp,tag)))
+ if(!(tag_val = get_tag(fp,tag))) {
+ freeString(tag);
return 1;
+ }
if(!strcmp(tag,"errmsg"))
strcpy(error,tag_val);
else if(!strcmp(tag,"timefmt")) {
@@ -548,24 +588,33 @@ int handle_config(per_request *reqInfo, FILE *fp, char *error,
*sizefmt = SIZEFMT_BYTES;
else if(!strcmp(tag_val,"abbrev"))
*sizefmt = SIZEFMT_KMG;
- }
- else if(!strcmp(tag,"done"))
+ }
+ else if(!strcmp(tag,"done")) {
+ freeString(tag);
return 0;
+ }
else {
- char errstr[MAX_STRING_LEN];
+ char *errstr;
+
+ errstr = newString(MAX_STRING_LEN,STR_TMP);
+
sprintf(errstr,"unknown parameter %s to tag config in %s",
tag, reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
+
+ freeString(errstr);
}
}
}
#ifndef NO_YOW
int handle_yow(per_request *reqInfo, FILE *fp, char *error) {
- char tag[MAX_STRING_LEN];
+ char *tag;
char c;
+ tag = newString(MAX_STRING_LEN,STR_TMP);
+
srand((int) (getpid() + time((long *) 0)));
GET_CHAR(fp,c,1);
if (c == ENDING_SEQUENCE[0]) {
@@ -574,10 +623,20 @@ int handle_yow(per_request *reqInfo, FILE *fp, char *error) {
GET_CHAR(fp,c,1);
if (c == ENDING_SEQUENCE[2]) {
print_yow(reqInfo,rand() % MAX_YOW);
+ freeString(tag);
return 0;
- } else return 1;
- } else return 1;
- } else return 1;
+ } else {
+ freeString(tag);
+ return 1;
+ }
+ } else {
+ freeString(tag);
+ return 1;
+ }
+ } else {
+ freeString(tag);
+ return 1;
+ }
}
#endif /* NO_YOW */
@@ -586,30 +645,41 @@ int handle_yow(per_request *reqInfo, FILE *fp, char *error) {
int find_file(per_request *reqInfo, char *directive, char *tag,
char *tag_val, struct stat *finfo, char *error)
{
- char errstr[MAX_STRING_LEN], dir[MAX_STRING_LEN], to_send[MAX_STRING_LEN];
+ char *errstr, *dir, *to_send;
+
+ errstr = newString(MAX_STRING_LEN,STR_TMP);
+ dir = newString(MAX_STRING_LEN,STR_TMP);
+ to_send = newString(MAX_STRING_LEN,STR_TMP);
if(!strcmp(tag,"file")) {
getparents(tag_val); /* get rid of any nasties */
- getwd(dir);
+ getcwd(dir,MAX_STRING_LEN);
make_full_path(dir,tag_val,to_send);
if(stat(to_send,finfo) == -1) {
sprintf(errstr,
"unable to get information about %s in parsed file %s",
to_send,reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
+ freeString(errstr);
+ freeString(dir);
+ freeString(to_send);
return -1;
}
+ freeString(errstr);
+ freeString(dir);
+ freeString(to_send);
return 0;
}
else if(!strcmp(tag,"virtual")) {
per_request *newInfo;
- newInfo = continue_request(reqInfo,NEW_URL | KEEP_ENV);
+ newInfo = continue_request(reqInfo, KEEP_ENV | KEEP_AUTH);
+ newInfo->http_version = P_HTTP_0_9;
strcpy(newInfo->url,tag_val);
if(translate_name(newInfo,newInfo->url,newInfo->filename)
!= A_STD_DOCUMENT) {
sprintf(errstr,"unable to get information about non standard file %s in parsed file %s",newInfo->filename,reqInfo->filename);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
log_error(errstr,reqInfo->hostInfo->error_log);
}
else if(stat(newInfo->filename,finfo) == -1) {
@@ -617,18 +687,27 @@ int find_file(per_request *reqInfo, char *directive, char *tag,
"unable to get information about %s in parsed file %s",
newInfo->filename,reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
free_request(newInfo,ONLY_LAST);
+ freeString(errstr);
+ freeString(dir);
+ freeString(to_send);
return -1;
}
free_request(newInfo,ONLY_LAST);
+ freeString(errstr);
+ freeString(dir);
+ freeString(to_send);
return 0;
}
else {
sprintf(errstr,"unknown parameter %s to tag %s in %s",
tag,directive,reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
+ rprintf(reqInfo,"%s",error);
+ freeString(errstr);
+ freeString(dir);
+ freeString(to_send);
return -1;
}
}
@@ -636,15 +715,21 @@ int find_file(per_request *reqInfo, char *directive, char *tag,
int handle_fsize(per_request *reqInfo, FILE *fp, char *error, int sizefmt)
{
- char tag[MAX_STRING_LEN];
+ char *tag;
char *tag_val;
struct stat finfo;
+ tag = newString(MAX_STRING_LEN,STR_TMP);
+
while(1) {
- if(!(tag_val = get_tag(fp,tag)))
+ if(!(tag_val = get_tag(fp,tag))) {
+ freeString(tag);
return 1;
- else if(!strcmp(tag,"done"))
+ }
+ else if(!strcmp(tag,"done")) {
+ freeString(tag);
return 0;
+ }
else if(!find_file(reqInfo,"fsize",tag,tag_val,&finfo,error)) {
if(sizefmt == SIZEFMT_KMG) {
send_size(reqInfo,finfo.st_size);
@@ -656,11 +741,9 @@ int handle_fsize(per_request *reqInfo, FILE *fp, char *error, int sizefmt)
l = strlen(tag); /* grrr */
for(x=0;x %c",
err_string,LF);
- fprintf(reqInfo->out,"%c",LF);
+ rprintf(reqInfo,"%c",LF);
}
log_transaction(reqInfo);
}
break;
case SC_REDIRECT_PERM:
reqInfo->status = SC_REDIRECT_PERM;
+ set_stat_line(reqInfo);
if (((x=have_doc_error(reqInfo,type)) >= 0) && (!ErrorStat)) {
ErrorStat = reqInfo->status;
GoErrorDoc(reqInfo,x,err_string);
} else {
keep_alive.bKeepAlive = 0;
- if(!no_headers) {
- begin_http_header(reqInfo,StatLine301);
- fprintf(reqInfo->out,"Location: %s%c",err_string,LF);
- fprintf(reqInfo->out,"Content-type: text/html%c",LF);
- fputc(LF,reqInfo->out);
- }
+ if(reqInfo->http_version != P_HTTP_0_9) {
+ strcpy(reqInfo->outh_location,err_string);
+ strcpy(reqInfo->outh_content_type,"text/html");
+ send_http_header(reqInfo);
+ }
if (reqInfo->method != M_HEAD) {
title_html(reqInfo,"Document moved");
- fprintf(reqInfo->out,"This document has permanently moved ");
- fprintf(reqInfo->out,"here. %c%c",
+ rprintf(reqInfo,"This document has permanently moved ");
+ rprintf(reqInfo,"here. %c%c",
err_string,LF,LF);
}
log_transaction(reqInfo);
@@ -409,73 +393,95 @@ int die(per_request *reqInfo, int type, char *err_string)
break;
case SC_USE_LOCAL_COPY:
reqInfo->status = SC_USE_LOCAL_COPY;
- begin_http_header(reqInfo,StatLine304);
- fputc(LF,reqInfo->out);
+ set_stat_line(reqInfo);
+ if (reqInfo->http_version != P_HTTP_0_9) {
+ send_http_header(reqInfo);
+ }
keep_alive.bKeepAlive = 0;
- header_only = 1;
RetVal = SC_USE_LOCAL_COPY;
log_transaction(reqInfo);
break;
case SC_AUTH_REQUIRED:
reqInfo->status = SC_AUTH_REQUIRED;
+ set_stat_line(reqInfo);
+ strcpy(reqInfo->outh_www_auth, err_string);
if (((x=have_doc_error(reqInfo,type)) >= 0) && (!ErrorStat)) {
ErrorStat = reqInfo->status;
GoErrorDoc(reqInfo,x,err_string);
} else {
keep_alive.bKeepAlive = 0;
- if(!no_headers) {
- begin_http_header(reqInfo,StatLine401);
- fprintf(reqInfo->out,"Content-type: text/html%c",LF);
- fprintf(reqInfo->out,"WWW-Authenticate: %s%c%c",
- err_string,LF,LF);
+ if(reqInfo->http_version != P_HTTP_0_9) {
+ strcpy(reqInfo->outh_content_type,"text/html");
+ send_http_header(reqInfo);
}
if (reqInfo->method != M_HEAD) {
title_html(reqInfo,"Authorization Required");
- fprintf(reqInfo->out,
- "Browser not authentication-capable or %c",LF);
- fprintf(reqInfo->out,"authentication failed.%c",LF);
- fprintf(reqInfo->out,"%c",LF);
+ rprintf(reqInfo,"Browser not authentication-capable or %c",LF);
+ rprintf(reqInfo,"authentication failed.%c",LF);
+ rprintf(reqInfo,"%s
%c",err,LF);
+ rprintf(reqInfo,"%s
%c",err,LF);
}
}
void title_html(per_request *reqInfo, char *msg)
{
- fprintf(reqInfo->out,"%s
%c",msg,LF);
+ rprintf(reqInfo,"%s
%c",msg,LF);
}
int die(per_request *reqInfo, int type, char *err_string)
{
- char arguments[MAX_STRING_LEN];
+ char *arguments;
int RetVal=0;
int x;
int die_type;
+ arguments = newString(MAX_STRING_LEN,STR_TMP);
/* kill keepalive on errors until we figure out what to do
such as compute content_length of error messages */
die_type = DIE_NORMAL;
@@ -346,62 +335,57 @@ int die(per_request *reqInfo, int type, char *err_string)
strcpy(failed_request,the_request);
strcpy(failed_url,reqInfo->url);
- /* For 1.4b4, changed to have a common message for ErrorDocument calls
- We now send only error=err_string (as passed) and the CGI environment
- variable ERROR_STATUS,ERROR_REQUEST,ERROR_URL contain the rest of the
- relevent information */
- /* For 1.4 release, changed ERROR_ to REDIRECT_ */
-
switch(type) {
case SC_NO_CONTENT:
reqInfo->status = SC_NO_CONTENT;
- begin_http_header(reqInfo,StatLine204);
- fputc(LF,reqInfo->out);
+ set_stat_line(reqInfo);
+ if (reqInfo->http_version != P_HTTP_0_9) {
+ send_http_header(reqInfo);
+ }
keep_alive.bKeepAlive = 0;
- header_only = 1;
RetVal = SC_NO_CONTENT;
log_transaction(reqInfo);
break;
case SC_REDIRECT_TEMP:
reqInfo->status = SC_REDIRECT_TEMP;
+ set_stat_line(reqInfo);
if (((x=have_doc_error(reqInfo,type)) >= 0) && (!ErrorStat)) {
ErrorStat = reqInfo->status;
GoErrorDoc(reqInfo,x,err_string);
} else {
keep_alive.bKeepAlive = 0;
- if(!no_headers) {
- begin_http_header(reqInfo,StatLine302);
- fprintf(reqInfo->out,"Location: %s%c",err_string,LF);
- fprintf(reqInfo->out,"Content-type: text/html%c",LF);
- fputc(LF,reqInfo->out);
+ if(reqInfo->http_version != P_HTTP_0_9) {
+ strcpy(reqInfo->outh_location,err_string);
+ strcpy(reqInfo->outh_content_type,"text/html");
+ send_http_header(reqInfo);
}
if (reqInfo->method != M_HEAD) {
title_html(reqInfo,"Document moved");
- fprintf(reqInfo->out,
+ rprintf(reqInfo,
"This document has moved here.