diff options
author | Simon Rettberg | 2022-11-03 14:42:47 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-11-03 14:42:47 +0100 |
commit | 2d4a804311346ba874cbf8e172fcfb094ae47c29 (patch) | |
tree | d5717a8e8530de441f9a07e110d4e63a8701cb2f /dozentenmodulserver | |
parent | [server] Use mariadb class name (diff) | |
download | tutor-module-2d4a804311346ba874cbf8e172fcfb094ae47c29.tar.gz tutor-module-2d4a804311346ba874cbf8e172fcfb094ae47c29.tar.xz tutor-module-2d4a804311346ba874cbf8e172fcfb094ae47c29.zip |
[server] Honor vmSizeLimit and reject uploads that exceed it
Diffstat (limited to 'dozentenmodulserver')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java | 4 | ||||
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java index ea450717..001e8566 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java @@ -87,6 +87,10 @@ public class RuntimeConfig { return cache.get().getMaxLocationsPerLecture(); } + public static long getVmSizeLimit() { + return cache.get().vmSizeLimit; + } + /** * How long a version that is not the latest version of an image will be * kept. diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java index 8382390a..7763f7fc 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java @@ -113,6 +113,8 @@ public class ServerHandler implements SatelliteServer.Iface { UserInfo user = SessionManager.getOrFail(userToken); if (!FileSystem.waitForStorage()) throw new TInvocationException(InvocationError.INTERNAL_SERVER_ERROR, "VM storage not mounted"); + if (RuntimeConfig.getVmSizeLimit() > 0 && RuntimeConfig.getVmSizeLimit() < fileSize) + throw new TTransferRejectedException("VM HDD size exceeds limit of " + RuntimeConfig.getVmSizeLimit() + " bytes"); User.canEditBaseImageOrFail(user, imageBaseId); ImageDetailsRead image; try { |