OpenBSD CVS

CVS log for src/usr.sbin/httpd/server_file.c


[BACK] Up to [local] / src / usr.sbin / httpd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.80 / (download) - annotate - [select for diffs], Mon Apr 29 16:17:46 2024 UTC (4 weeks, 5 days ago) by florian
Branch: MAIN
CVS Tags: HEAD
Changes since 1.79: +2 -1 lines
Diff to previous 1.79 (colored)

plug fd leak introduced in "avoid toctu" rewrite.

Issue reported by job
OK tb, job

Revision 1.79 / (download) - annotate - [select for diffs], Tue Apr 16 17:15:50 2024 UTC (6 weeks, 4 days ago) by florian
Branch: MAIN
Changes since 1.78: +117 -126 lines
Diff to previous 1.78 (colored)

Prevent toctu issues in static file serving and auto index generation.

This fixes a problem in passing, reported by matthieu@ where httpd
would return 500 Internal Server Error when it could stat(2) but not
open(2) a file. The correct error code is 403.

testing matthieu
ok tobhe, tl;dr ok stsp
input & OK deraadt

Revision 1.78 / (download) - annotate - [select for diffs], Sat Jan 6 11:29:00 2024 UTC (4 months, 3 weeks ago) by espie
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.77: +2 -2 lines
Diff to previous 1.77 (colored)

put the real sizes into the "title" attribute so that hovering shows the
exact value.

adjust/refactor javascript sorter accordingly

Revision 1.77 / (download) - annotate - [select for diffs], Thu Jan 4 18:17:47 2024 UTC (4 months, 3 weeks ago) by espie
Branch: MAIN
Changes since 1.76: +29 -24 lines
Diff to previous 1.76 (colored)

make auto-index better
- make it an actual table
- use "human readable sizes" for the file sizes
- add some decoration and javascript to be able to sort it per-column
(client side) (this means some extra column attribute)
- add glue to facilitate embedding js + css directly in the program
- add some graphical indication for directories
- should still validate as proper html everywhere (custom properties
need to be called data-* for this!)

Work with claudio@ and tb@, many thanks to claudio@ for some of the finer
points of css handling, and tb@ for some fine spaces fixes.

I've tried it with lynx as well, shows up correctly.

One big plus is that the size of columns work as utf-8, so you can expose
filenames without any problems (I've tried it with non-js text navigators
as well as firefox, chromium and friends)

And it looks slightly less yahoo ca. 1995.

It's still "one size fits all". If people object to the current look, adding
httpd.conf(5) properties to override the default css should be easy.

okay claudio@, tb@

Revision 1.76 / (download) - annotate - [select for diffs], Thu Dec 28 18:05:32 2023 UTC (5 months ago) by espie
Branch: MAIN
Changes since 1.75: +16 -6 lines
Diff to previous 1.75 (colored)

don't add values we won't print, use scandir properly

okay tb@

(logic NOT simplified because I don't want to risk introducing bugs,
and the compiler knows as much boolean logic as me)

Revision 1.75 / (download) - annotate - [select for diffs], Mon Aug 15 09:40:14 2022 UTC (21 months, 2 weeks ago) by op
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.74: +23 -14 lines
Diff to previous 1.74 (colored)

plug some memory leaks in server_file_index when failures occur

namelist and its entries are not freed if escape_html fails or if we
fail in the inner loop.  Move scandir later so it's closer to the for
loop and handle escape_html and url_encode failures.

With lots of help from tb, thanks!

ok tb@

