Commit Graph

97 Commits (2f303d820558f6955fce87da8ec56ae4e05e2477)

Author SHA1 Message Date
Glenn Strauss 122094e3e3 [multiple] employ http_date.h, sys-time.h
- replace use of strptime() w/ implementation specialized for HTTP dates
- use thread-safe gmtime_r(), localtime_r() (replace localtime, gmtime)
2 years ago
Glenn Strauss f846a392d5 [multiple] use stat_cache_path_isdir() 3 years ago
Glenn Strauss 81029b8b51 [multiple] inline chunkqueue where always alloc'd
inline struct chunkqueue where always allocated in other structs

(memory locality)
3 years ago
Glenn Strauss f2e4e83a85 [mod_dirlisting] fix config parsing crash
(bug on master branch; never released)

(thx avij)

update doc that dir-listing.hide-dotfiles = "enable" by default
since lighttpd 1.4.40 https://redmine.lighttpd.net/issues/1081
3 years ago
Glenn Strauss d334eaf1ee [core] uint32_t is plenty large for path names 3 years ago
Glenn Strauss c687e01c98 [core] r->uri.path always set, though might be ""
(might be "" if <backend>.server sets "fix-root-scriptname" => "enable")
3 years ago
Glenn Strauss 7c7f8c467c [multiple] split con, request (very large change)
NB: r->tmp_buf == srv->tmp_buf (pointer is copied for quicker access)

NB: request read and write chunkqueues currently point to connection
    chunkqueues; per-request and per-connection chunkqueues are
    not distinct from one another
      con->read_queue  == r->read_queue
      con->write_queue == r->write_queue

NB: in the future, a separate connection config may be needed for
    connection-level module hooks.  Similarly, might need to have
    per-request chunkqueues separate from per-connection chunkqueues.
    Should probably also have a request_reset() which is distinct from
    connection_reset().
3 years ago
Glenn Strauss 31d9495330 [core] store subrequest_handler instead of mode
store pointer to module in handler_module instead of con->mode id
3 years ago
Glenn Strauss 1474be7859 [core] move addtl request-specific struct members 3 years ago
Glenn Strauss 19985261b2 [core] convenience macros to check req methods 3 years ago
Glenn Strauss 03b4c993d2 [multiple] generic config array type checking 3 years ago
Glenn Strauss 68d8d4c532 [multiple] stat_cache singleton 3 years ago
Glenn Strauss f24e6d696a [multiple] plugin_stats array
use global rather than passing around (server *) just for that

li_itostrn() and li_utostrn() return string length
(rather than requiring subsequent strlen() to find length)
3 years ago
Glenn Strauss 50bdb55de8 [multiple] connection hooks no longer get (srv *)
(explicit (server *) not passed; available in con->srv)
3 years ago
Glenn Strauss 010c28949c [multiple] prefer (connection *) to (srv *)
convert all log_error_write() to log_error() and pass (log_error_st *)

use con->errh in preference to srv->errh (even though currently same)

avoid passing (server *) when previously used only for logging (errh)
3 years ago
Glenn Strauss b73949e03f [multiple] plugin.c handles common FREE_FUNC code
(simpler for modules; less boilerplate to cut-n-paste)
3 years ago
Glenn Strauss ed62e354ff [core] use config_plugin_values_init() 3 years ago
Glenn Strauss 3fe1827633 [mod_dirlisting] use config_plugin_values_init() 3 years ago
Glenn Strauss e2de4e581e [core] const char *name in struct plugin
put void *data (always used) as first member of struct plugin

add int nconfig member to PLUGIN_DATA

calloc() inits p->data to NULL
3 years ago
Glenn Strauss 36f64b26a1 [core] simpler config_check_cond()
optimize for common case where condition has been evaluated for
the request and a cached result exists

