1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +00:00

fix(console): a VNC console whose access check fails is closed, not left unchecked

novncd checks every 10 seconds that an open VNC console's user may still
open it. An error in that check, such as a locked database, ended the
checking thread and left the session open for good, unchecked: a user
removed from the VM afterwards kept its console. The session now ends
with a warning in the log, as a serial console's worker does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-10 18:58:55 +03:00
parent 16ad625cda
commit 417be11616
2 changed files with 22 additions and 6 deletions

View file

@ -108,13 +108,19 @@ def end_when_refused(instance, user_id, tsock, ended):
"""Close the session's VNC socket, which ends it, once its user may no
longer open the console (as the serial console does)."""
while not ended.wait(ACCESS_CHECK):
if not may_still_open(user_id, instance):
try:
if may_still_open(user_id, instance):
continue
logging.info("VNC console of VM %s closed: its user may no longer open it", instance.name)
try:
tsock.shutdown(socket.SHUT_RDWR)
except OSError:
pass # the session ended meanwhile
return
except Exception as e:
# unchecked, the session would go on whoever loses the VM meanwhile
logging.warning("VNC console of VM %s closed: its user's access could not be checked: %s",
instance.name, safe_text(e))
try:
tsock.shutdown(socket.SHUT_RDWR)
except OSError:
pass # the session ended meanwhile
return
class ConsoleClient: