Commit Graph

15 Commits

Author SHA1 Message Date
d18243c019
main.c: Call form_free instead of repeating code 2023-03-09 02:04:52 +01:00
2e1b131396
Implement public file sharing
An HTML form is now added next to each regular file, that generates a
POST request. Then, slcl replies with a HTML document with a link to the
public resource (which are implemented as symlinks).

Limitations:

- For now, only regular files can be shared i.e., sharing directories is
not possible. While feasible, it still requires a larger refactor to
list_dir and resource_layout, so that read-only access to the directory
is provided to anonymous users.
2023-03-09 02:02:40 +01:00
a4c12e7ccc
Translate whitespace to '+' in append_form
Otherwise, every function calling get_forms must implement this.
2023-03-09 01:17:37 +01:00
f4c16b8e56
main.c: Always append trailing slash to directories
Otherwise, slcl would fail to generate the URLs for the elements inside
a directory, because of how cust_dirname worked, which also turned out
to be redundant.
2023-03-08 18:50:15 +01:00
7176bd3c94
Call page_forbidden on invalid auth 2023-03-08 18:48:58 +01:00
e37a0248e8
Remove(3) f->tmpname from ctx_free
Until now, f->tmpname was removed by move_file when the move
operation succeeded. However, since a HTTP operation can fail before
move_file is called, the temporary file must also be removed.
2023-03-08 18:17:32 +01:00
76664d2006
main.c: Avoid leaking forms 2023-03-08 00:38:03 +01:00
4e1a0484e5
main.c: Print error message only on errno != EEXIST 2023-03-08 00:37:28 +01:00
0ca8ea19bc
main.c: Replace + with whitespace for directories 2023-03-07 12:40:30 +01:00
42c23ec1a5
main.c: Fix memory leak if append_form fails 2023-03-07 12:38:59 +01:00
bd3d2aabc3
main.c: Simplify code a bit 2023-03-07 12:38:32 +01:00
61dc4f42b3
Perform some minor optimizations 2023-03-06 05:51:53 +01:00
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
8bc191d08a
main.c: Simplify failed login response
- Location seems to have no effect on 401 HTTP responses.
- Content-Type is already set by page_failed_login.
2023-03-06 00:56:48 +01:00
d26f046fc9
Initial commit 2023-02-28 01:43:56 +01:00