aboutsummaryrefslogtreecommitdiff
path: root/usergen
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-03-06 05:09:56 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-03-06 05:51:49 +0100
commitff8da797a143cb1dfbeb4ce2d2c3e4a1d0c2e56a (patch)
treec51bbbd084f531d11ba765186cc5d39709e40ba3 /usergen
parent804b8841f3fe59f7058c91fa25c1694f4433642a (diff)
downloadslcl-ff8da797a143cb1dfbeb4ce2d2c3e4a1d0c2e56a.tar.gz
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.
Diffstat (limited to 'usergen')
-rwxr-xr-xusergen7
1 files changed, 6 insertions, 1 deletions
diff --git a/usergen b/usergen
index 875ef20..ec63fd3 100755
--- a/usergen
+++ b/usergen
@@ -1,9 +1,13 @@
#! /bin/sh
+set -e
+
echo Username: >&2
read -r USER
echo Password: >&2
read -r PWD
+echo "Quota, in MiB (leave empty for unlimited quota):" >&2
+read -r QUOTA
PWD=$(printf '%s' $PWD | xxd -p | tr -d '\n')
SALT=$(openssl rand 32 | xxd -p | tr -d '\n')
@@ -24,6 +28,7 @@ cat <<-EOF
"name": "$USER",
"password": "$PWD",
"salt": "$SALT",
- "key": "$KEY"
+ "key": "$KEY",
+ "quota": "$QUOTA"
}
EOF