Compare commits

..

9 Commits

Author SHA1 Message Date
2f1caebaae
README.md: Update according to thumbnail generation 2024-03-01 00:12:38 +01:00
77327e7c2d
Display thumbnails, if available 2024-03-01 00:12:38 +01:00
16ffb6848f
Add thumbnail generation tool
This new application runs separately from slcl and communicates with it
via a named pipe. When files are added/removed to/from the user
directory, slcl shall write to the named pipe.

Then, this new tool shall process incoming entries and generate
or remove thumbnails accordingly. Such thumbnails are stored into a new
directory inside the database directory, namely thumbnails/, which
replicates the same structure as user/.
2024-03-01 00:12:38 +01:00
917c689fd4
main.c: Add -m command line option to open a named pipe
This write-only named pipe is meant to inform other processes about
files that have been added/removed to/from the user/ directory.
The syntax is line-oriented and is described below.

For added files:
+<space ...><path><LF>

For removed files:
-<space ...><path><LF>

Paths shall always be absolute.

Examples:

+ /home/test/db/user/alice/a picture.jpg
- /home/test/db/user/bob/essay.txt

As reported above, this feature has been made completely optional so as
not to introduce breaking changes. A new command line option, namely -m,
is required to enable this feature.
2024-03-01 00:12:38 +01:00
a4c0a7f0e2
auth.c: Make use of crealpath
crealpath already provides a mechanism to determine the current working
directory from getcwd(3).
2024-03-01 00:12:37 +01:00
523bc444ca
Introduce crealpath
crealpath (for "custom realpath") is a custom implementation of
realpath(3) that aims to work similarly to GNU's realpath(1). This
implementation is provided due to the following reasons:

- Future commits will require extracting an absolute path from a
  relative path, and/or process relative components from a path, such as
".." or ".".
- realpath(3) is defined by POSIX.1-2008 as a XSI extension, and
  extensions are generally avoided in this repository whenever possible.
- Additionally, realpath(3) requires the file or directory pointed to by
the path to exist, which might not always be the case for slcl.
- auth.c uses its own implementation to extract a dynamically allocated
string by repeatedly calling getcwd(3). Future commits will also
require this future, so it makes sense to keep it on a separate
component.
2024-03-01 00:12:37 +01:00
b4572c6217
page.c: Do not get filename on previews
This change should provide the same behaviour, but would avoid
unnecessary calls to dynstr_append and basename(3) when a preview is to
be served.
2024-03-01 00:06:03 +01:00
fb8896bccd
README.md: Update dependencies list
- jq is required by usergen.
- Despite being part of a POSIX.1-2008 environment, m4 is not provided
by Debian or Ubuntu by default.
2024-02-24 08:39:25 +01:00
dd29f9096a
usergen: Do not abort on existing directory
Otherwise, it would not be possible to replace user credentials if the
directory already exists.
2024-02-20 21:44:53 +01:00
3 changed files with 12 additions and 12 deletions

View File

@ -62,13 +62,13 @@ to `slcl`. If required, encryption should be done before uploading e.g.: using
#### Mandatory packages
```sh
sudo apt install build-essential libcjson-dev libssl-dev
sudo apt install build-essential libcjson-dev libssl-dev m4 jq
```
#### Optional packages
```sh
sudo apt install cmake xxd jq
sudo apt install cmake
```
## How to use

18
page.c
View File

@ -1370,7 +1370,15 @@ static int serve_file(struct http_response *const r,
dynstr_init(&b);
dynstr_init(&d);
if (dynstr_append(&b, "%s", res))
if (preview)
{
if (dynstr_append(&d, "inline"))
{
fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
goto end;
}
}
else if (dynstr_append(&b, "%s", res))
{
fprintf(stderr, "%s: dynstr_append res failed\n", __func__);
goto end;
@ -1380,14 +1388,6 @@ static int serve_file(struct http_response *const r,
fprintf(stderr, "%s: basename(3) failed\n", __func__);
goto end;
}
else if (preview)
{
if (dynstr_append(&d, "inline"))
{
fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
goto end;
}
}
else if (dynstr_append(&d, "attachment; filename=\"%s\"", bn))
{
fprintf(stderr, "%s: dynstr_append attachment failed\n", __func__);

View File

@ -93,5 +93,5 @@ jq ".users += [
\"quota\": \"$QUOTA\"
}]" "$DB" > $TMP
mkdir "$DIR/user/$USER"
mkdir -p "$DIR/user/$USER"
mv $TMP "$DB"