Revision 1.74 / (download) - annotate - [select for diffs], Fri Mar 4 01:46:07 2022 UTC (2 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.73: +28 -16 lines
Diff to previous 1.73 (colored)

Only provide the .gz file if timestamp is >= the non-gzip file.  Make
sure it is a regular file.  Use the timestamp of the non-gzip file as
the last-modified timestamp, as proposed by claudio.
ok claudio bluhm millert

Revision 1.73 / (download) - annotate - [select for diffs], Wed Mar 2 23:27:43 2022 UTC (2 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.72: +52 -49 lines
Diff to previous 1.72 (colored)

struct stat from early file inspection was being used after actual file
open() which means the stat could refer to the wrong file.  Mostly this
relates to st_size use.  This bug could mean that httpd sends new files
truncated to the old length, saying "I am sure you have the correct file now"?
Could have other bad effects.
ok tb millert bluhm

Revision 1.72 / (download) - annotate - [select for diffs], Wed Mar 2 19:52:19 2022 UTC (2 years, 3 months ago) by tb
Branch: MAIN
Changes since 1.71: +5 -8 lines
Diff to previous 1.71 (colored)

Simplify .gz handling a bit

Combine strlcpy + strlcat into a single snprintf and remove a few
unnecessary parentheses.

ok deraadt millert

Revision 1.71 / (download) - annotate - [select for diffs], Sun Feb 27 20:30:30 2022 UTC (2 years, 3 months ago) by bluhm
Branch: MAIN
Changes since 1.70: +33 -3 lines
Diff to previous 1.70 (colored)

Add gzip-static option to httpd.  This allows to deliver precompressed
files with content-encoding gzip.
from prx at si3t dot ch; OK tracey@

Revision 1.70 / (download) - annotate - [select for diffs], Thu Apr 29 18:23:07 2021 UTC (3 years, 1 month ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.69: +2 -4 lines
Diff to previous 1.69 (colored)

Use relative reference URIs in Location header on directory redirects.

This adds support for front-ending httpd(8) with a TLS-terminating
gateway like relayd(8) that forwards unencrypted http traffic.

Previously httpd(8) would use a full URL in the Location header in 301
redirects when a user-agent requests a directory but without the
trailing '/'. If the user-agent originally connected with https, this
caused the redirected url to be http.

This change conforms to RFC7231 section 7.1.2.

Reported by Vincent Lee.

OK claudio@

Revision 1.69 / (download) - annotate - [select for diffs], Tue Mar 16 06:44:14 2021 UTC (3 years, 2 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.68: +9 -6 lines
Diff to previous 1.68 (colored)

A socket buffer is not the best size to read from a disk.
Use st_blksize to set high water mark; florian@

Revision 1.68 / (download) - annotate - [select for diffs], Fri May 22 07:18:17 2020 UTC (4 years ago) by bentley
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.67: +2 -3 lines
Diff to previous 1.67 (colored)

Use the simpler HTML5 idiom to declare charset in autogenerated pages.

This came from a suggestion by Andras Farkas to replace use of
XHTML self-closing tags.

ok cwen@ danj@ florian@

Revision 1.67 / (download) - annotate - [select for diffs], Mon May 18 14:40:06 2020 UTC (4 years ago) by cwen
Branch: MAIN
Changes since 1.66: +6 -2 lines
Diff to previous 1.66 (colored)

httpd: add a "dark mode" in directory listings and error pages

Introduce a new "dark mode" for httpd(8) directory listings and error pages,
using the prefers-color-scheme css function. It uses the colorscheme already
used in OpenBSD project websites.

This version will only be displayed if the user's browser specifically sends
a "prefer darker themes if available" request.

Input from florian@, danj@ and clematis.

OK florian@, danj@ (on a previous version with the wrong background color)

Revision 1.66 / (download) - annotate - [select for diffs], Fri Jun 15 12:36:05 2018 UTC (5 years, 11 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.65: +9 -3 lines
Diff to previous 1.65 (colored)

Fix 304 Not Modified response: don't send a body, use the correct MIME type.

Reported by Hidvegi Gabor  gaborca  websivision  hu

Fix found by anton@

OK anton@

Revision 1.65 / (download) - annotate - [select for diffs], Thu Feb 2 22:19:59 2017 UTC (7 years, 3 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.64: +14 -2 lines
Diff to previous 1.64 (colored)

Fix support for HTTP pipelining by handling all requests in the buffer.

Tested & OK jung@

Revision 1.60.2.1 / (download) - annotate - [select for diffs], Tue Jan 31 21:07:28 2017 UTC (7 years, 4 months ago) by benno
Branch: OPENBSD_5_9
Changes since 1.60: +2 -9 lines
Diff to previous 1.60 (colored) next main 1.61 (colored)

A bug in the processing of range headers in httpd can lead to memory
exhaustion and possibly crash httpd.

This patch disables range header processing.

The problem is fixed in future versions of httpd (OpenBSD 6.1)
by changing the way the file size is determined.

found by Pierre Kim (pierre.kim.sec at gmail.com), thanks.
fix by sunil@

ok reyk@ sunil@ and beck@ danj@ tb@ and tj@ on the errata.

Revision 1.62.2.1 / (download) - annotate - [select for diffs], Tue Jan 31 21:07:05 2017 UTC (7 years, 4 months ago) by benno
Branch: OPENBSD_6_0
Changes since 1.62: +2 -9 lines
Diff to previous 1.62 (colored) next main 1.63 (colored)

A bug in the processing of range headers in httpd can lead to memory
exhaustion and possibly crash httpd.

This patch disables range header processing.

The problem is fixed in future versions of httpd (OpenBSD 6.1)
by changing the way the file size is determined.

found by Pierre Kim (pierre.kim.sec at gmail.com), thanks.
fix by sunil@

ok reyk@ sunil@ and beck@ danj@ tb@ and tj@ on the errata.

Revision 1.64 / (download) - annotate - [select for diffs], Tue Jan 31 14:39:47 2017 UTC (7 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.63: +64 -95 lines
Diff to previous 1.63 (colored)

Reimplement httpd's support for byte ranges.

The previous implementation loaded all the output into a single output
buffer and used its size to determine the Content-Length of the body.

The new implementation calculates the body length first and writes the
individual ranges in an async way using the bufferevent mechanism.

This prevents httpd from using too much memory and applies the
watermark and throttling mechanisms to range requests.

Problem reported by Pierre Kim (pierre.kim.sec at gmail.com)

OK benno@ sunil@

Revision 1.63 / (download) - annotate - [select for diffs], Mon Jan 30 09:54:41 2017 UTC (7 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.62: +4 -6 lines
Diff to previous 1.62 (colored)

Fix error path of range requests, found while reviewing byte range support.

OK jsg@

Revision 1.62 / (download) - annotate - [select for diffs], Tue May 17 03:12:39 2016 UTC (8 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE
Branch point for: OPENBSD_6_0
Changes since 1.61: +8 -2 lines
Diff to previous 1.61 (colored)

Repair some file descriptor leaks.
ok beck krw millert

Revision 1.61 / (download) - annotate - [select for diffs], Tue Mar 8 09:33:15 2016 UTC (8 years, 2 months ago) by florian
Branch: MAIN
Changes since 1.60: +3 -1 lines
Diff to previous 1.60 (colored)

Set content charset for auto index generated page.
Pointed out and diff by dhill, thanks!
Tweaks and same change for error documents by me.

Revision 1.60 / (download) - annotate - [select for diffs], Mon Aug 3 11:45:17 2015 UTC (8 years, 10 months ago) by florian
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_8_BASE, OPENBSD_5_8
Branch point for: OPENBSD_5_9
Changes since 1.59: +2 -1 lines
Diff to previous 1.59 (colored)

Fix rev 1.70 of server.c by only re-enabling the bufferevent if we
previously disabled it because we were reading to fast (from disk).
Problem noted and tracked down to that commit by weerd@ and
independently by stsp@.
Tested by weerd@, stsp@, reyk@
OK bluhm@, reyk@

Revision 1.59 / (download) - annotate - [select for diffs], Mon Jul 20 11:38:19 2015 UTC (8 years, 10 months ago) by semarie
Branch: MAIN
Changes since 1.58: +9 -3 lines
Diff to previous 1.58 (colored)

ensure http_path is escaped before using it in Location redirection.

OK reyk@

Revision 1.58 / (download) - annotate - [select for diffs], Sat Jul 18 14:36:24 2015 UTC (8 years, 10 months ago) by kili
Branch: MAIN
Changes since 1.57: +2 -2 lines
Diff to previous 1.57 (colored)

Fix check against NULL which was reverted by accident in r1.56.

ok reyk@

Revision 1.57 / (download) - annotate - [select for diffs], Sat Jul 18 06:00:43 2015 UTC (8 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.56: +6 -7 lines
Diff to previous 1.56 (colored)

Allow to change the default media type globally or per-location,
eg. default type text/html.

OK florian@

Revision 1.56 / (download) - annotate - [select for diffs], Fri Jul 17 21:53:57 2015 UTC (8 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.55: +15 -11 lines
Diff to previous 1.55 (colored)

Adjust server_file_modified_since() to our style.  Please keep httpd clean.

Revision 1.55 / (download) - annotate - [select for diffs], Thu Jul 16 19:05:28 2015 UTC (8 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.54: +19 -19 lines
Diff to previous 1.54 (colored)

spacing

Revision 1.54 / (download) - annotate - [select for diffs], Tue May 5 11:10:13 2015 UTC (9 years ago) by florian
Branch: MAIN
Changes since 1.53: +26 -2 lines
Diff to previous 1.53 (colored)

Implement If-Modified-Since.
From Kyle Thompson <jmp AT giga DOT moe>.
Tweaks by me.
OK benno@

Revision 1.53 / (download) - annotate - [select for diffs], Sun May 3 18:39:58 2015 UTC (9 years, 1 month ago) by florian
Branch: MAIN
Changes since 1.52: +273 -7 lines
Diff to previous 1.52 (colored)

Implement byte ranges.
From Sunil Nimmagadda <sunil At nimmagadda DOT net>
OK benno@

Revision 1.52 / (download) - annotate - [select for diffs], Sat Apr 25 14:40:35 2015 UTC (9 years, 1 month ago) by florian
Branch: MAIN
Changes since 1.51: +5 -3 lines
Diff to previous 1.51 (colored)

Prepend files or directories containing ":" with "./" in directory
indexes as per RFC 3986:
A path segment that contains a colon character (e.g., "this:that")
cannot be used as the first segment of a relative-path reference, as
it would be mistaken for a scheme name.  Such a segment must be
preceded by a dot-segment (e.g., "./this:that") to make a relative-
path reference.

While here add a "/" to the end of directory names, this saves us one
redirect round trip.

Found the hard way & "functionality wise, OK" ajacoutot@
RFC pointer & OK benno@

Revision 1.51 / (download) - annotate - [select for diffs], Thu Feb 12 10:05:29 2015 UTC (9 years, 3 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.50: +2 -2 lines
Diff to previous 1.50 (colored)

Rename escape_uri() to url_encode() because it is the opposite of
url_decode().  No functional change.

Revision 1.50 / (download) - annotate - [select for diffs], Tue Feb 10 08:12:29 2015 UTC (9 years, 3 months ago) by florian
Branch: MAIN
Changes since 1.49: +17 -4 lines
Diff to previous 1.49 (colored)

Encode directory listings.
Problem pointed out by remco AT d-compu.dyndns.org some time ago.
Input / OK reyk@

Revision 1.49 / (download) - annotate - [select for diffs], Sun Feb 8 00:00:59 2015 UTC (9 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.48: +3 -2 lines
Diff to previous 1.48 (colored)

spacing

Revision 1.48 / (download) - annotate - [select for diffs], Wed Jan 21 22:21:05 2015 UTC (9 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.47: +2 -11 lines
Diff to previous 1.47 (colored)

httpd is based on relayd and had included many headers that are only
needed by its ancestor.  jsg@, include-what-you-use, and some manual
review helped to cleanup the headers (take iwyu with a grain of salt).
Based on common practice, httpd.h now also includes the necessary
headers for itself.

OK florian@

Revision 1.47 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:17 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.46: +10 -7 lines
Diff to previous 1.46 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.46 / (download) - annotate - [select for diffs], Tue Jan 13 09:21:15 2015 UTC (9 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.45: +2 -2 lines
Diff to previous 1.45 (colored)

bump copyright year

Revision 1.45 / (download) - annotate - [select for diffs], Tue Jan 6 17:55:28 2015 UTC (9 years, 4 months ago) by stsp
Branch: MAIN
Changes since 1.44: +2 -1 lines
Diff to previous 1.44 (colored)

Make httpd return "404 not found" if an intermediate component of a requested
file path does not exist rather than returning "500 internal server error".
ok reyk

Revision 1.44 / (download) - annotate - [select for diffs], Sun Jan 4 22:23:58 2015 UTC (9 years, 4 months ago) by chrisz
Branch: MAIN
Changes since 1.43: +10 -7 lines
Diff to previous 1.43 (colored)

add new url stripping option:

strip number
	Strip number path components from the beginning of the
	request URI before looking up the stripped-down URI at
	the document root.


reviewed with much patience and OK by reyk@

Revision 1.43 / (download) - annotate - [select for diffs], Thu Jan 1 14:15:02 2015 UTC (9 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.42: +2 -3 lines
Diff to previous 1.42 (colored)

Use the HTML5 doctype for error and auto index pages because it is
shorter, newer, and the recommendation.  From James Jerkins.

Exclude the charset for now because it is not explicitly handled by httpd.

OK validator.w3.org (This document was successfully checked as HTML5!)

Revision 1.42 / (download) - annotate - [select for diffs], Sun Dec 21 00:54:49 2014 UTC (9 years, 5 months ago) by guenther
Branch: MAIN
Changes since 1.41: +1 -2 lines
Diff to previous 1.41 (colored)

Stop pulling in <arpa/inet.h> or <arpa/nameser.h> when unnecessary.
*Do* pull it in when in_{port,addr}_h is needed and <netinet/in.h> isn't.

ok reyk@

Revision 1.41 / (download) - annotate - [select for diffs], Fri Dec 12 14:45:59 2014 UTC (9 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.40: +2 -2 lines
Diff to previous 1.40 (colored)

Like previously done in relayd, change the keyword "ssl" to "tls" to
reflect reality.

OK benno@

Revision 1.40 / (download) - annotate - [select for diffs], Thu Dec 4 02:44:42 2014 UTC (9 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.39: +1 -2 lines
Diff to previous 1.39 (colored)

stop viral header propagation. none of this code uses sys/hash.h
from Max Fillinger

Revision 1.31.4.1 / (download) - annotate - [select for diffs], Thu Nov 20 07:48:45 2014 UTC (9 years, 6 months ago) by jasper
Branch: OPENBSD_5_6
Changes since 1.31: +116 -60 lines
Diff to previous 1.31 (colored) next main 1.32 (colored)

httpd was developed very rapidly in the weeks before 5.6 release,
and it has a few flaws.  It would be nice to get these flaws fully
remediated before the next release, and that requires the community
to want to use it.
Therefore here is a "jumbo" patch that brings in the most important fixes.

committing on behalf of reyk@

Revision 1.39 / (download) - annotate - [select for diffs], Sat Oct 25 03:23:49 2014 UTC (9 years, 7 months ago) by lteo
Branch: MAIN
Changes since 1.38: +1 -2 lines
Diff to previous 1.38 (colored)

Remove unnecessary netinet/in_systm.h include.

ok millert@

Revision 1.38 / (download) - annotate - [select for diffs], Tue Oct 21 13:00:33 2014 UTC (9 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.37: +2 -2 lines
Diff to previous 1.37 (colored)

Rework the error message a little bit: Do not send details of the
error.  Traditionally, web servers responsed with the request path on
40x errors which could be abused to inject JavaScript etc.  Instead of
sanitizing the path, we just don't reprint it.  Also modify the style
a little bit but keep Comic Sans.

With input from Jonas Lindemann and doug@

Revision 1.37 / (download) - annotate - [select for diffs], Thu Oct 2 19:22:43 2014 UTC (9 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.36: +10 -6 lines
Diff to previous 1.36 (colored)

Fix an error case that was never handled ending up in an endless event
loop that could eat all CPU.  I thought that the previous (correct)
commit fixed it which wasn't the case.  But this one is obvious.

ok florian@

Revision 1.36 / (download) - annotate - [select for diffs], Sat Sep 27 12:49:45 2014 UTC (9 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

In addition to READ, disable WRITE events when closing the file
descriptor of the file I/O bufferevent. This fixes a potential event flood.

OK florian@

Revision 1.35 / (download) - annotate - [select for diffs], Fri Aug 29 13:01:46 2014 UTC (9 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.34: +5 -5 lines
Diff to previous 1.34 (colored)

Use two instead of one http descriptor for request and response.

OK chrisz@

Revision 1.34 / (download) - annotate - [select for diffs], Thu Aug 21 19:23:10 2014 UTC (9 years, 9 months ago) by chrisz
Branch: MAIN
Changes since 1.33: +17 -13 lines
Diff to previous 1.33 (colored)

Add Last-Modified: HTTP header.

OK reyk@

Revision 1.33 / (download) - annotate - [select for diffs], Thu Aug 14 07:50:35 2014 UTC (9 years, 9 months ago) by chrisz
Branch: MAIN
Changes since 1.32: +10 -13 lines
Diff to previous 1.32 (colored)

Remove obsolete struct stat parameters.

ok reyk@

Revision 1.32 / (download) - annotate - [select for diffs], Fri Aug 8 18:29:42 2014 UTC (9 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.31: +86 -35 lines
Diff to previous 1.31 (colored)

When opening directories, re-match the location after the index file
has been appended.  This allows to use a fastcgi target as the default
index, for example index.php.

OK florian@

Revision 1.31 / (download) - annotate - [select for diffs], Wed Aug 6 11:24:12 2014 UTC (9 years, 9 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE
Branch point for: OPENBSD_5_6
Changes since 1.30: +9 -8 lines
Diff to previous 1.30 (colored)

The watermark exposed a bug in server_write that broke keep-alive
support.  Instead of calling server_close from server_write, we have
to proceed to the next connection by calling the error handler.

OK jsg@

Revision 1.30 / (download) - annotate - [select for diffs], Wed Aug 6 09:36:31 2014 UTC (9 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.29: +5 -1 lines
Diff to previous 1.29 (colored)

Adjust the read/write watermarks according to the TCP send buffer.
This fixes sending of large files.  Previously, httpd was reading the
input file too quickly and could run out of memory when filling the
input buffer.

Found by jsg@
OK florian@

Revision 1.29 / (download) - annotate - [select for diffs], Mon Aug 4 17:43:20 2014 UTC (9 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.28: +3 -2 lines
Diff to previous 1.28 (colored)

Redirect to https:// if SSL/TLS is enabled.

Revision 1.28 / (download) - annotate - [select for diffs], Mon Aug 4 11:09:25 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.27: +1 -3 lines
Diff to previous 1.27 (colored)

httpd doesn't support SSL/TLS yet, remove the remaining bits.
The secrect plan is to add it later using the ressl wrapper library.

Revision 1.27 / (download) - annotate - [select for diffs], Sun Aug 3 22:47:25 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.26: +10 -1 lines
Diff to previous 1.26 (colored)

Only allow GET and HEAD for static files or return 405.

ok florian@

Revision 1.26 / (download) - annotate - [select for diffs], Sun Aug 3 22:38:12 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.25: +24 -15 lines
Diff to previous 1.25 (colored)

Also write log messages, like 404 Not Found, on error.  This is a bit
tricky because we couldn't guarantee a sane state after
server_response_http() so fail hard afterwards and close the connection.

ok doug@

Revision 1.25 / (download) - annotate - [select for diffs], Sun Aug 3 11:16:10 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.24: +3 -3 lines
Diff to previous 1.24 (colored)

Split fastcgi socket path and document root option and add the
SCRIPT_FILENAME CGI param with a prepended root.  This fixes php-fpm
that expects SCRIPT_FILENAME and also works with slowcgi if you
configure the root correctly.  For example, if SCRIPT_NAME and
REQUEST_URI are /php/index.php, root is /htdocs, SCRIPT_FILENAME will
be /htdocs/php/index.php.  As tested and discussed with florian@

Revision 1.24 / (download) - annotate - [select for diffs], Sat Aug 2 09:54:13 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.23: +2 -2 lines
Diff to previous 1.23 (colored)

spacing

Revision 1.23 / (download) - annotate - [select for diffs], Sat Aug 2 09:46:51 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.22: +3 -3 lines
Diff to previous 1.22 (colored)

scandir(3)-based directory auto index didn't work on NFS because the
file system is not filling in d_type properly.  Using st_mode from the
stat call fixes the problem, eg. S_ISDIR(st.st_mode) instead of
dp->d_type == DT_DIR.  Pointed out by pelikan@

Revision 1.22 / (download) - annotate - [select for diffs], Thu Jul 31 17:55:09 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.21: +7 -4 lines
Diff to previous 1.21 (colored)

some fastcgi improvements:
- DPRINTF instead of log_info for internal debugging.
- submit QUERY_STRING, if it exists
- use a proper function to create an HTTP header.
- use server_file_error() to detect EOF and fastcgi stream errors.
- disable keep-alive/persist for now until we have a reliable way to
get the content length from the cgi response or support chunked
encoding.

"Cool, jep" florian@

Revision 1.21 / (download) - annotate - [select for diffs], Thu Jul 31 14:25:14 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.20: +7 -7 lines
Diff to previous 1.20 (colored)

One bufferevent can be shared by file and fcgi.

Revision 1.20 / (download) - annotate - [select for diffs], Thu Jul 31 13:28:15 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.19: +3 -3 lines
Diff to previous 1.19 (colored)

Rename the "docroot" variable to "path" because it will be used for
either files or the fastcgi socket (and there's no need to use a union yet).

Revision 1.19 / (download) - annotate - [select for diffs], Wed Jul 30 07:09:38 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.18: +1 -7 lines
Diff to previous 1.18 (colored)

Reserve an extra file descriptor per connection instead of per
request.  This fixes fd accounting with persistent connections and
reduces the complexity of the implementation.

ok benno@

Revision 1.18 / (download) - annotate - [select for diffs], Tue Jul 29 16:17:28 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.17: +170 -8 lines
Diff to previous 1.17 (colored)

Add extended directory index options: "[no] index" and "[no] auto index".
The option "directory auto index" implements basic directory listing
and is turned off by default.

ok deraadt@

Revision 1.17 / (download) - annotate - [select for diffs], Sat Jul 26 22:38:38 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

Remove redundant slash

Revision 1.16 / (download) - annotate - [select for diffs], Fri Jul 25 23:23:39 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.15: +3 -2 lines
Diff to previous 1.15 (colored)

It is recommended to use a URL in the Location header of 3xx
responses.  To accomplish this, add some semantics to retrieve the
server host name of a connection: either IP, IP:PORT (if not 80) or
[IP6]:PORT, or Host value (if valid).

Revision 1.15 / (download) - annotate - [select for diffs], Fri Jul 25 21:29:58 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.14: +13 -18 lines
Diff to previous 1.14 (colored)

Canonicalize the request path once without the docroot and prepend the
docroot only only when it's needed.  Suggested by deraadt@.

Revision 1.14 / (download) - annotate - [select for diffs], Fri Jul 25 20:13:06 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.13: +3 -2 lines
Diff to previous 1.13 (colored)

Don't leak docroot in the error message if the default index file is missing.

OK florian@

Revision 1.13 / (download) - annotate - [select for diffs], Fri Jul 25 13:10:18 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.12: +4 -4 lines
Diff to previous 1.12 (colored)

Split server and server_config.

Revision 1.12 / (download) - annotate - [select for diffs], Fri Jul 25 12:46:23 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.11: +2 -2 lines
Diff to previous 1.11 (colored)

Rename a field, needed later, no functional change.

Revision 1.11 / (download) - annotate - [select for diffs], Fri Jul 25 12:42:05 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

Move the docroot into the server block.

Revision 1.10 / (download) - annotate - [select for diffs], Wed Jul 23 22:20:37 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.9: +2 -2 lines
Diff to previous 1.9 (colored)

The default index page shouldn't be a directory.  It's a 500.

Revision 1.9 / (download) - annotate - [select for diffs], Wed Jul 23 22:18:57 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.8: +5 -1 lines
Diff to previous 1.8 (colored)

Don't expose the docroot on error.

Revision 1.8 / (download) - annotate - [select for diffs], Wed Jul 23 21:43:12 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.7: +71 -28 lines
Diff to previous 1.7 (colored)

First attempt at verifying the request path and the access
permissions.  We also have to redirect with 301 if a directory name
was requested without the trailing slash.

Revision 1.7 / (download) - annotate - [select for diffs], Wed Jul 23 19:03:56 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.6: +13 -7 lines
Diff to previous 1.6 (colored)

Add canonicalize_path() to canonicalize the requested URL path.

Revision 1.6 / (download) - annotate - [select for diffs], Wed Jul 16 10:25:28 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.5: +52 -2 lines
Diff to previous 1.5 (colored)

Implement file descriptor accounting.  The concept was taken from
relayd but had to be adjusted for httpd.  It now handles single-pass
HTTP connections, persistent connections with multiple requests, and
body-less HEAD requests.  With input from benno@

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jul 15 09:51:06 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.4: +2 -1 lines
Diff to previous 1.4 (colored)

don't diplay the full path in error messages

Revision 1.4 / (download) - annotate - [select for diffs], Mon Jul 14 00:19:48 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.3: +16 -37 lines
Diff to previous 1.3 (colored)

first step towards keep-alive/persistent connections support

Revision 1.3 / (download) - annotate - [select for diffs], Sun Jul 13 15:07:50 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored)

Finish writing the output before closing the connection
(adopted from relayd).

Revision 1.2 / (download) - annotate - [select for diffs], Sun Jul 13 14:17:37 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.1: +28 -10 lines
Diff to previous 1.1 (colored)

Add support for media types (aka. MIME types): the types section is
compatible to nginx' mime.types file which can be included directly.
If not present, use a few built-in defaults for html, css, txt, jpeg,
gif, png, and js.

Revision 1.1 / (download) - annotate - [select for diffs], Sat Jul 12 23:34:54 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN

Add httpd(8), an attempt to turn the relayd(8) codebase into a simple
web server.  It is not finished yet and I just started it today, but
the goal is to provide an HTTP server that a) provides minimal
features, b) serves static files, c) provides FastCGI support, and d)
follows common coding practices of OpenBSD.

It will neither support plugins, nor custom memory allocators, EBCDIC
support, PCRE or any other things that can be found elsewhere.
httpd(8) is not intended to provide a fully-featured replacement for
nginx(8) or the Apache, but it will provide enough functionality that
is needed in the OpenBSD base system.

ok deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.