(also: begin isolating data_config)
3 years ago
Glenn Strauss c2238256e2 [core] inline array as part of data_array value
(instead of value being (array *))
3 years ago
Glenn Strauss 601c572c39 [core] inline buffer as part of data_string value
(instead of value being (buffer *))
3 years ago
Glenn Strauss 47a758f959 [core] inline buffer key for *_patch_connection()
handle buffer key as part of DATA_UNSET in *_patch_connection()
(instead of key being (buffer *))
3 years ago
Glenn Strauss ad9b7e009b [core] inline buffer as part of DATA_UNSET key
(instead of key being (buffer *))
3 years ago
Glenn Strauss 83535bbef3 [core] differentiate array_get_* for ro and rw
array_get_element_klen() is now intended for read-only access
array_get_data_unset() is used by config processing for r/w access
array_get_buf_ptr() is used for r/w access to ds->value (string buffer)
3 years ago
Glenn Strauss a15f40a569 [core] replace open() with fdevent_open_cloexec()
fdevent_open_cloexec() opens files O_BINARY for consistency,
and with O_NONBLOCK, so that the server will not block if the
target file to open is a fifo.
4 years ago
Mohammed Sadiq 6a988bb0d0 [multiple] cleaner calloc use in SETDEFAULTS_FUNC
github: closes #99

x-ref:
  "cleaner calloc use in SETDEFAULTS_FUNC"
  https://github.com/lighttpd/lighttpd1.4/pull/99
4 years ago
Glenn Strauss d28bac32fe [multiple] reduce code dup in list resizing
reduce code duplication in list resizing
realloc() of NULL ptr has behavior similar to malloc()

Note that if initial size == 0, then code used to adjust size
must be += x to ensure the size is non-zero for reallocation.
(Multiplying 0 * x, e.g. power-2 resizing, will result in 0.)
4 years ago
Glenn Strauss 77c01f9817 [core] buffer_append_path_len()
concatenate paths, placing single '/' between strings

reverts broken commit:b9402283

(thx avij)
5 years ago
Glenn Strauss f69bd9cdb8 [core] perf: simple, quick buffer_clear()
quickly clear buffer instead of buffer_string_set_length(b, 0) or
buffer_reset(b).  Avoids free() of large buffers about to be reused,
or buffers that are module-scoped, persistent, and reused.

(buffer_reset() should still be used with buffers in connection *con
 when the data in the buffers is supplied by external, untrusted source)
5 years ago
Glenn Strauss 40d3408328 [core] perf: append response directly into write q
prepend non-dynamic response directly into write queue chunkqueue
5 years ago
Glenn Strauss 5b327e0089 [multiple] quiet compiler warnings --without-pcre
quiet compiler warnings for ./configure --without-pcre
5 years ago
Glenn Strauss 3dd3cde902 [core] abstraction layer for HTTP header manip
http_header.[ch]
convert existing calls to manip request/response headers
convert existing calls to manip environment array (often header-related)
5 years ago
Glenn Strauss 04d76e7afd [core] some header cleanup
provide standard types in first.h instead of base.h
provide lighttpd types in base_decls.h instead of settings.h
reduce headers exposed by headers for core data structures
  do not expose <pcre.h> or <stdlib.h> in headers
move stat_cache_entry to stat_cache.h
reduce use of "server.h" and "base.h" in headers
5 years ago
Glenn Strauss d3f4a62c10 [mod_dirlisting] custom js date parse func (fixes #2823)
lighttpd mod_dirlisting produces a directory listing with the date in a
certain format, and lighttpd calls setlocale(LC_TIME, "C"), so strftime
date used in mod_dirlisting is predictable.  Use a custom date parse
routine to replace Date.parse() in the javascript sorting functions.

x-ref:
  "Directory listing / sort by last modified does not work on Safari"
  https://redmine.lighttpd.net/issues/2823
6 years ago
Glenn Strauss 07e57e24c2 [mod_dirlisting] treat README and HEADER as paths (fixes #2818)
Treat README and HEADER as filepaths.  If absolute path, take as-is.
If relative path, then take relative to directory physical path.

This extends dir-listing.show-header and dir-listing.show-readme
feature to take a filename, which was introduced in lighttpd 1.4.43

x-ref:
  "Custom HEADER and README filepaths in mod_dirlisting are treated as relative paths instead of absolute paths when file name starts with '/'"
  https://redmine.lighttpd.net/issue/2818
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 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 a53f662a30 [core] remove some unused header includes
remove exposure of stdio.h in buffer.h for print_backtrace(), now static
6 years ago
Glenn Strauss bd77abe0f8 [config] more specific checks for array lists
More specific checks on contents of array lists.  Each module using
lists now does better checking on the types of values in the list
(strings, integers, arrays/lists)

This helps prevent misconfiguration of things like cgi.assign,
fastcgi.server, and scgi.server, where source code might be
served as static files if parenthesis are misplaced.

x-ref:
  https://redmine.lighttpd.net/boards/2/topics/6571
6 years ago
Glenn Strauss 090985af6b [mod_dirlisting] render dirlisting as HTML (fixes #2767)
(thx altblue)

x-ref:
  "Render dirlisting as HTML"
  https://redmine.lighttpd.net/issues/2767
7 years ago
Glenn Strauss 431bc346df remove #include "stream.h" where not used 7 years ago
Glenn Strauss f5eef270bb [mod_dirlisting] config header and readme files
dir-listing.show-header = "HEADER.txt"
dir-listing.show-readme = "README.txt"

now take a filename to display, in addition to "enable" or "disable".

The filename to display can not literally be "enable" or "disable",
since those retain current behavior of displaying "HEADER.txt" or
"README.txt", or disabling inclusion of a file for that directive.
7 years ago
Glenn Strauss cfa3d27fc3 [mod_dirlisting] js column sort for dirlist table (fixes #613, fixes #2315)
copied javascript from mod_status and from lighttpd2 mod_dirlist

modified and specialized for stable dirlist sorting by name

Partial implementation of Apache autoindex request query arguments
  (https://httpd.apache.org/docs/current/en/mod/mod_autoindex.html)
If query string is supplied, allow specifying initial column to sort
  ?C=N name (default)
  ?C=M last-modified, then by name
  ?C=S size, then by name
  ?C=T type, then by name
  ?C=D type, then by name
and O=[AD] can be added for descending or ascending order, e.g.
  ?C=N&O=D descending (default)
  ?C=N&O=A ascending

(While functional, no effort was made on js performance.
 Patches welcome)

New directive dir-listing.external-js for user to replace sorting js

Note: dir-listing.external-js or default js sorting is enabled only
if dir-listing.auto-layout = "enable" (which is the default)

x-ref:
  "client-selectable directory list sorting"
  https://redmine.lighttpd.net/issues/613
  "dir-listing.external-js"
  https://redmine.lighttpd.net/issues/2315
7 years ago
Glenn Strauss 09a663b95b [mod_dirlisting] dirlist does not handle POST 7 years ago
Glenn Strauss d506f4a569 minor: spelling changes in some comments/messages 7 years ago
Glenn Strauss acad2c903a fix some warnings reported by cppcheck
fix some warnings reported by cppcheck and
change mod_skeleton.c to use buffer_string_length()
7 years ago
Glenn Strauss 69ec5728f9 use con->conf.server_tag in modules
do not expose server info server_tag is configured by admin

default con->conf.server_tag is still PACKAGE_DESC, those
admin can configure server.tag otherwise.

(these changes reduce recompilation and relinking when switching
 brances in source control)
7 years ago
Glenn Strauss 72b133f595 fix errors detected by Coverity Scan
buffer.c:itostr() undefined behavior taking modulus of negative number

additional minor code changes made to quiet other coverity warnings
(false positives)
7 years ago
Glenn Strauss 879a282de7 fix errors detected by Coverity Scan
fd leak in mod_dirlisting.c
use after free in error condition in mod_proxy.c
NULL pointer dereference in error message in chunk.c

additional minor code changes made to quiet other coverity warnings
7 years ago