summaryrefslogtreecommitdiff
path: root/src/mod_webdav.c
Commit message (Collapse)AuthorAgeFilesLines
* [build] _WIN32 __declspec(dllexport) *_plugin_initGlenn Strauss2023-05-031-0/+1
| | | | _WIN32 __declspec(dllexport) on mod_*_plugin_init()
* [multiple] __MINGW32__ missing strftime() "%F %T"Glenn Strauss2023-05-031-0/+4
| | | | mingw does not support strftime() "%F %T"
* [core] _WIN32 sys-unistd.h to wrap <unistd.h>Glenn Strauss2023-05-031-1/+2
| | | | (selective implementations; not complete)
* [multiple] _WIN32 Find*File() sys-dirent.hGlenn Strauss2023-05-031-12/+4
| | | | _WIN32 FindFirstFile(), FindNextFile(), FindClose()
* [multiple] _WIN32 stat() compat sys-stat.hGlenn Strauss2023-05-031-1/+1
| | | | | | | no lstat() no S_IFSOCK no S_ISSOCK() ...
* [mod_webdav] send 409 Conflict if PUT miss parentGlenn Strauss2023-02-041-1/+9
| | | | send 409 Conflict if PUT into parent collection which does not exist
* [mod_webdav] MOD_WEBDAV_BUILD_MINIMAL preproc optGlenn Strauss2023-01-201-0/+2
| | | | | | | | | | | | | | | | -DMOD_WEBDAV_BUILD_MINIMAL preprocessor option to disable PROPPATCH, LOCK, UNLOCK by removing dependencies on libxml2, libsqlite3, libuuid (even if built --with-webdav-props --with-webdav-locks) This permits building mod_webdav.so and an alternative mod_webdav_min.so without the extra dependencies if the build system is extended to build mod_webdav_min, compiling mod_webdav.c with -DMOD_WEBDAV_BUILD_MINIMAL -Dmod_webdav_plugin_init=mod_webdav_min_plugin_init (note: build systems have not been extended here for mod_webdav_min.so) x-ref: "lighttpd-mod-webdav dependency to SQLite" https://redmine.lighttpd.net/issues/3188
* [mod_webdav] modify OPTIONS response if no db cfgGlenn Strauss2023-01-201-12/+17
| | | | | | | | | | | modify OPTIONS response if webdav.sqlite-db-name is not configured if webdav.sqlite-db-name is not configured, then in OPTIONS response - do not advertise PROPPATCH, LOCK, or UNLOCK in "Allow" response header - do not advertise DAV Compliance Class 2 in "DAV" response header x-ref: https://redmine.lighttpd.net/issues/3188
* [multiple] spelling: github action check-spellingGlenn Strauss2023-01-091-1/+1
|
* [multiple] employ ck_calloc, ck_malloc shared codeGlenn Strauss2022-12-101-9/+5
| | | | | employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
* [multiple] employ ck_realloc_u32() shared codeGlenn Strauss2022-12-101-16/+9
| | | | employ ck_realloc_u32() shared code to slightly reduce code size
* [multiple] mark mod_*_plugin_init() funcs coldGlenn Strauss2022-12-071-0/+1
|
* [mod_webdav] minor cleanups and adjustmentsGlenn Strauss2022-11-231-9/+13
|
* [core] manually calculate off_t max (fixes #3171)Glenn Strauss2022-09-151-1/+1
| | | | | | | | | | | | | manually calculate off_t max for broken cross-compilation systems which fail to enable large file support (so sizeof(off_t) != sizeof(int64_t)) If sizeof(off_t) != sizeof(int64_t), a negative number could end up in cq->upload_temp_file_size when it was assigned INTMAX_MAX, leading to excessive new temporary file creation occurring on each and every write. x-ref: "File upload regression with --disable-lfs" https://redmine.lighttpd.net/issues/3171
* [mod_webdav] build with Android NDKGlenn Strauss2022-07-221-0/+8
|
* [mod_webdav] webdav_reqbody_type_xml() fixesGlenn Strauss2022-07-011-2/+4
| | | | | webdav_reqbody_type_xml() must check request headers (behavior fix) protect webdav_reqbody_type_xml() with USE_PROPPATCH (compile fix)
* [mod_webdav] check reqbody Content-Type is XMLGlenn Strauss2022-06-111-3/+28
|
* [mod_webdav] cold func if xml reqbody w/o db confGlenn Strauss2022-06-111-8/+17
|
* [mod_webdav] alt handling PROPFIND on collectionGlenn Strauss2022-06-041-35/+2
| | | | | | | | | | | | | | | | | | | | | alternative way of handling PROPFIND on collection where the request was made without a trailing slash. Instead of sending 308 redirect in some cases, set Content-Location response header *and* treat as if request had been made with trailing slash on the collection for PROPFIND and PROPPATCH. https://www.rfc-editor.org/rfc/rfc4918#section-5.2 There is a standing convention that when a collection is referred to by its name without a trailing slash, the server MAY handle the request as if the trailing slash were present. In this case, it SHOULD return a Content-Location header in the response, pointing to the URL ending with the "/". x-ref: "The previous workaround for GVFS is breaking the new version of GVFS" https://redmine.lighttpd.net/boards/2/topics/10468 HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) https://www.rfc-editor.org/rfc/rfc4918#section-5.2
* [mod_webdav] If-None-Match: * on non-existentGlenn Strauss2022-05-141-2/+1
| | | | | | | | | | | | | | | fix logic for If-None-Match: * test on non-existent entity (regression in lighttpd 1.4.64) If-None-Match: * should not fail on a non-existent entity, as it may be used to make the request conditional on the origin server having no current representation of the entity. (see If-None-Match in RFC2616 and RFC7232) (This logic had been changed in lighttpd 1.4.64 in commit 8a535e7e064b0c33c3b60a92df88b349d79b94c2 when allowing bogus, non-'*' If-None-Match etags for non-existent entities to not-match (and pass the check)
* [multiple] use preferred syntax for Content-TypeGlenn Strauss2022-05-111-3/+3
| | | | | use preferred syntax for Content-Type: .../charset=... (match preferred syntax specified in upcoming HTTP spec revision)
* [multiple] use buffer_append_char()Glenn Strauss2022-05-111-21/+21
|
* [mod_webdav] opt for partial PUT via copy/renameGlenn Strauss2022-04-121-14/+98
| | | | | | | | | | option for partial PUT via copy/modify/rename webdav.opts += ("partial-put-copy-modify" => "enable") Some modern filesystems support efficiently cloning files, making it less expensive to copy to a tempfile, modify, and atomically rename the modified tempfile to replace the original.
* [multiple] shared code for struct chunk and mmapGlenn Strauss2022-02-191-66/+29
| | | | | | | | | | | | | | | | | | | chunkqueue_chunk_file_view() reduces size of struct chunk use mmap with mod_deflate libdeflate, if mmap available, even when lighttpd not built with --enable-mmap avoid using mmap on temp files in chunkqueue (c->file.is_temp) since pread() with a reasonable block size is typically as fast or faster than mmap on files read sequentially and used only once, especially when writing results to limited-size socket buffers (and lighttpd temp files are, in most cases, by default about 1 MB) (Exception: sometimes mmap is used for convenience or to fulfill a requirement, e.g. one-shot libdeflate in mod_deflate) (There are many factors which influence speed of mmap versus pread, so this should not be construed as generic usage advice.)
* [multiple] pedantic chunk.c checks for 0-len chunkGlenn Strauss2022-02-191-2/+3
|
* [mod_webdav] no COPYFILE_CLONE_FORCE on OSX <10.12 (fixes #3142)Glenn Strauss2022-01-241-10/+2
| | | | | | | | | | | | | (thx ryandesign) There is no COPYFILE_CLONE_FORCE on OSX <10.12 so fall back to using fcopyfile() to avoid race condition on source (if changed to dir) if using copyfile() with flags equivalent to COPYFILE_CLONE_FORCE, but without the 'force' flag. x-ref: "error: use of undeclared identifier 'COPYFILE_CLONE_FORCE'" https://redmine.lighttpd.net/issues/3142
* [mod_webdav] no sys/ioctl.h on _WIN32Glenn Strauss2022-01-101-1/+1
|
* [mod_webdav] define HAVE_RENAMEAT2 earlierGlenn Strauss2022-01-041-4/+8
| | | | (including linux/fs.h later might reveal RENAME_NOREPLACE)
* [mod_webdav] copy accelerationGlenn Strauss2022-01-041-16/+238
| | | | | | | | | | | | | | | | | * copy acceleration * safety for accelerated copying of files > 2 GB on 32-bit systems * disable hard linking when "deprecated-unsafe-partial-put" => "enable" (In normal operation, hard-linking is safe for copying since WebDAV modification of any file involves full upload of file and atomic replacement, which severs any hard-links. When deprecated unsafe partial PUT is permitted, that is not the case.) x-ref: https://man7.org/linux/man-pages/man2/copy_file_range.2.html https://www.freebsd.org/cgi/man.cgi?query=copy_file_range&sektion=2&n=1 https://man7.org/linux/man-pages/man2/ioctl_ficlone.2.html https://keith.github.io/xcode-man-pages/clonefile.2.html https://keith.github.io/xcode-man-pages/copyfile.3.html
* [mod_webdav] copy_file_range() new in FreeBSD 13Glenn Strauss2022-01-021-3/+1
| | | | | | | | | | | (take 2) adjust feature defines for header visibility of copy_file_range() (introduced in FreeBSD 13) x-ref: https://redmine.lighttpd.net/issues/3128 https://github.com/freebsd/freebsd-src/blob/main/sys/sys/cdefs.h#L634
* [mod_webdav] copy_file_range() new in FreeBSD 13Glenn Strauss2022-01-011-0/+7
| | | | | | | | | | | (thx devnexen) adjust feature defines for header visibility of copy_file_range() (introduced in FreeBSD 13) x-ref: https://redmine.lighttpd.net/issues/3128 https://github.com/freebsd/freebsd-src/blob/main/sys/sys/cdefs.h#L634
* [mod_webdav] detect truncated copy_file_range()Glenn Strauss2022-01-011-1/+2
| | | | | detect truncated file when using copy_file_range(), even though this should not happen with lighttpd-created temporary files
* [multiple] remove r->physical.etagGlenn Strauss2021-12-121-12/+8
| | | | (no longer used; was used as temporary buffer)
* [mod_webdav] If-None-Match on non-existent entityGlenn Strauss2021-12-091-1/+1
| | | | | | | | | | fix logic inversion on If-None-Match test on non-existent entity return 412 if If-None-Match: "*" for non-existent entity x-ref: "trying to use Joplin Android App with lighttpd" https://redmine.lighttpd.net/boards/3/topics/10193
* [mod_webdav] ignore PROPFIND Depth for filesGlenn Strauss2021-10-161-3/+2
| | | | | | | | | | | | | (thx meeb5) ignore PROPFIND "Depth" request header for files (non-collections) RFC4918 10.2. Depth Header "If a resource does not have internal members, then the Depth header MUST be ignored." x-ref: "Webdav + rclone backup" https://redmine.lighttpd.net/boards/2/topics/10081
* [multiple] fdevent_mkostemp()Glenn Strauss2021-09-301-1/+1
| | | | | | fdevent_mkostemp() with flags arg so that caller can pass O_APPEND renamed from fdevent_mkstemp_append(), previously always O_APPEND
* [core] remove server.upload-temp-file-size limitGlenn Strauss2021-09-081-3/+0
| | | | | | previously undocumented server.upload-temp-file-size in lighttpd 1.4.38 preceded introduction of lighttpd streaming options in lighttpd 1.4.40 (server.stream-request-body and server.stream-response-body)
* [core] chunkqueue_append_buffer always clears bufGlenn Strauss2021-09-081-1/+1
| | | | | chunkqueue_append_buffer() always clears buffer (instead of relying on caller to do so after the call)
* [multiple] Y2038 32-bit signed time_t mitigationsGlenn Strauss2021-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most OS platforms have already provided solutions to Y2038 32-bit signed time_t 5 - 10 years ago (or more!) Notable exceptions are Linux i686 and FreeBSD i386. Since 32-bit systems tend to be embedded systems, and since many distros take years to pick up new software, this commit aims to provide Y2038 mitigations for lighttpd running on 32-bit systems with Y2038-unsafe 32-bit signed time_t * Y2038: lighttpd 1.4.60 and later report Y2038 safety $ lighttpd -V + Y2038 support # Y2038-SAFE $ lighttpd -V - Y2038 support (unsafe 32-bit signed time_t) # Y2038-UNSAFE * Y2038: general platform info * Y2038-SAFE: lighttpd 64-bit builds on platforms using 64-bit time_t - all major 64-bit platforms (known to this author) use 64-bit time_t * Y2038-SAFE: lighttpd 32-bit builds on platforms using 64-bit time_t - Linux x32 ABI (different from i686) - FreeBSD all 32-bit and 64-bit architectures *except* 32-bit i386 - NetBSD 6.0 (released Oct 2012) all 32-bit and 64-bit architectures - OpenBSD 5.5 (released May 2014) all 32-bit and 64-bit architectures - Microsoft Windows XP and Visual Studio 2005 (? unsure ?) Another reference suggests Visual Studio 2015 defaults to 64-bit time_t - MacOS 10.15 Catalina (released 2019) drops support for 32-bit apps * Y2038-SAFE: lighttpd 32-bit builds on platforms using 32-bit unsigned time_t - e.g. OpenVMS (unknown if lighttpd builds on this platform) * Y2038-UNSAFE: lighttpd 32-bit builds on platforms using 32-bit signed time_t - Linux 32-bit (including i686) - glibc 32-bit library support not yet available for 64-bit time_t - https://sourceware.org/glibc/wiki/Y2038ProofnessDesign - Linux kernel 5.6 on 32-bit platforms does support 64-bit time_t https://itsubuntu.com/linux-kernel-5-6-to-fix-the-year-2038-issue-unix-y2k/ - https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html "Note: at this point, 64-bit time support in dual-time configurations is work-in-progress, so for these configurations, the public API only makes the 32-bit time support available. In a later change, the public API will allow user code to choose the time size for a given compilation unit." - compiling with -D_TIME_BITS=64 currently has no effect - glibc recent (Jul 2021) mailing list discussion - https://public-inbox.org/bug-gnulib/878s2ozq70.fsf@oldenburg.str.redhat.com/T/ - FreeBSD i386 - DragonFlyBSD 32-bit * Y2038 mitigations attempted on Y2038-UNSAFE platforms (32-bit signed time_t) * lighttpd prefers system monotonic clock instead of realtime clock in places where realtime clock is not required * lighttpd treats negative time_t values as after 19 Jan 2038 03:14:07 GMT * (lighttpd presumes that lighttpd will not encounter dates before 1970 during normal operation.) * lighttpd casts struct stat st.st_mtime (and st.st_*time) through uint64_t to convert negative timestamps for comparisions with 64-bit timestamps (treating negative timestamp values as after 19 Jan 2038 03:14:07 GMT) * lighttpd provides unix_time64_t (int64_t) and * lighttpd provides struct unix_timespec64 (unix_timespec64_t) (struct timespec equivalent using unix_time64_t tv_sec member) * lighttpd provides gmtime64_r() and localtime64_r() wrappers for platforms 32-bit platforms using 32-bit time_t and lighttpd temporarily shifts the year in order to use gmtime_r() and localtime_r() (or gmtime() and localtime()) from standard libraries, before readjusting year and passing struct tm to formatting functions such as strftime() * lighttpd provides TIME64_CAST() macro to cast signed 32-bit time_t to unsigned 32-bit and then to unix_time64_t * Note: while lighttpd tries handle times past 19 Jan 2038 03:14:07 GMT on 32-bit platforms using 32-bit signed time_t, underlying libraries and underlying filesystems might not behave properly after 32-bit signed time_t overflows (19 Jan 2038 03:14:08 GMT). If a given 32-bit OS does not work properly using negative time_t values, then lighttpd likely will not work properly on that system. * Other references and blogs - https://en.wikipedia.org/wiki/Year_2038_problem - https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs - http://www.lieberbiber.de/2017/03/14/a-look-at-the-year-20362038-problems-and-time-proofness-in-various-systems/
* [core] http_date_time_append() convenience macroGlenn Strauss2021-08-271-3/+1
| | | | append IMF-fixdate time string to (buffer *)
* [multiple] reduce use of BUFFER_INTLEN_PTRGlenn Strauss2021-08-271-2/+1
| | | | reduce use of BUFFER_INTLEN_PTR where b->ptr known not to be NULL
* [multiple] reduce redundant NULL buffer checksGlenn Strauss2021-08-271-91/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a large set of code changes and results in removal of hundreds, perhaps thousands, of CPU instructions, a portion of which are on hot code paths. Most (buffer *) used by lighttpd are not NULL, especially since buffers were inlined into numerous larger structs such as request_st and chunk. In the small number of instances where that is not the case, a NULL check is often performed earlier in a function where that buffer is later used with a buffer_* func. In the handful of cases that remained, a NULL check was added, e.g. with r->http_host and r->conf.server_tag. - check for empty strings at config time and set value to NULL if blank string will be ignored at runtime; at runtime, simple pointer check for NULL can be used to check for a value that has been set and is not blank ("") - use buffer_is_blank() instead of buffer_string_is_empty(), and use buffer_is_unset() instead of buffer_is_empty(), where buffer is known not to be NULL so that NULL check can be skipped - use buffer_clen() instead of buffer_string_length() when buffer is known not to be NULL (to avoid NULL check at runtime) - use buffer_truncate() instead of buffer_string_set_length() to truncate string, and use buffer_extend() to extend Examples where buffer known not to be NULL: - cpv->v.b from config_plugin_values_init is not NULL if T_CONFIG_BOOL (though we might set it to NULL if buffer_is_blank(cpv->v.b)) - address of buffer is arg (&foo) (compiler optimizer detects this in most, but not all, cases) - buffer is checked for NULL earlier in func - buffer is accessed in same scope without a NULL check (e.g. b->ptr) internal behavior change: callers must not pass a NULL buffer to some funcs. - buffer_init_buffer() requires non-null args - buffer_copy_buffer() requires non-null args - buffer_append_string_buffer() requires non-null args - buffer_string_space() requires non-null arg
* [core] simplify buffer_path_simplify()Glenn Strauss2021-05-081-1/+1
|
* [mod_webdav] quiet pedantic compiler warningGlenn Strauss2021-04-271-1/+1
|
* [mod_webdav] accept alt syntax in webdav.optsGlenn Strauss2021-04-251-1/+1
|
* [mod_expires,mod_webdav] fix truncated date stringGlenn Strauss2021-04-241-3/+3
| | | | (bug on master branch)
* [mod_webdav] always define webdav_mmap_file_chunkGlenn Strauss2021-04-071-2/+2
| | | | | (previously was defined only if mod_webdav was built with PROPPATCH and/or LOCK support)
* [multiple] more reuse of http_date_time_to_str()Glenn Strauss2021-04-051-10/+8
|
* [mod_webdav] limit mem use under extreme conditionGlenn Strauss2021-04-051-57/+82
| | | | limit memory use under extreme conditions (edge cases)
* [mod_webdav] webdav_log_xml_response()Glenn Strauss2021-04-051-10/+41
| | | | | | | log XML response from chunkqueue instead of taking single buffer (webdav.log-xml = "enable") (prep for future changes)