mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(instances): a VNC password the browser console can send, kept as set
The console settings accepted any password of at most 8 bytes, so "éééé" was saved, but noVNC derives its key from the characters while QEMU compares the UTF-8 bytes: the browser console could not log in. A new password now takes up to 8 printable ASCII characters, which also keeps control characters out of the definition. The .vv file wrote the password and the VM name as they are; virt-viewer reads it as a GLib key file, so a backslash or a leading space changed the password. Both are escaped as a key file expects. A new or removed password also drops a passwdValidTo set elsewhere: an expired one left the new password unusable.
This commit is contained in:
parent
275bf11aed
commit
cd3edf4dff
11 changed files with 257 additions and 222 deletions
|
|
@ -71,9 +71,10 @@ class CanOpenConsoleTestCase(TestCase):
|
|||
self.owner.user_permissions.add(Permission.objects.get(codename="passwordless_console"))
|
||||
with patch("instances.models.wvmInstance") as wvm:
|
||||
proxy = wvm.return_value.cached_reads.return_value.__enter__.return_value
|
||||
proxy.get_console_passwd.return_value = "secret"
|
||||
proxy.get_console_passwd.return_value = " a\\nb"
|
||||
res = self.client.get(reverse("instances:getvvfile", args=[self.instance.id]))
|
||||
self.assertIn(b"password=secret\n", res.content)
|
||||
# as a key file reads it back: the leading space and the backslash stay
|
||||
self.assertIn(b"password=\\sa\\\\nb\n", res.content)
|
||||
|
||||
def test_owner_can_get_vdi_url(self):
|
||||
self.client.force_login(self.owner)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class UpdateConsoleTestCase(TestCase):
|
|||
proxy.set_console_keymap.assert_not_called()
|
||||
|
||||
def test_the_password_changes_by_the_action_chosen(self):
|
||||
for action, password in (("set", " a b c "), ("set", "éééé"), ("none", "")):
|
||||
for action, password in (("set", " a b c "), ("set", "~a\\b{}!"), ("none", "")):
|
||||
with self.subTest(action, password=password):
|
||||
proxy, _ = self.post({**VNC, "password_action": action, "password": password})
|
||||
proxy.set_console_passwd.assert_called_once_with(password)
|
||||
|
|
@ -62,7 +62,8 @@ class UpdateConsoleTestCase(TestCase):
|
|||
self.assertEqual(len(generated), 8)
|
||||
|
||||
def test_a_password_vnc_cannot_take_is_refused_and_nothing_is_saved(self):
|
||||
for password in ("", "123456789", "ééééé"): # libvirt counts bytes: é is two
|
||||
# the browser console sends the password's characters, QEMU expects its bytes
|
||||
for password in ("", "123456789", "éé", "a\nb", "a\tb"):
|
||||
with self.subTest(password=password):
|
||||
proxy, messages = self.post({**VNC, "keymap": "de", "password_action": "set", "password": password})
|
||||
proxy.set_console_passwd.assert_not_called()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue