Commit Graph

18 Commits

Author SHA1 Message Date
Xavier Del Campo Romero f6b84b765d
Bump libweb to 0.3.0
The following commits fix a couple of security issues on libweb.

Because of afe0681c0b26bb64bad55d7e86770f346cfa043e, slcl had to be
updated to set up its struct http_cfg_post.

commit afe0681c0b26bb64bad55d7e86770f346cfa043e
Author: Xavier Del Campo Romero <xavi.dcr@tutanota.com>
Date:   Mon Feb 19 23:00:56 2024 +0100

    Limit maximum multipart/form-data pairs and files

    A malicious user could inject an infinite number of empty files or
    key/value pairs into a request in order to exhaust the device's
    resources.

commit 9d9e0c2979f43297b2ebbf84f14f064f3f9ced0e
Author: Xavier Del Campo Romero <xavi.dcr@tutanota.com>
Date:   Mon Feb 19 22:49:09 2024 +0100

    html.c: Avoid half-init objects on html_node_add_attr

    The previous implementation would leave half-initialised objects if one
    of the calls to strdup(3) failed. Now, n->attrs is only modified when
    all previous memory allocations were successful.
2024-02-19 23:35:08 +01:00
Xavier Del Campo Romero c198199a81
CMakeLists.txt: Bump version to 0.2.0 2024-02-12 23:15:15 +01:00
Xavier Del Campo Romero 69c9f975ba
Bump libweb to 0.2.0 2024-02-12 23:15:14 +01:00
Xavier Del Campo Romero c322356670
CMakeLists.txt: Fix wrong parameters for project
When VERSION is given, LANGUAGES becomes mandatory.
2023-11-23 00:07:45 +01:00
Xavier Del Campo Romero fb6105b1b2
CMakeLists.txt: set project VERSION 2023-10-25 22:13:23 +02:00
Xavier Del Campo Romero b2be8b4658
CMake: Find system libweb or dynstr if available
So far, slcl's build system would always build libweb and dynstr.
However, this is discouraged by distribution packagers.
2023-10-25 13:45:12 +02:00
Xavier Del Campo Romero 1da12097cb
CMakeLists.txt: Fix wrong library name 2023-10-14 13:10:37 +02:00
Xavier Del Campo Romero 28ae865e5e
Apply slweb renaming to libweb 2023-10-11 00:08:40 +02:00
Xavier Del Campo Romero a9d6cdf2e9
CMakeLists.txt: Install targets 2023-09-27 22:13:52 +02:00
Xavier Del Campo Romero b5327b2f7a
Reduce minimum required major version for OpenSSL
slcl has been successfully tested with OpenSSL 2.0 on an OpenBSD 7.3
host.
2023-09-16 00:29:07 +02:00
Xavier Del Campo Romero 0e324e6d77
CMakeLists.txt: Set project language to C
Otherwise, CMake by default tests the system C++ compiler, but this is
not a requirement for slcl.
2023-08-02 13:05:23 +02:00
Xavier Del Campo Romero 6e5c091d8f
Adapt build system to slweb
Now, slweb is a library slcl depends on, which includes the HTTP/1.1
server implementation, as well as other utilities.
2023-07-21 01:40:55 +02:00
Xavier Del Campo Romero e79e955d93
Allow admins to define their own stylesheet
slcl used to provide a hardcoded stylesheet. However, it would be
desirable for some admins to provide a custom stylesheet without having
to rebuild the application.

Now, slcl creates a default stylesheet, namely style.css, into the
target directory, that can be later modified by admins.

While this might contradict the suckless philosophy a bit, hopefully
some admins might find this new feature useful.
2023-07-11 01:49:12 +02:00
Xavier Del Campo Romero d4c8a8062f
Split wildcard_cmp into its own component
Future commits will make use of this function outside handler.c.
2023-06-06 03:48:50 +02:00
Xavier Del Campo Romero ad7fb045ad
Move decode_hex into its own file
- Error detection against strotul(3) has been improved, as done in other
places.
- New function encode_hex has been implemented, which will be used
by future commits.
2023-03-09 01:14:10 +01:00
Xavier Del Campo Romero ff8da797a1
Implement user quota
This feature allows admins to set a specific quota for each user, in
MiB. This feature is particularly useful for shared instances, where
unlimited user storage might be unfeasible or even dangerous for the
server.

Also, a nice HTML5 <progress> element has been added to the site that
shows how much of the quota has been consumed.

If no quota is set, slcl falls back to the default behaviour i.e.,
assume unlimited storage.

Limitations:

- While HTTP does specify a Content-Length, which determines the length
of the whole request, it does not specify how many files are involved
or their individual sizes.
- Because of this, if multiple files are uploaded simultaneously, the
whole request would be dropped if user quota is exceeded, even if not
all files exceeded it.
- Also, Content-Length adds the length of some HTTP boilerplate
(e.g.: boundaries), but slcl must rely on this before accepting the
whole request. In other words, this means some requests might be
rejected by slcl because of the extra bytes caused by such boilerplate.
- When the quota is exceeded, slcl must close the connection so that
the rest of the transfer is cancelled. Unfortunately, this means no
HTML can be sent back to the customer to inform about the situation.
2023-03-06 05:51:49 +01:00
Xavier Del Campo Romero 804b8841f3
Add cftw
POSIX functions ftw(3) and nftw(3) do not allow passing an opaque
pointer to the callback they call, so it forces the use of statically
allocated data.

ctfw (from "custom ftw") is a custom implementation that solves this,
while also removing unneeded stuff.

This function will be used by future commits.
2023-03-06 05:06:30 +01:00
Xavier Del Campo Romero d26f046fc9
Initial commit 2023-02-28 01:43:56 +01:00