Commit Graph

2540 Commits (ec9e6abcb3b5d3a2eb1339e6f87b5700cd1cd4c6)
 

Author SHA1 Message Date
Glenn Strauss 8af9e71ccc [core] allow earlier plugin init for SSL/TLS
If lighttpd is started privileged, then SSL/TLS modules need to be
initialized prior to chroot (optional) and prior to dropping privileges
in order to be able to read sensitive files such as private certificates

(thx m4t)
6 years ago
Glenn Strauss fb87ae8604 [mod_openssl] safer_X509_NAME_oneline() (fixes #2693)
provide a safer X590_NAME_oneline() with return value semantics similar
to those of snprintf() and use safer_X509_NAME_oneline() to set
SSL_CLIENT_S_DN when client cert is validated.

The manpage for X509_NAME_oneline() says:

    The functions X509_NAME_oneline() and X509_NAME_print() are legacy functions which produce a non standard output form, they don't handle multi character fields and have various quirks and inconsistencies. Their use is strongly discouraged in new applications.

Besides X509_NAME_oneline() function being deprecated, until fairly recently, there was a security issue with the function, too.

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-2176

    The X509_NAME_oneline function in crypto/x509/x509_obj.c in OpenSSL before 1.0.1t and 1.0.2 before 1.0.2h allows remote attackers to obtain sensitive information from process stack memory or cause a denial of service (buffer over-read) via crafted EBCDIC ASN.1 data.

github: closes #63, closes #83

x-ref:
  "support SSL_CLIENT_VERIFY & SSL_CLIENT_S_DN"
  https://redmine.lighttpd.net/issues/2693
  https://github.com/lighttpd/lighttpd1.4/pull/63
  https://github.com/lighttpd/lighttpd1.4/pull/83
6 years ago
Glenn Strauss e29f7d5738 [mod_dirlisting] sort "../" to top of names
sort "../" to top of names and do not emit "../" for docroot
6 years ago
Glenn Strauss b298e2acb0 [mod_extforward] quiet clang compiler warning
It does seem possible for PROXY protocol subelements to be misaligned
and a message has been sent to HAProxy author of the PROXY protocol.

On most modern processors and operating systems, misaligned access has a
cost, but not the outrageous cost that it historical had on processors
and older operating systems such as on SPARC processors running Solaris
prior to Solaris 11.
6 years ago
Glenn Strauss 21081c7b72 [mod_openssl] fix compile with openssl 1.1.0
fix compile with openssl 1.1.0
remove stray tabs from prior commit

(thx gazoo74)
6 years ago
Gaël PORTAY 04d510af20 [mod_openssl] ignore client verification error if not enforced
ignore client verification error if not enforced
  e.g. *not* ssl.verifyclient.enforce = "enable"

github: closes #83

x-ref:
  "ignore client verification error if not enforced"
  https://github.com/lighttpd/lighttpd1.4/pull/83
6 years ago
Glenn Strauss 69aeaf2fad [mod_proxy] fix typo identified by coverity
fix mod_proxy.c typo identified by coverity
silence some warnings checking return values of fcntl() in fdevent.c
6 years ago
Glenn Strauss 0399609ac2 [mod_openssl] ssl.ca-dn-file (fixes #2694)
(original patch by mackyle)

The ssl.ca-dn-file option provides independent control of
the "certificate_authorities" field (see RFC 5246 section
7.4.4 Certificate Request) separate from the actual list
of trusted certificate authorities used for client
certificate verification.

It may be necessary to send a hint that includes the DN
of a non-root client CA in order to receive the correct
certificate from the client, but such a non-root CA really
does not belong in the trusted client root CA list.

Signed-off-by: Kyle J. McKay mackyle@gmail.com

github: closes #64

x-ref:
  "add support for ssl.cadn-file"
  https://redmine.lighttpd.net/issues/2694
  https://github.com/lighttpd/lighttpd1.4/pull/64
6 years ago
Gaël PORTAY e422ac128a [mod_openssl] ssl.ca-crl-file for CRL (fixes #2319)
(original patch by binbrain, and updated by flynn)

github: closes #82

x-ref:
  "Support CRLs for client certificate verification"
  https://redmine.lighttpd.net/issues/2319
  https://github.com/lighttpd/lighttpd1.4/pull/82
6 years ago
Glenn Strauss 6f75cdddda [build] autotools use AC_PROG_CC_STDC macro
autotools now use AC_PROG_CC_STDC macro instead of -std=gnu99.
The default in current modern gcc compilers is -std=gnu11

(Note: src/CMakeLists.txt and SConstruct still specify -std=gnu99)
6 years ago
Glenn Strauss 1e8147fc3a [build] -Werror if --enable-extra-warnings=error
enable -Werror if ./configure --enable-extra-warnings=error

x-ref:
   "Fix warnings"
   https://github.com/lighttpd/lighttpd1.4/pull/81
6 years ago
Gaël PORTAY e8498bbfcc [core] silence compiler warnings if !HAVE_FORK
silence compiler warnings if HAVE_FORK is not set

However, if HAVE_FORK is not set, then -Werror was probably passed to
./configure, which is currently a mistake.  lighttpd can successfully
compiles src/ with -Werror on many platforms, but ./configure tests
should not be run with -Werror. [gstrauss]

github: closes #81

x-ref:
   "Fix warnings"
   https://github.com/lighttpd/lighttpd1.4/pull/81
6 years ago
Glenn Strauss 7a27d5eff5 [core] buffer to disk streaming to slow backends
buffer input to disk when streaming request body to slow backends
6 years ago
Glenn Strauss 574fb562f1 [mod_cgi] basic support for Upgrade: websocket
transition to transparent gateway for e.g. Upgrade: websocket

*experimental*

disabled by default
enabled with cgi.upgrade = "enable"
6 years ago
Glenn Strauss b641850376 [core] optional condition in config "else" clause (fixes #1268)
x-ref:
  "condition should be optional in "else" clause in configuration file"
  https://redmine.lighttpd.net/issues/1268
6 years ago
Glenn Strauss 86bb8be2c8 [core] perf: skip redundant strlen() if len known
performance: skip redundant strlen() if length is already known

introduce array_get_element_klen() to take key and klen params
6 years ago
Glenn Strauss 07cde2cf0b [core] set server.max-keep-alive-requests = 100 (fixes #2205)
median webpage in today's day and age contains 75-100 requests per page
so increasing the default server.max-keep-alive-requests in lighttpd
from 16 is more than warranted

x-ref:
  "set server.max-keep-alive-requests = 100"
  https://redmine.lighttpd.net/issues/2205
6 years ago
Glenn Strauss 8913dc4e59 [mod_extforward] compile on OSX
define MSG_DONTWAIT and MSG_NOSIGNAL to be no-ops on platforms
without support.  (fd should already be configured O_NONBLOCK
and SIGPIPE signal is configured to be ignored)

(thx avij and wardw)
6 years ago
Glenn Strauss 14656f8f89 [mod_proxy] basic support for Upgrade: websocket (fixes #2811)
transition to transparent proxy for e.g. Upgrade: websocket

*experimental*

disabled by default
enabled with proxy.header = ( "upgrade" => "enable" )

x-ref:
  "proxy Upgrade: websocket"
  https://redmine.lighttpd.net/issues/2811
6 years ago
Glenn Strauss 316e959b4d [core] prep mod transitions to transparent proxy
prep mod_proxy,mod_fastcgi,mod_scgi for transition to transparent proxy
6 years ago
Glenn Strauss dfc1603c4b [core] fix crash for invalid syntax in config file (fixes #2810)
fix crash for invalid syntax in config file for server.modules

x-ref:
  "Missing array entry type check in config_insert (configfile.c), SIGSEGV"
  https://redmine.lighttpd.net/issues/2810
6 years ago
Stefan Bühler 9752620792 [core] configparser: fix resource handling in error cases (fixes #2809)
- lemon never calls the destructor for variables on the RHS, make sure
  to manually clean up
- outside `if (ctx->ok) { }` always check for NULL pointers, i.e:
  - if (x) x->free(x)
  - buffer_free and array_free check for NULL on their own
- cleanup RHS variables below `if (ctx->ok) { }` at the bottom
  - set variables to NULL before if ownership gets passed on
- move some buffers instead of copying them

x-ref:
  "Memory corruption in yy_reduce (configparser.y), SIGSEGV"
  https://redmine.lighttpd.net/issues/2809
6 years ago
Glenn Strauss a48d65c8a5 [core] remove redundant resets of fde_ndx
after initialization, value of fde_ndx should be managed by fdevent.c
6 years ago
Glenn Strauss e685ef70f1 [core] act as transparent proxy after con Upgrade 6 years ago
Glenn Strauss 28851b2cdf [core] skip socket shutdown() if con->fd negative
(allow for future module(s) which give fd away over unix domain socket)
6 years ago
Glenn Strauss c66e826978 [mod_proxy,mod_scgi] fix truncated error trace 6 years ago
Glenn Strauss 77509ed087 [mod_fastcgi] consolidate backend read code
Use same funcs as other dynamic handlers to recv data from backend.
Add hook for fastcgi to process FastCGI packets (and other future
dynamic handlers may hook this in order to handle custom data framing)
6 years ago
Glenn Strauss e622aa4114 [mod_uploadprogress] handle query str progress ID (fixes #2808)
x-ref:
  "mod_uploadprogress fails when using parameters"
  https://redmine.lighttpd.net/issues/2808
6 years ago
Glenn Strauss 036d3d3d66 [mod_proxy] simple host/url mapping in headers (fixes #152)
Provide a simple mechanism for mapping host and urlpath header strings
in proxied request and response well-known headers.  This *is not*
intended as a one-size-fits-all, infinitely extensible, regex rewriting
engine.  Instead, the proxy.header directive aims to provide built-in
functionality in mod_proxy for a few common use cases by performing
simple host matching or urlpath prefix matching, and using the
mapping of the first match.  More complex use cases could possibly be
handled by a custom lighttpd module (which does not currently exist).

Note: the contents of the HTTP request-line and HTTP headers may or
may not be in normalized canonical forms, which may or may not influence
the simple matching performed.  Admins should take care to provide safe
defaults (fail closed) if mapping is expected to occur and blindly
passing non-mapped requests is undesirable.

proxy.header = (
    #"map-host-request" => (
        #"-" => "...",#replace provided given Host request authority
        #"..." => "-",#preserve existing authority (no further matching)
        #"..." => "", #preserve existing authority (no further matching)
        #             #(equivalent to "xxx" => "xxx")
        #"xxx" => "yyy", #map one string ("xxx") to another ("yyy")
    #),
    #"map-host-response" => (
        #"-" => "...",#replace authority used in backend request
        #"..." => "-",#replace with original authority
        #"..." => "", #preserve existing authority (no further matching)
        #             #(equivalent to "xxx" => "xxx")
        #"xxx" => "yyy", #map one string ("xxx") to another ("yyy")
    #),
    #"map-urlpath" => (
        #"/xxx"  => "/yyy",#map one urlpath prefix to another
        #"/xxx/" => "/",   #map one urlpath prefix to another
        #"/xxx"  => "",    #map one urlpath prefix to another
        #"/key"  => "/value",
        # Note: request headers have matching "key" prefix replaced with
        # "value", and response headers have matching "value" prefix
        # replaced with "key", with a pre-test of the "value" from the
        # first-matched "key" in request headers (if there was a match)
    #),
    #"https-remap" => "enable",
        # For https requests from client, map https:// to http://
        # when map-host-request matches URI in request, and map http://
        # to https:// when map-host-response matches URI in response.
        # (mod_proxy currently sends all backend requests as http)
  )

x-ref:
  "feature to remove part of the URI when passing along requests..."
  https://redmine.lighttpd.net/issues/152
6 years ago
Glenn Strauss 1465cf80f9 [core] calloc plugin_config for consistent init 6 years ago
Glenn Strauss 9c0ef6876d [core] permit strings,ints,arrays in config array
(modules may implement more particular restrictions)

x-ref:
  "[mod_proxy] forwarded is a string array only"
  https://github.com/lighttpd/lighttpd1.4/pull/80
6 years ago
Glenn Strauss b23065e547 [mod_accesslog] flag high precision ts for %T (fixes #2807)
flag high precision ts for %T after parsing %{xxx}T config

x-ref:
  "%D and %{UNIT}T of mod_accesslog do not work as expected"
  https://redmine.lighttpd.net/issues/2807
6 years ago
Glenn Strauss 45bb2c1f59 [core] permit strings and integers in config array
(modules may implement more particular restrictions)

github: closes #80
6 years ago
Gaël PORTAY 589faeef63 [core] fix build issue without ipv6 support
This patch fixes the build issue introduced with when code has been
shared in commit a448886485.

	http-header-glue.c: In function 'http_cgi_headers':
	http-header-glue.c:1555:39: error: 'b2' undeclared (first use in this function)
	http-header-glue.c:1555:39: note: each undeclared identifier is reported only once for each function it appears in

github: closes #79
6 years ago
Glenn Strauss 40f72a41b9 [core] omit default port from normalized host str
omit default scheme port from normalized host string
6 years ago
Glenn Strauss 440b371997 [mod_proxy] fix backslash escaping
(thx gportay)
6 years ago
Glenn Strauss 2986221cab [core] sys-strings.h abstraction for strings.h 6 years ago
Glenn Strauss 05c34ce464 [core] buffer_substr_replace() 6 years ago
Glenn Strauss ac143ead29 [core] inline simple buffer is empty checks 6 years ago
Glenn Strauss 8641d1b03f [core] no SOCK_CLOEXEC on Linux kernel < 2.6.27
Linux kernels < 2.6.27 (old!) might return EINVAL if SOCK_CLOEXEC used

x-ref:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529929
  http://www.linksysinfo.org/index.php?threads/lighttpd-no-longer-starts-toastman-1-28-0510-7.73132/
6 years ago
Glenn Strauss 9e46b8ea25 [core] extend mimetype search w/o leading '.'
repeat extension search without leading '.' to handle situation
where admin configured mimetype.assign keys without leading '.'
6 years ago
Glenn Strauss a434a3fab0 [mod_openssl] free local_send_buffer at exit 6 years ago
Glenn Strauss ba679290f9 [core] inet_ntop_cache now 4-element cache
(round-robin replacement; fixes what was effectively a 1-element cache)
6 years ago
Glenn Strauss 0cc7556aec [core] perf: stat_cache_mimetype_by_ext()
shared code to get mimetype string via longest extension match
(attempts to match file basename, then longest ext, then "")

Note: this is a behavior change from simple suffix match
      if there are 16 or more entries in mimetypes.assign
6 years ago
Glenn Strauss 8e97c84c0f [core] fix stat_cache initialization error
fix stat_cache initialization error (coverity identified memory leak)
  (bug introduced when moving stat_cache_init code from server.c to
   stat_cache.c)

quell insignificant coverity warning in mod_extforward
6 years ago
Glenn Strauss bd0b2592d1 [mod_extforward] fix typos in Forwarded handling
also: add commented-out code for potentially creating X-Forwarded-For
from Forwarded, if X-Forwarded-For is not present.
6 years ago
Glenn Strauss 78cc72726d [mod_extforward] support HAProxy "PROXY" protocol (fixes #2804)
experimental support to receive requests via HAProxy "PROXY" protocol

x-ref:
  "The PROXY protocol - Versions 1 & 2"
  http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt
  "support (HAProxy) PROXY protocol for receiving requests"
  https://redmine.lighttpd.net/issues/2804
6 years ago
Glenn Strauss e33ec75999 [core] save connection-level proto in con->proto
The per-request scheme starts with con->proto (e.g. "http")
and can later be changed per-request by mod_extforward or mod_magnet
6 years ago
Glenn Strauss a448886485 [core] inet_pton(), inet_ntop() on (sock_addr *)
shared code to provide inet_pton() and inet_ntop() behavior on
lighttpd (sock_addr *) and (buffer *) data structures.
6 years ago
Glenn Strauss b2e2d42c83 [mod_proxy] support Forwarded HTTP Extension (fixes #2703)
To enable "Forwarded", must enable which params to include.
The recommended set is "for" and "proto" unless other params
are required and proper security precautions have been taken.
proxy.forwarded = ( "for" => 1,
                    "proto" => 1,
                    #"host" => 1,
                    #"by" => 1,
                    #"remote_user" => 1,
                  )

See https://tools.ietf.org/html/rfc7239 for info about "Forwarded"

x-ref:
  "Forwarded HTTP Extension"
  https://tools.ietf.org/html/rfc7239
  "Forward authenticated user to proxied requests"
  https://redmine.lighttpd.net/issues/2703
6 years ago