1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(gstfsd): at most 4 connections at a time; one more is told it is busy

Every connection got a thread before any authentication, and every
signed request a guestfs appliance, with no limit: with remote access
allowed, anyone on that network could make the host run out of threads
or memory. A connection over MAX_CLIENTS (4) now gets an unsigned busy
line and is closed before it gets a thread; the panel shows it as the
gstfsd error.
This commit is contained in:
catborise 2026-11-05 18:37:26 +03:00
parent b55def5b27
commit 026110adfb
3 changed files with 50 additions and 1 deletions

View file

@ -1046,7 +1046,10 @@ def gstfsd_request(compute, data):
try:
s.settimeout(GSTFSD_TIMEOUT)
stream = s.makefile("rb")
challenge = json.loads(stream.readline(GSTFSD_MAX_FRAME))["challenge"]
first = json.loads(stream.readline(GSTFSD_MAX_FRAME))
if "error" in first: # busy: gstfsd took no request
raise ValueError(first["error"])
challenge = first["challenge"]
nonce, request = secrets.token_hex(32), json.dumps(data)
s.sendall(json.dumps({"nonce": nonce, "request": request,
"mac": gstfsd_mac(compute.gstfsd_key, "request", challenge, nonce, request)}).encode())