mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 20:26:48 +00:00
fix(console): the console daemons hold to what the console page allowed
The token now names the console type it was made for: novncd accepts only a VNC page's token and socketiod only a serial page's, so a VNC page's token no longer opens the serial console without the VNC password. A VNC session re-checks every 10 s, as the serial one did, that its user may still open the console; a deactivated user or a removed owner loses it. The check (may_still_open) moves to console.tokens for both daemons.
This commit is contained in:
parent
f670ee7333
commit
458074df82
10 changed files with 110 additions and 74 deletions
|
|
@ -20,16 +20,13 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webvirtcloud.settings")
|
|||
django.setup()
|
||||
|
||||
import libvirt # noqa: E402
|
||||
from django import db # noqa: E402
|
||||
from django.contrib.auth import get_user_model # noqa: E402
|
||||
|
||||
from instances.models import Instance # noqa: E402
|
||||
from instances.utils import can_open_console # noqa: E402
|
||||
from console.tokens import ACCESS_CHECK, may_still_open # noqa: E402
|
||||
from operations.utils import public_error_text # noqa: E402
|
||||
from vrtManager.connection import connection_manager # noqa: E402
|
||||
|
||||
SEND_WAIT = 5 # seconds a paste may wait for the VM to take it
|
||||
ACCESS_CHECK = 10 # seconds between checks that the user may still use the console
|
||||
|
||||
|
||||
log = logging.getLogger("consolecallback")
|
||||
|
|
@ -112,16 +109,6 @@ def from_vm(stream, events, console):
|
|||
os.write(1, data)
|
||||
|
||||
|
||||
def may_still_open(user_id, instance):
|
||||
"""The user still may open the console: an owner may have been removed or
|
||||
the user deactivated since the session started."""
|
||||
try:
|
||||
user = get_user_model().objects.filter(pk=user_id).first()
|
||||
return user is not None and can_open_console(user, instance)
|
||||
finally:
|
||||
db.connection.close() # a session may last for days: no idle connection meanwhile
|
||||
|
||||
|
||||
def main():
|
||||
# what the operator reads goes to socketiod's log (the journal, docker
|
||||
# logs), on the descriptor it names; the user's terminal gets a short line
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue