diff --git a/BUGS b/BUGS
index 92cf3db..e8b8f8d 100644
--- a/BUGS
+++ b/BUGS
@@ -1,47 +1,5 @@
-NOTE: Bugs are mentioned in the version they are found in. This doesn't
-mean that they didn't exist prior to that version.
-
-Known Bugs in 1.5.1b3
----------------------
-*) 299: File descriptors aren't set correctly on child_alone()
-*) 301: Sending headers on HTTP/0.9 response
-
-Known Bugs in 1.5.1b2
----------------------
-*) 900: ErrorDocument 401s as html files doesn't work on Mosaic/X, does on
- netscape
-*) 293: Socket isn't closed before CGI execution, causing client to hang
- waiting for close
-
-Known Bugs in 1.5.1b1
----------------------
-*) 264: imagemap fails because of invalid fgets() argument
-*) 265: in_ip() broken causing all access control by ip to fail
-*) 266: 301 and 204 status codes broken in set_stat_line()
-*) 267: no bounds checking in access_control array
-
-
Known Bugs in 1.5a
---------------------
-*) server doesn't clean up directory indexing information added by .htaccess
-*) fgets in src/imagemap.c only uses MAX_STRING_LEN, which may be too short
- for complex polygons
-*) If you don't have an allow or require line in .htaccess LIMIT, it won't
- work (ie, just a deny)
-*) Doesn't log HEAD request to automatically indexed directory
-*) Can't use group and user name which are the same in flat group file
-*) Off by one errors in DBM support
-*) typo in LOCALHACK
-*) Server core dumped if user aborted before reqInfo->remote_name set
-*) Server core dumped if setuid/setgid failed
-*) Bug in http_access.c which makes matchexp directories in access control
- not work correctly
-*) NIS group files only work if using NIS password files as well
-*) Order mutual-failure is broken, does exact opposite
-*) Don't strip Content-Length header from CGI scripts
-*) require group will match user as postfix of another, and fails if a
- prefix occurs first
-
Known Bugs in 1.5
diff --git a/CHANGES b/CHANGES
index 027637e..aaf73b3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,37 +1,3 @@
-Changes for 1.5.1
-------------------
-*) Imagemaps (both internal and external) now add the path of the map file
- for non full path urls in the map file
-*) A couple logging functions didn't check reqInfo->remote_name for a NULL
-*) change getuid to geteuid in httpd.c so that effectively root people can
- start the server and have it change uids
-*) Slight code rearrangement to make Redirects from .htaccess more
- useful because the file doesn't have to exist.
-*) Added support for restricted access by Referer field
-*) Added OnDeny command for Limit directive which allows a redirect on
- failure (esp. useful for denying by referer)
-*) Added string allocating mechanism for speed
-*) Added CONTENT_MD5 header support from patches by Martin Hamilton
- (martin@net.lut.ac.uk)
-*) Server doesn't keep creating more structures in the event of KeepAlive
-*) Added bounds checking for security structures
-*) Fixed Order mutual-failure
-*) Support both CERN and NCSA style imagemaps (on a line by line basis)
-*) Attempting to make the server thread safe
-*) First attempt at allowing ErrorDocument 401s as html files (still broken)
-*) Fixed string searching for user in group
-*) Close csd (socket) on exec of CGI scripts so that client doesn't hang
- waiting for the scripts (and their children) to finish
-*) made a single interface for most output functions to make it easier
- to go to different output functions (SSL is a good example)
-*) remove path_args/path_alias crap, and put it in reqInfo structure
-*) Why do we require full URLs in Redirect? A local (root) url should work fine
-*) Redirect from .htaccess should work now (completely)
-*) Added hack to allow SSI of CGI, at a great expense of speed (CGI_SSI_HACK)
-*) Made getline() code re-entrant (now has its own sock_buf struct)
-
-
-
Fixes for 1.5c
------------------
*) add newline character to list of characters to strip from shell cmds
@@ -46,6 +12,15 @@ Fixes for 1.5c
start the server and have it change uids
*) Fix group checking
+Fixes for 1.5b (internal)
+------------------
+*) Couple of off by one errors in the DBM support (server and support files)
+*) HP/Apollo Domain/OS support updated
+*) SCO ODT and SCO SVR3 support updated
+*) Typo in LOCALHACK
+*) No error message for NO_CONTENT default imagemap
+*) clean up after directory indexing (memory leak)
+
Fixes for 1.5a
-------------------
*) Typo/Thinko for http_access.c which makes order deny/allow not work as
diff --git a/CREDITS b/CREDITS
index 82f0bb4..0821c37 100644
--- a/CREDITS
+++ b/CREDITS
@@ -28,8 +28,6 @@ Vince Tkac (tkac@oclc.org)
Elf Sternberg (elf@aaden.spry.com)
Nathan Neulinger (nneul@umr.edu)
Stuart Lynne (sl@wimsey.com)
-Martin Hamilton (martin@net.lut.ac.uk)
-Tim Hudson (tjh@mincom.oz.au) SSL
And for Porting information/help:
Alex Podlecki (a.podlecki@att.com) SVR4
diff --git a/README b/README
index e755dca..91ad215 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
-NCSA HTTPd Server 1.5.1 Beta
+NCSA HTTPd Server 1.5c
Copyright (c) 1995 Board of Trustees, University of Illinois
@@ -70,8 +70,6 @@ support/dbmpasswd Program to make password files that use dbm
support/htdigest Program to make MD5 password files (std/text)
support/htpasswd Program to make password files (std/text)
support/std2dbm Program to convert std files to dbm
-support/webgrab Brian J. Swetland's Command Line Browser
- (its almost as good as telnet)
Version Number Defined
---------------------------
@@ -84,4 +82,3 @@ Version Number Defined
| ---- Major revisions. Probably not going to be another until 2.0
------ Really major revisions, code overhauls, goal changes, language
changes
-
diff --git a/cgi-src/Makefile b/cgi-src/Makefile
old mode 100644
new mode 100755
diff --git a/cgi-src/imagemap.c b/cgi-src/imagemap.c
index b5bbc6b..c8a8e1a 100644
--- a/cgi-src/imagemap.c
+++ b/cgi-src/imagemap.c
@@ -47,9 +47,6 @@
**
** 1.9 : Fixed bug: If you requested a new style conf file in DOCUMENT_ROOT,
** and didn't have an old style conf file, it would fail
-** 1.9a: Most other imagemap programs seem to allow a non-full path as the url,
-** so we'll switch to that. Any url not starting with / goes to the
-** same path as the map file.
*/
#include ");
diff --git a/cgi-src/util.c b/cgi-src/util.c
index c3d5d65..f02eb06 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("&;`'\"|*?~<>^()[]{}$\\\x0A",cmd[x]) != -1){
+ if(ind("&;`'\"|*?~<>^()[]{}$\\",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 973b293..ae97f4c 100644
--- a/conf/httpd.conf-dist
+++ b/conf/httpd.conf-dist
@@ -160,13 +160,13 @@ AccessConfig conf/access.conf
LogOptions Separate
-# LogDirGroupWriteOk, LogDirOtherWriteOk: Define either of these if you
+# LogDirGroupWriteOk, LogDirPublicWriteOk: 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
-#LogDirOtherWriteOk
+#LogDirPublicWriteOk
# 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 0c7e3d0..70881f5 100644
--- a/conf/srm.conf-dist
+++ b/conf/srm.conf-dist
@@ -122,8 +122,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 compress Z
-#AddEncoding gzip gz
+#AddEncoding x-compress Z
+#AddEncoding x-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
diff --git a/src/FEATURE_REQUESTS b/src/FEATURE_REQUESTS
deleted file mode 100644
index 2efed4f..0000000
--- a/src/FEATURE_REQUESTS
+++ /dev/null
@@ -1,37 +0,0 @@
-
-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
deleted file mode 100644
index f57d1ad..0000000
--- a/src/HTTP_HEADERS
+++ /dev/null
@@ -1,81 +0,0 @@
-
-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
deleted file mode 100644
index d081916..0000000
--- a/src/HTTPd_REQ_PATH
+++ /dev/null
@@ -1,212 +0,0 @@
-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 b21dd0a..3dfc6aa 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,13 +1,12 @@
# NCSA HTTPd 1.5
#
# For normal machines with ANSI compilers
-#CC= cc
+# CC= cc
# For Suns or other non-ANSI platforms.
CC= gcc
-#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
+QUANTIFY=/hdf2/pure/quantify-2.0-sunos4/quantify
+PURIFY=purify
+
# CFLAGS, compile flags.
#
@@ -15,10 +14,12 @@ PURIFY=/hdf2/pure/purify-3.2-sunos4/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 -ansi -pedantic -Wall -DAIX_BROKEN_HEADERS
+#CFLAGS= -g -Wall -ansi -pedantic
+
# DIGEST AUTHENTICATION
#
@@ -45,8 +46,9 @@ 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
#
@@ -79,7 +81,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
@@ -87,7 +89,7 @@ LFLAGS= # -pg -DPROFILE
# For HP-UX
# AUX_CFLAGS= -DHPUX
# For AIX3
-# AUX_CFLAGS= -DAIX3 -D_ALL_SOURCE # For xlc compiler
+ AUX_CFLAGS= -DAIX3
# For AIX4
# AUX_CFLAGS= -DAIX4
# For Ultrix
@@ -100,7 +102,6 @@ LFLAGS= # -pg -DPROFILE
# AUX_CFLAGS= -DSEQUENT
# For Linux -m486 ONLY IF YOU HAVE 486 BINARY SUPPORT IN KERNEL
# AUX_CFLAGS= -DLINUX
-# DBM_LIBS = -lgdbm
# For NetBSD 1.0
# May not need -lcrypt if its included in your libc
# AUX_CFLAGS= -DNetBSD
@@ -141,21 +142,18 @@ LFLAGS= # -pg -DPROFILE
# -------------- You shouldn't have to edit anything else -----------------
# -------------------------------------------------------------------------
-SEC_CFLAGS = $(MD5_CFLAGS) $(KRB_CFLAGS)
-SEC_LIBS = $(KRB_LIBS)
-
-ALL_CFLAGS = $(CFLAGS) $(AUX_CFLAGS) $(SEC_CFLAGS) $(DBM_CFLAGS)
-ALL_LIBS = $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
+SEC_CFLAGS = $(MD5_CFLAGS) $(PGP_CFLAGS) $(KRB_CFLAGS)
+SEC_LIBS = $(KRB_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 allocate.o debug.o blackout.o
+open_logfile.o
.c.o: Makefile config.h portability.h constants.h
- $(CC) -c $(ALL_CFLAGS) $<
+ $(CC) -c $(CFLAGS) $(AUX_CFLAGS) $(SEC_CFLAGS) $(DBM_CFLAGS) $<
all: httpd
@@ -205,22 +203,21 @@ ultrix:
make tar AUX_CFLAGS=-DULTRIX CC=gcc CFLAGS=-O2
httpd: $(OBJS)
- $(CC) $(LFLAGS) -o httpd $(OBJS) $(ALL_LIBS)
+ $(CC) $(LFLAGS) -o httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
-# -logfile=/X11/blong/httpd/logs/pure_log
purify: $(OBJS)
- $(PURIFY) -program-name=/X11/blong/httpd/src/httpd \
+ $(PURIFY) -logfile=/X11/blong/httpd/logs/pure_log \
+ -program-name=/X11/blong/httpd/src/httpd \
-follow-child-processes=yes \
- $(CC) $(LFLAGS) -o httpd $(OBJS) $(ALL_LIBS)
+ $(CC) $(LFLAGS) -o httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
quantify: $(OBJS)
$(QUANTIFY) -record-child-process-data=yes \
- -record-data=no \
- -avoid-recording-system-calls=1,6,93,113,114 \
- $(CC) $(LFLAGS) -o httpd $(OBJS) $(ALL_LIBS)
+ -avoid-recording-system-calls=93,113,114 \
+ $(CC) $(LFLAGS) -o httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
tar: $(OBJS)
- $(CC) $(LFLAGS) -o ../httpd $(OBJS) $(ALL_LIBS)
+ $(CC) $(LFLAGS) -o ../httpd $(OBJS) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
http_access.o: Makefile config.h portability.h constants.h http_access.h \
@@ -251,9 +248,10 @@ 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 \
- 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
+ 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
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
@@ -267,8 +265,6 @@ 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
@@ -286,5 +282,5 @@ SRC = $(OBJS:%.o=%.c)
codecenter:
#setopt ansi
#setopt print_string 128
- #setopt load_flags $(ALL_FLAGS)
- #load $(LFLAGS) $(SRC) $(ALL_LIBS)
+ #setopt load_flags $(CFLAGS) $(AUX_CFLAGS) $(SEC_CFLAGS) $(DBM_CFLAGS)
+ #load $(LFLAGS) $(SRC) $(EXTRA_LIBS) $(SEC_LIBS) $(DBM_LIBS)
diff --git a/src/allocate.c b/src/allocate.c
deleted file mode 100644
index 0c66607..0000000
--- a/src/allocate.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/************************************************************************
- * 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
deleted file mode 100644
index 32cb23c..0000000
--- a/src/blackout.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/************************************************************************
- * 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 6581054..86b8a32 100644
--- a/src/cgi.c
+++ b/src/cgi.c
@@ -10,7 +10,7 @@
*
************************************************************************
*
- * cgi.c,v 1.44 1996/04/05 18:54:31 blong Exp
+ * cgi.c,v 1.34 1995/11/28 09:01:37 blong Exp
*
************************************************************************
*
@@ -56,34 +56,21 @@
#include
%c",LF); + if(rule) reqInfo->bytes_sent += fprintf(reqInfo->out,"%c",LF); return 1; } @@ -365,18 +361,15 @@ 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); - 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])) { + set_content_type(reqInfo,filebak); + if(((!strcmp(content_type,"text/html")) || + (strcmp(content_type, INCLUDES_MAGIC_TYPE) == 0)) + && (!content_encoding[0])) { if(!(thefile = FOpen(filename,"r"))) - goto not_found; + return NULL; n = fread(titlebuf,sizeof(char),MAX_STRING_LEN - 1,thefile); titlebuf[n] = '\0'; for(x=0,p=0;titlebuf[x];x++) { @@ -389,17 +382,14 @@ 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; } - not_found: - freeString(file_type); - freeString(file_encoding); + content_encoding[0] = '\0'; return NULL; } @@ -505,19 +495,22 @@ struct ent *make_dir_entry(per_request *reqInfo, char *path, void send_size(per_request *reqInfo, size_t size) { if(size == -1) { - rputs(" -",reqInfo); + fputs(" -",reqInfo->out); + reqInfo->bytes_sent += 5; } else { if(!size) { - rputs(" 0K",reqInfo); + fputs(" 0K",reqInfo->out); + reqInfo->bytes_sent += 5; } else if(size < 1024) { - rputs(" 1K",reqInfo); + fputs(" 1K",reqInfo->out); + reqInfo->bytes_sent += 5; } else if(size < 1048576) - rprintf(reqInfo,"%4dK",size / 1024); + reqInfo->bytes_sent += fprintf(reqInfo->out,"%4dK",size / 1024); else - rprintf(reqInfo,"%4dM",size / 1048576); + reqInfo->bytes_sent += fprintf(reqInfo->out,"%4dM",size / 1048576); } } @@ -557,28 +550,30 @@ void output_directories(per_request *reqInfo, struct ent **ar,int n,char *name) name[0] = '/'; name[1] = '\0'; } /* aaaaargh Solaris sucks. */ - rflush(reqInfo); + fflush(reqInfo->out); if(dir_opts & FANCY_INDEXING) { - rputs("
%c",LF); + reqInfo->bytes_sent += fprintf(reqInfo->out,"%c",LF); } - else if(rule) rprintf(reqInfo,"%c",LF); + if(plaintext) + reqInfo->bytes_sent += fprintf(reqInfo->out,"
%c",LF); + else if(rule) reqInfo->bytes_sent += fprintf(reqInfo->out,"
%c",LF); if(!(r = FOpen(fn,"r"))) return 0; send_fp(reqInfo,r,NULL); FClose(r); - if(plaintext) rprintf(reqInfo,"
",reqInfo); + fputs("",reqInfo->out); + (reqInfo->bytes_sent) += 5; if((tp = find_icon(reqInfo,"^^BLANKICON^^",1))) - rprintf(reqInfo,"",tp); - rprintf(reqInfo,"Name "); + reqInfo->bytes_sent += (fprintf(reqInfo->out, + "
",tp)); + reqInfo->bytes_sent += fprintf(reqInfo->out,"Name "); if(!(dir_opts & SUPPRESS_LAST_MOD)) - rprintf(reqInfo,"Last modified "); + reqInfo->bytes_sent += fprintf(reqInfo->out,"Last modified "); if(!(dir_opts & SUPPRESS_SIZE)) - rprintf(reqInfo,"Size "); + reqInfo->bytes_sent += fprintf(reqInfo->out,"Size "); if(!(dir_opts & SUPPRESS_DESC)) - rprintf(reqInfo,"Description"); - rprintf(reqInfo,"%c
%c",LF,LF); + reqInfo->bytes_sent += fprintf(reqInfo->out,"Description"); + reqInfo->bytes_sent += fprintf(reqInfo->out,"%c
%c",LF,LF); } else { - rputs("
out);
+ ++(reqInfo->bytes_sent);
}
}
- rputc(c,reqInfo);
+ putc(c,reqInfo->out);
+ ++(reqInfo->bytes_sent);
}
p=0;
}
@@ -210,6 +211,9 @@ 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;
@@ -223,14 +227,13 @@ int send_included_file(per_request *reqInfo, char *fn)
if(!allow)
return -1;
set_content_type(reqInfo,reqInfo->filename);
- if((op & OPT_INCLUDES) &&
- (!strcmp(reqInfo->outh_content_type,INCLUDES_MAGIC_TYPE))) {
+ if((op & OPT_INCLUDES) && (!strcmp(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(reqInfo->outh_content_type,CGI_MAGIC_TYPE))
+ else if(!strcmp(content_type,CGI_MAGIC_TYPE))
return -1;
else {
if(!(fp=FOpen(reqInfo->filename,"r")))
@@ -242,30 +245,20 @@ int send_included_file(per_request *reqInfo, char *fn)
}
int handle_include(per_request *reqInfo, FILE *fp, char *error) {
- char *tag,*errstr;
+ char tag[MAX_STRING_LEN],errstr[MAX_STRING_LEN];
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))) {
- freeString(tag);
- freeString(errstr);
+ if(!(tag_val = get_tag(fp,tag)))
return 1;
- }
if(!strcmp(tag,"file")) {
- char *dir,*to_send;
+ char dir[MAX_STRING_LEN],to_send[MAX_STRING_LEN];
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 */
- getcwd(dir,MAX_STRING_LEN);
+ getwd(dir);
make_full_path(dir,tag_val,to_send);
- newInfo = continue_request(reqInfo, KEEP_ENV | KEEP_AUTH);
- newInfo->http_version = P_HTTP_0_9;
+ newInfo = continue_request(reqInfo,NEW_URL | KEEP_ENV);
strcpy(newInfo->url,tag_val);
strcpy(newInfo->args,reqInfo->args);
strcpy(newInfo->filename,to_send);
@@ -273,21 +266,18 @@ 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);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%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, KEEP_ENV | KEEP_AUTH);
- newInfo->http_version = P_HTTP_0_9;
+ newInfo = continue_request(reqInfo, NEW_URL | KEEP_ENV);
strcpy(newInfo->url,tag_val);
if(translate_name(newInfo,newInfo->url,newInfo->filename)
!= A_STD_DOCUMENT) {
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%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 {
@@ -295,22 +285,19 @@ 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);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
}
reqInfo->bytes_sent += newInfo->bytes_sent;
}
free_request(newInfo,ONLY_LAST);
}
- else if(!strcmp(tag,"done")) {
- freeString(tag);
- freeString(errstr);
+ else if(!strcmp(tag,"done"))
return 0;
- }
else {
sprintf(errstr,"unknown parameter %s to tag echo in %s",tag,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
}
}
}
@@ -318,22 +305,23 @@ int handle_include(per_request *reqInfo, FILE *fp, char *error) {
#ifndef NO_YOW
#include "httpy.h"
-void print_yow(per_request *reqInfo, int yow_num) {
+int 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]) {
- rputc(yow_lines[yow_num][i],reqInfo);
+ putc(yow_lines[yow_num][i],reqInfo->out);
if (yow_lines[yow_num][i] == ' ') {
tmp = href_on;
href_on = (rand() % 100 < 50) ? 1 : 0;
if (tmp != href_on) {
if (!tmp)
- rprintf(reqInfo,"", reqInfo->url);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"",
+ reqInfo->url);
else
- rprintf(reqInfo,"");
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"");
}
i++;
while ((yow_lines[yow_num][i] == ' ') && yow_lines[yow_num][i++]);
@@ -344,23 +332,19 @@ void print_yow(per_request *reqInfo, int yow_num) {
i++;
}
if (href_on) {
- rprintf(reqInfo,"");
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"");
}
}
#endif /* NO_YOW */
int handle_echo(per_request *reqInfo, FILE *fp, char *error) {
- char *tag;
+ char tag[MAX_STRING_LEN];
char *tag_val;
- tag = newString(MAX_STRING_LEN,STR_TMP);
-
while(1) {
- if(!(tag_val = get_tag(fp,tag))) {
- freeString(tag);
+ if(!(tag_val = get_tag(fp,tag)))
return 1;
- }
if(!strcmp(tag,"var")) {
int x,i,len;
@@ -368,12 +352,13 @@ 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))) {
- rprintf(reqInfo,"%s",&(reqInfo->env[x][i+1]));
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",
+ &(reqInfo->env[x][i+1]));
break;
}
}
if(!(reqInfo->env[x]))
- rprintf(reqInfo,"(none)");
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"(none)");
}
#ifndef NO_YOW
else if(!strcmp(tag,"yow")) {
@@ -381,26 +366,19 @@ int handle_echo(per_request *reqInfo, FILE *fp, char *error) {
print_yow(reqInfo,num);
}
#endif /* NO_YOW */
- else if(!strcmp(tag,"done")) {
- freeString(tag);
+ else if(!strcmp(tag,"done"))
return 0;
- }
else {
- char *errstr;
-
- errstr = newString(MAX_STRING_LEN,STR_TMP);
-
+ 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);
- rprintf(reqInfo,"%s",error);
-
- freeString(errstr);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
}
}
}
-int include_cgi(per_request *reqInfo) {
+int include_cgi(per_request *reqInfo, char *pargs) {
char op;
int allow,check_cgiopt;
struct stat finfo;
@@ -412,12 +390,10 @@ int include_cgi(per_request *reqInfo) {
return -1;
check_cgiopt=0;
} else {
- char *dir;
- dir = newString(MAX_STRING_LEN, STR_TMP);
- getcwd(dir,MAX_STRING_LEN);
+ char dir[MAX_STRING_LEN];
+ getwd(dir);
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)
@@ -428,51 +404,43 @@ int include_cgi(per_request *reqInfo) {
if((!allow) || (check_cgiopt && (!(op & OPT_EXECCGI))))
return -1;
- if(cgi_stub(reqInfo,&finfo,op) == SC_REDIRECT_TEMP)
- rprintf(reqInfo, "%s",reqInfo->outh_location,
- reqInfo->outh_location);
+ if(cgi_stub(reqInfo,pargs,&finfo) == SC_REDIRECT_TEMP)
+ reqInfo->bytes_sent += fprintf(reqInfo->out,
+ "%s",location,location);
return 0;
}
static int ipid;
void kill_include_child(void) {
- char *errstr;
-
- errstr = newString(MAX_STRING_LEN,STR_TMP);
-
+ char errstr[MAX_STRING_LEN];
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) {
+int include_cmd(per_request *reqInfo, char *s, char *pargs) {
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(reqInfo->path_info[0] || reqInfo->args[0]) {
- if(reqInfo->path_info[0]) {
- char *p2;
+ if(pargs[0] || reqInfo->args[0]) {
+ if(pargs[0]) {
+ char p2[HUGE_STRING_LEN];
- 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);
+ escape_shell_cmd(pargs);
+ make_env_str(reqInfo,"PATH_INFO",pargs);
+ translate_name(reqInfo,pargs,p2);
make_env_str(reqInfo,"PATH_TRANSLATED",p2);
-
- freeString(p2);
}
if(reqInfo->args[0]) {
make_env_str(reqInfo,"QUERY_STRING",reqInfo->args);
@@ -487,76 +455,72 @@ int include_cmd(per_request *reqInfo, char *s) {
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 *error)
+int handle_exec(per_request *reqInfo, FILE *fp, char *path_args,
+ char *error)
{
- char *tag,*errstr;
+ char tag[MAX_STRING_LEN],errstr[MAX_STRING_LEN];
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))) {
- freeString(tag);
- freeString(errstr);
+ if(!(tag_val = get_tag(fp,tag)))
return 1;
- }
if(!strcmp(tag,"cmd")) {
- if(include_cmd(reqInfo,tag_val) == -1) {
+ if(include_cmd(reqInfo,tag_val,path_args) == -1) {
sprintf(errstr,"invalid command exec %s in %s",tag_val,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%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, KEEP_ENV | KEEP_AUTH);
- newInfo->http_version = P_HTTP_0_9;
+ newInfo = continue_request(reqInfo,NEW_URL | KEEP_ENV);
strcpy(newInfo->url,tag_val);
- if(include_cgi(newInfo) == -1) {
+ if(include_cgi(newInfo,path_args) == -1) {
sprintf(errstr,"invalid CGI ref %s in %s",newInfo->filename,
reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
}
reqInfo->bytes_sent += newInfo->bytes_sent;
free_request(newInfo,ONLY_LAST);
/* grumble groan */
chdir_file(reqInfo->filename);
}
- else if(!strcmp(tag,"done")) {
- freeString(errstr);
- freeString(tag);
+ else if(!strcmp(tag,"done"))
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);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
}
}
@@ -564,16 +528,12 @@ int handle_exec(per_request *reqInfo, FILE *fp, char *error)
int handle_config(per_request *reqInfo, FILE *fp, char *error,
char *tf, int *sizefmt) {
- char *tag;
+ char tag[MAX_STRING_LEN];
char *tag_val;
- tag = newString(MAX_STRING_LEN,STR_TMP);
-
while(1) {
- if(!(tag_val = get_tag(fp,tag))) {
- freeString(tag);
+ if(!(tag_val = get_tag(fp,tag)))
return 1;
- }
if(!strcmp(tag,"errmsg"))
strcpy(error,tag_val);
else if(!strcmp(tag,"timefmt")) {
@@ -588,33 +548,24 @@ 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")) {
- freeString(tag);
+ }
+ else if(!strcmp(tag,"done"))
return 0;
- }
else {
- char *errstr;
-
- errstr = newString(MAX_STRING_LEN,STR_TMP);
-
+ char errstr[MAX_STRING_LEN];
sprintf(errstr,"unknown parameter %s to tag config in %s",
tag, reqInfo->filename);
log_error(errstr,reqInfo->hostInfo->error_log);
- rprintf(reqInfo,"%s",error);
-
- freeString(errstr);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
}
}
}
#ifndef NO_YOW
int handle_yow(per_request *reqInfo, FILE *fp, char *error) {
- char *tag;
+ char tag[MAX_STRING_LEN];
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]) {
@@ -623,20 +574,10 @@ 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 {
- freeString(tag);
- return 1;
- }
- } else {
- freeString(tag);
- return 1;
- }
- } else {
- freeString(tag);
- return 1;
- }
+ } else return 1;
+ } else return 1;
+ } else return 1;
}
#endif /* NO_YOW */
@@ -645,41 +586,30 @@ 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, *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);
+ char errstr[MAX_STRING_LEN], dir[MAX_STRING_LEN], to_send[MAX_STRING_LEN];
if(!strcmp(tag,"file")) {
getparents(tag_val); /* get rid of any nasties */
- getcwd(dir,MAX_STRING_LEN);
+ getwd(dir);
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);
- rprintf(reqInfo,"%s",error);
- freeString(errstr);
- freeString(dir);
- freeString(to_send);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
return -1;
}
- freeString(errstr);
- freeString(dir);
- freeString(to_send);
return 0;
}
else if(!strcmp(tag,"virtual")) {
per_request *newInfo;
- newInfo = continue_request(reqInfo, KEEP_ENV | KEEP_AUTH);
- newInfo->http_version = P_HTTP_0_9;
+ newInfo = continue_request(reqInfo,NEW_URL | KEEP_ENV);
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);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
log_error(errstr,reqInfo->hostInfo->error_log);
}
else if(stat(newInfo->filename,finfo) == -1) {
@@ -687,27 +617,18 @@ 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);
- rprintf(reqInfo,"%s",error);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%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);
- rprintf(reqInfo,"%s",error);
- freeString(errstr);
- freeString(dir);
- freeString(to_send);
+ reqInfo->bytes_sent += fprintf(reqInfo->out,"%s",error);
return -1;
}
}
@@ -715,21 +636,15 @@ int find_file(per_request *reqInfo, char *directive, char *tag,
int handle_fsize(per_request *reqInfo, FILE *fp, char *error, int sizefmt)
{
- char *tag;
+ char tag[MAX_STRING_LEN];
char *tag_val;
struct stat finfo;
- tag = newString(MAX_STRING_LEN,STR_TMP);
-
while(1) {
- if(!(tag_val = get_tag(fp,tag))) {
- freeString(tag);
+ if(!(tag_val = get_tag(fp,tag)))
return 1;
- }
- else if(!strcmp(tag,"done")) {
- freeString(tag);
+ else if(!strcmp(tag,"done"))
return 0;
- }
else if(!find_file(reqInfo,"fsize",tag,tag_val,&finfo,error)) {
if(sizefmt == SIZEFMT_KMG) {
send_size(reqInfo,finfo.st_size);
@@ -741,9 +656,11 @@ int handle_fsize(per_request *reqInfo, FILE *fp, char *error, int sizefmt)
l = strlen(tag); /* grrr */
for(x=0;x %c",
err_string,LF);
- rprintf(reqInfo,"%c",LF);
+ fprintf(reqInfo->out,"%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(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(!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->method != M_HEAD) {
title_html(reqInfo,"Document moved");
- rprintf(reqInfo,"This document has permanently moved ");
- rprintf(reqInfo,"here. %c%c",
+ fprintf(reqInfo->out,"This document has permanently moved ");
+ fprintf(reqInfo->out,"here. %c%c",
err_string,LF,LF);
}
log_transaction(reqInfo);
@@ -393,95 +409,73 @@ int die(per_request *reqInfo, int type, char *err_string)
break;
case SC_USE_LOCAL_COPY:
reqInfo->status = SC_USE_LOCAL_COPY;
- set_stat_line(reqInfo);
- if (reqInfo->http_version != P_HTTP_0_9) {
- send_http_header(reqInfo);
- }
+ begin_http_header(reqInfo,StatLine304);
+ fputc(LF,reqInfo->out);
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(reqInfo->http_version != P_HTTP_0_9) {
- strcpy(reqInfo->outh_content_type,"text/html");
- send_http_header(reqInfo);
+ 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->method != M_HEAD) {
title_html(reqInfo,"Authorization Required");
- rprintf(reqInfo,"Browser not authentication-capable or %c",LF);
- rprintf(reqInfo,"authentication failed.%c",LF);
- rprintf(reqInfo,"%c",LF);
+ fprintf(reqInfo->out,
+ "Browser not authentication-capable or %c",LF);
+ fprintf(reqInfo->out,"authentication failed.%c",LF);
+ fprintf(reqInfo->out,"%s
%c",err,LF);
+ fprintf(reqInfo->out,"%s
%c",err,LF);
}
}
void title_html(per_request *reqInfo, char *msg)
{
- rprintf(reqInfo,"%s
%c",msg,LF);
+ fprintf(reqInfo->out,"%s
%c",msg,LF);
}
int die(per_request *reqInfo, int type, char *err_string)
{
- char *arguments;
+ char arguments[MAX_STRING_LEN];
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;
@@ -335,57 +346,62 @@ 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;
- set_stat_line(reqInfo);
- if (reqInfo->http_version != P_HTTP_0_9) {
- send_http_header(reqInfo);
- }
+ begin_http_header(reqInfo,StatLine204);
+ fputc(LF,reqInfo->out);
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(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(!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->method != M_HEAD) {
title_html(reqInfo,"Document moved");
- rprintf(reqInfo,
+ fprintf(reqInfo->out,
"This document has moved here.