Re-factor VNC auth protocol handling to allow caller to determine whether a password is needed or not. Go straight to VNC viewer if no auth is needed. Set default button/focus handling.

This commit is contained in:
Daniel P. Berrange 2006-08-28 16:39:22 -04:00
parent fb61284b74
commit a071ab3cae
7 changed files with 182 additions and 136 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-08-22 11:33-0400\n"
"POT-Creation-Date: 2006-08-28 16:17-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -20,50 +20,50 @@ msgstr ""
msgid "Could not connection to session bus, disabling DBus service"
msgstr ""
#: ../../src/virtManager/console.py:166
#: ../../src/virtManager/console.py:168
msgid "Unable to activate console"
msgstr ""
#: ../../src/virtManager/console.py:218
#: ../../src/virtManager/console.py:221
msgid "Save Virtual Machine Screenshot"
msgstr ""
#: ../../src/virtManager/console.py:251
#: ../../src/virtManager/console.py:254
#, python-format
msgid ""
"The screenshot has been saved to:\n"
"%s"
msgstr ""
#: ../../src/virtManager/console.py:252
#: ../../src/virtManager/console.py:255
msgid "Screenshot saved"
msgstr ""
#: ../../src/virtManager/console.py:264 ../../src/virtManager/details.py:167
#: ../../src/virtManager/console.py:267 ../../src/virtManager/details.py:167
msgid "Shutdown requested, but machine is already shutting down / shutoff"
msgstr ""
#: ../../src/virtManager/console.py:272 ../../src/virtManager/details.py:175
#: ../../src/virtManager/console.py:275 ../../src/virtManager/details.py:175
msgid "Pause/resume requested, but machine is shutdown / shutoff"
msgstr ""
#: ../../src/virtManager/console.py:278 ../../src/virtManager/details.py:181
#: ../../src/virtManager/console.py:281 ../../src/virtManager/details.py:181
msgid "Pause requested, but machine is already paused"
msgstr ""
#: ../../src/virtManager/console.py:283 ../../src/virtManager/details.py:186
#: ../../src/virtManager/console.py:286 ../../src/virtManager/details.py:186
msgid "Resume requested, but machine is already running"
msgstr ""
#: ../../src/virtManager/console.py:351
#: ../../src/virtManager/console.py:354
msgid "paused"
msgstr ""
#: ../../src/virtManager/console.py:366
#: ../../src/virtManager/console.py:370
msgid "Couldn't open console: "
msgstr ""
#: ../../src/virtManager/create.py:267
#: ../../src/virtManager/create.py:292
#, python-format
msgid ""
"Congratulations, you have successfully created a new virtual system, <b>\"%s"
@ -72,98 +72,94 @@ msgid ""
"manager."
msgstr ""
#: ../../src/virtManager/create.py:310
msgid "Installs from local CD are not yet supported"
msgstr ""
#: ../../src/virtManager/create.py:315
#: ../../src/virtManager/create.py:336
msgid "Invalid FV media address"
msgstr ""
#: ../../src/virtManager/create.py:322
#: ../../src/virtManager/create.py:343
msgid "Invalid PV media address"
msgstr ""
#: ../../src/virtManager/create.py:328
#: ../../src/virtManager/create.py:349
msgid "Error locating PV install image"
msgstr ""
#: ../../src/virtManager/create.py:334
#: ../../src/virtManager/create.py:355
msgid "Error locating PV kickstart file"
msgstr ""
#: ../../src/virtManager/create.py:342
#: ../../src/virtManager/create.py:363
msgid "Invalid system name"
msgstr ""
#: ../../src/virtManager/create.py:350
#: ../../src/virtManager/create.py:371
msgid "Invalid memory setting"
msgstr ""
#: ../../src/virtManager/create.py:369
#: ../../src/virtManager/create.py:390
msgid "Invalid storage address"
msgstr ""
#: ../../src/virtManager/create.py:385
#: ../../src/virtManager/create.py:406
msgid "Creating Virtual Machine"
msgstr ""
#: ../../src/virtManager/create.py:388
#: ../../src/virtManager/create.py:409
msgid "Guest Install Error"
msgstr ""
#: ../../src/virtManager/create.py:421
#: ../../src/virtManager/create.py:450
msgid "Locate ISO Image"
msgstr ""
#: ../../src/virtManager/create.py:458
#: ../../src/virtManager/create.py:487
msgid "Locate Storage Partition"
msgstr ""
#: ../../src/virtManager/create.py:464
#: ../../src/virtManager/create.py:496
msgid "Locate or Create New Storage File"
msgstr ""
#: ../../src/virtManager/create.py:516
#: ../../src/virtManager/create.py:550
msgid "Invalid System Name"
msgstr ""
#: ../../src/virtManager/create.py:517
#: ../../src/virtManager/create.py:551
msgid ""
"System name must be non-blank, less than 50 characters, and contain no spaces"
msgstr ""
#: ../../src/virtManager/create.py:522
#: ../../src/virtManager/create.py:556
msgid "Hardware Support Required"
msgstr ""
#: ../../src/virtManager/create.py:523
#: ../../src/virtManager/create.py:557
msgid ""
"Your hardware does not appear to support full virtualization. Only "
"paravirtualized guests will be available on this hardware."
msgstr ""
#: ../../src/virtManager/create.py:529
#: ../../src/virtManager/create.py:563
msgid "ISO Location Required"
msgstr ""
#: ../../src/virtManager/create.py:530
#: ../../src/virtManager/create.py:564
msgid "You must specify an ISO location for the guest install image"
msgstr ""
#: ../../src/virtManager/create.py:535
#: ../../src/virtManager/create.py:569
msgid "URL Required"
msgstr ""
#: ../../src/virtManager/create.py:536
#: ../../src/virtManager/create.py:570
msgid "You must specify a URL for the install image for the guest install"
msgstr ""
#: ../../src/virtManager/create.py:541
#: ../../src/virtManager/create.py:575
msgid "Storage Address Required"
msgstr ""
#: ../../src/virtManager/create.py:542
#: ../../src/virtManager/create.py:576
msgid ""
"You must specify a partition or a file for storage for the guest install"
msgstr ""
@ -176,7 +172,7 @@ msgstr ""
msgid "Paused"
msgstr ""
#: ../../src/virtManager/domain.py:257 tmp/virt-manager.glade.h:139
#: ../../src/virtManager/domain.py:257 tmp/virt-manager.glade.h:138
msgid "Shutdown"
msgstr ""
@ -244,7 +240,7 @@ msgstr ""
msgid "Name"
msgstr ""
#: ../../src/virtManager/manager.py:293 tmp/virt-manager.glade.h:142
#: ../../src/virtManager/manager.py:293 tmp/virt-manager.glade.h:141
msgid "Status"
msgstr ""
@ -776,206 +772,204 @@ msgid ""
msgstr ""
#: tmp/virt-manager.glade.h:123
msgid ""
"Please insert disc 1 of the installation media for the desired operating "
"system now."
msgstr ""
#: tmp/virt-manager.glade.h:124
msgid "Please wait..."
msgstr ""
#: tmp/virt-manager.glade.h:125
#: tmp/virt-manager.glade.h:124
msgid "Port:"
msgstr ""
#: tmp/virt-manager.glade.h:126
#: tmp/virt-manager.glade.h:125
msgid "Processor"
msgstr ""
#: tmp/virt-manager.glade.h:127
#: tmp/virt-manager.glade.h:126
msgid "Randomly generated MAC address"
msgstr ""
#: tmp/virt-manager.glade.h:128
#: tmp/virt-manager.glade.h:127
msgid "Read only connection"
msgstr ""
#: tmp/virt-manager.glade.h:129
#: tmp/virt-manager.glade.h:128
msgid "Remote Xen host"
msgstr ""
#: tmp/virt-manager.glade.h:130
#: tmp/virt-manager.glade.h:129
msgid "Restore a saved machine from a filesystem image"
msgstr ""
#: tmp/virt-manager.glade.h:131
#: tmp/virt-manager.glade.h:130
msgid "Restore saved machine..."
msgstr ""
#: tmp/virt-manager.glade.h:132
#: tmp/virt-manager.glade.h:131
msgid "Run"
msgstr ""
#: tmp/virt-manager.glade.h:133
#: tmp/virt-manager.glade.h:132
msgid "Save Domain"
msgstr ""
#: tmp/virt-manager.glade.h:134
#: tmp/virt-manager.glade.h:133
msgid "Save domain"
msgstr ""
#: tmp/virt-manager.glade.h:135
#: tmp/virt-manager.glade.h:134
msgid "Save this password in your keyring"
msgstr ""
#: tmp/virt-manager.glade.h:136
#: tmp/virt-manager.glade.h:135
msgid "Saving VM Image"
msgstr ""
#: tmp/virt-manager.glade.h:137
#: tmp/virt-manager.glade.h:136
msgid "Screenshot"
msgstr ""
#: tmp/virt-manager.glade.h:138
#: tmp/virt-manager.glade.h:137
msgid "Shut down"
msgstr ""
#: tmp/virt-manager.glade.h:140
#: tmp/virt-manager.glade.h:139
msgid "Simple _File:"
msgstr ""
#: tmp/virt-manager.glade.h:141
#: tmp/virt-manager.glade.h:140
msgid "Specified MAC address:"
msgstr ""
#: tmp/virt-manager.glade.h:143
#: tmp/virt-manager.glade.h:142
msgid "Status:"
msgstr ""
#: tmp/virt-manager.glade.h:144
#: tmp/virt-manager.glade.h:143
msgid "System _Name:"
msgstr ""
#: tmp/virt-manager.glade.h:145
#: tmp/virt-manager.glade.h:144
msgid "Take screenshot"
msgstr ""
#: tmp/virt-manager.glade.h:146
#: tmp/virt-manager.glade.h:145
msgid ""
"The <b>location</b> of the files necessary for installing an operating "
"system on the virtual system"
msgstr ""
#: tmp/virt-manager.glade.h:147
#: tmp/virt-manager.glade.h:146
msgid ""
"This assistant will guide you through creating a new virtual system. You "
"will be asked for some information about the virtual system you'd like to "
"create, such as:"
msgstr ""
#: tmp/virt-manager.glade.h:148
#: tmp/virt-manager.glade.h:147
msgid "Total memory on host machine:"
msgstr ""
#: tmp/virt-manager.glade.h:149
#: tmp/virt-manager.glade.h:148
msgid "URI:"
msgstr ""
#: tmp/virt-manager.glade.h:150
#: tmp/virt-manager.glade.h:149
msgid "UUID:"
msgstr ""
#: tmp/virt-manager.glade.h:151
#: tmp/virt-manager.glade.h:150
msgid "Unavailable"
msgstr ""
#: tmp/virt-manager.glade.h:152
#: tmp/virt-manager.glade.h:151
msgid "Update status every"
msgstr ""
#: tmp/virt-manager.glade.h:153
#: tmp/virt-manager.glade.h:152
msgid "Virtual CPUs"
msgstr ""
#: tmp/virt-manager.glade.h:154
#: tmp/virt-manager.glade.h:153
msgid "Virtual Machine Console"
msgstr ""
#: tmp/virt-manager.glade.h:155
#: tmp/virt-manager.glade.h:154
msgid "Virtual Machine Details"
msgstr ""
#: tmp/virt-manager.glade.h:156
#: tmp/virt-manager.glade.h:155
msgid "Virtual Machine Manager"
msgstr ""
#: tmp/virt-manager.glade.h:157
#: tmp/virt-manager.glade.h:156
msgid "Virtual Machine Manager Preferences"
msgstr ""
#: tmp/virt-manager.glade.h:158
#: tmp/virt-manager.glade.h:157
msgid "Virtual _Machine"
msgstr ""
#: tmp/virt-manager.glade.h:159
#: tmp/virt-manager.glade.h:158
msgid "What is the maximum amount of memory this VM should be able to use?"
msgstr ""
#: tmp/virt-manager.glade.h:160
#: tmp/virt-manager.glade.h:159
msgid ""
"Whether the system will be <b>fully virtualized</b> or <b>para-virtualized</"
"b>"
msgstr ""
#: tmp/virt-manager.glade.h:161
#: tmp/virt-manager.glade.h:160
msgid "You will need to choose a virtualization method for your new system:"
msgstr ""
#: tmp/virt-manager.glade.h:162
#: tmp/virt-manager.glade.h:161
msgid "_Browse..."
msgstr ""
#: tmp/virt-manager.glade.h:163
#: tmp/virt-manager.glade.h:162
msgid "_CD-ROM or DVD:"
msgstr ""
#: tmp/virt-manager.glade.h:164
#: tmp/virt-manager.glade.h:163
msgid "_Details"
msgstr ""
#: tmp/virt-manager.glade.h:165
#: tmp/virt-manager.glade.h:164
msgid "_Edit"
msgstr ""
#: tmp/virt-manager.glade.h:166
#: tmp/virt-manager.glade.h:165
msgid "_File"
msgstr ""
#: tmp/virt-manager.glade.h:167
#: tmp/virt-manager.glade.h:166
msgid "_Finish"
msgstr ""
#: tmp/virt-manager.glade.h:168
#: tmp/virt-manager.glade.h:167
msgid "_Fully Virtualized:"
msgstr ""
#: tmp/virt-manager.glade.h:169
#: tmp/virt-manager.glade.h:168
msgid "_Help"
msgstr ""
#: tmp/virt-manager.glade.h:170
#: tmp/virt-manager.glade.h:169
msgid "_ISO Image Location:"
msgstr ""
#: tmp/virt-manager.glade.h:171
#: tmp/virt-manager.glade.h:170
msgid "_Mount Point (on virtual system):"
msgstr ""
#: tmp/virt-manager.glade.h:172
#: tmp/virt-manager.glade.h:171
msgid "_Paravirtualized:"
msgstr ""
#: tmp/virt-manager.glade.h:172
msgid "_Path to install media:"
msgstr ""
#: tmp/virt-manager.glade.h:173
msgid "_Pause"
msgstr ""

View File

@ -39,6 +39,8 @@ class vmmConnect(gobject.GObject):
# Not securely implemented yet by XenD, so disable it
self.window.get_widget("type-remote-xen").set_sensitive(False)
self.window.get_widget("connect").grab_default()
self.window.signal_autoconnect({
"on_type_local_xen_toggled": self.change_active_type,
"on_type_remote_xen_toggled": self.change_active_type,

View File

@ -124,7 +124,7 @@ class vmmConsole(gobject.GObject):
if vncHeight > (rootHeight-200):
vncHeight = rootHeight - 200
vp.set_size_request(vncWidth+3, vncHeight+3)
vp.set_size_request(vncWidth+2, vncHeight+2)
def show(self):
@ -132,6 +132,8 @@ class vmmConsole(gobject.GObject):
dialog.show_all()
dialog.present()
self.try_login()
def close(self,ignore1=None,ignore2=None):
self.window.get_widget("vmm-console").hide()
if self.vncViewer.is_connected():
@ -166,9 +168,10 @@ class vmmConsole(gobject.GObject):
print _("Unable to activate console") + " " + str((sys.exc_info())[0]) + " " + str((sys.exc_info())[1])
self.activate_unavailable_page()
return
if self.vncViewer.is_authenticated():
self.activate_viewer_page()
elif password:
elif password or not(self.vncViewer.needs_password()):
if self.vncViewer.authenticate(password) == 1:
if self.window.get_widget("console-auth-remember").get_active():
self.config.set_console_password(self.vm, password)
@ -211,6 +214,7 @@ class vmmConsole(gobject.GObject):
def activate_viewer_page(self):
self.window.get_widget("console-pages").set_current_page(3)
self.window.get_widget("control-screenshot").set_sensitive(True)
self.vncViewer.grab_focus()
def control_vm_screenshot(self, src):
# If someone feels kind they could extend this code to allow
@ -359,12 +363,15 @@ class vmmConsole(gobject.GObject):
self.activate_screenshot_page()
else:
self.activate_unavailable_page()
else:
elif self.vncViewer.is_connected():
self.try_login()
try:
self.try_login()
except:
print _("Couldn't open console: ") + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
self.ignorePause = False
else:
self.activate_unavailable_page()
self.ignorePause = False
gobject.type_register(vmmConsole)

View File

@ -88,6 +88,8 @@ class vmmDetails(gobject.GObject):
self.window.get_widget("hw-list").append_column(hwCol)
self.window.get_widget("close-details").grab_focus()
self.window.get_widget("close-details").grab_focus()
self.cpu_usage_graph = sparkline.Sparkline()
self.cpu_usage_graph.show()

View File

@ -41,10 +41,6 @@ class vmmRemote(dbus.service.Object):
def show_domain_console(self, uri, uuid):
self.engine.show_console(uri, uuid)
@dbus.service.method("com.redhat.virt.manager", in_signature="ss")
def show_domain_serial_console(self, uri, uuid):
self.engine.show_serial_console(uri, uuid)
@dbus.service.method("com.redhat.virt.manager", in_signature="s")
def show_host_summary(self, uri):
self.engine.show_manager(uri)

View File

@ -54,6 +54,18 @@ ENCODING_CURSOR_POS = -232
ENCODING_RICH_CURSOR = -239
ENCODING_XCURSOR = -240
AUTH_INVALID = 0
AUTH_NONE = 1
AUTH_VNCAUTH = 2
AUTH_RA2 = 5
AUTH_RA2NE = 6
AUTH_TIGHT = 16
AUTH_ULTRA = 17
AUTH_TLS = 18
AUTH_VALID = [ AUTH_NONE, AUTH_VNCAUTH, AUTH_RA2, AUTH_RA2NE, AUTH_TIGHT, AUTH_ULTRA, AUTH_TLS ]
AUTH_SUPPORTED = [ AUTH_NONE, AUTH_VNCAUTH ]
## RFBFrameBuffer
##
class RFBFrameBuffer:
@ -155,11 +167,42 @@ class RFBProxy:
self.send('RFB 003.%03d\x0a' % self.protocol_version)
if self.debug:
print >>stderr, 'protocol_version: 3.%d' % self.protocol_version
return self
self.auth_types = []
if self.protocol_version == 3:
# protocol 3.3 (or 3.6)
# recv: server security
(server_security,) = unpack('>L', self.recv(4))
if self.debug:
print >>stderr, 'server_security: %r' % server_security
# server_security might be 0, 1 or 2.
if int(server_security) == 0:
(reason_length,) = unpack('>L', self.recv(4))
reason = self.recv(reason_length)
raise RFBAuthError('Auth Error: %s' % reason)
elif int(server_security) in AUTH_VALID:
self.auth_types = [ server_security ]
else:
raise "illegal auth type %d" % server_security
elif self.protocol_version >= 7:
(nsecurities,) = unpack('>B', self.recv(1))
server_securities = self.recv(nsecurities)
if self.debug:
print >>stderr, 'server_securities: %r' % server_securities
for type in server_securities:
if ord(type) in AUTH_SUPPORTED:
self.auth_types.append(ord(type))
if len(self.auth_types) == 0:
raise "no valid auth types in " + str(server_securities)
return self.auth_types
def getpass(self):
raise NotImplementedError
def auth(self):
# vnc challange & response auth
@ -182,40 +225,23 @@ class RFBProxy:
server_result = 0
if self.protocol_version == 3:
# protocol 3.3 (or 3.6)
# recv: server security
(server_security,) = unpack('>L', self.recv(4))
if self.debug:
print >>stderr, 'server_security: %r' % server_security
# server_security might be 0, 1 or 2.
if server_security == 0:
(reason_length,) = unpack('>L', self.recv(4))
reason = self.recv(reason_length)
raise RFBAuthError('Auth Error: %s' % reason)
elif server_security == 1:
pass
else:
if AUTH_NONE in self.auth_types:
server_result = 0
elif AUTH_VNCAUTH in self.auth_types:
server_result = crauth()
else:
# protocol 3.7 or 3.8
# recv: multiple server securities
(nsecurities,) = unpack('>B', self.recv(1))
server_securities = self.recv(nsecurities)
if self.debug:
print >>stderr, 'server_securities: %r' % server_securities
# must include None or VNCAuth
if '\x01' in server_securities:
# None
elif self.protocol_version >= 7:
if AUTH_NONE in self.auth_types:
self.send('\x01')
if self.protocol_version == 8:
# Protocol 3.8: must recv security result
(server_result,) = unpack('>L', self.recv(4))
else:
server_result = 0
elif '\x02' in server_securities:
# VNCAuth
elif AUTH_VNCAUTH in self.auth_types:
self.send('\x02')
server_result = crauth()
else:
raise "no supported auth types"
# result returned.
if self.debug:
print >>stderr, 'server_result: %r' % server_result
@ -227,12 +253,13 @@ class RFBProxy:
else:
reason = server_result
raise RFBAuthError('Auth Error: %s' % reason)
# negotiation ok.
# send: always shared.
self.send('\x01')
return self
def start(self):
def start(self, shared=True):
if shared:
self.send('\x01')
else:
self.send('\x00')
# server info.
server_init = self.recv(24)
(width, height, pixelformat, namelen) = unpack('>HH16sL', server_init)
@ -492,8 +519,7 @@ class RFBNetworkClient(RFBProxy):
def init(self):
self.sock.connect((self.host, self.port))
x = RFBProxy.init(self)
return x
return RFBProxy.init(self)
def recv(self, n):
# MS-Windows doesn't have MSG_WAITALL, so we emulate it.

View File

@ -103,7 +103,7 @@ class GRFBNetworkClient(rfb.RFBNetworkClient, gobject.GObject):
self.password = None
def init(self):
rfb.RFBNetworkClient.init(self)
return rfb.RFBNetworkClient.init(self)
def start(self):
rfb.RFBNetworkClient.start(self)
@ -156,6 +156,7 @@ class GRFBViewer(gtk.DrawingArea):
self.fb = GRFBFrameBuffer(self)
self.client = None
self.authenticated = False
self.needpw = True
self.fb.connect("resize", self.resize_display)
self.fb.connect("invalidate", self.repaint_region)
@ -191,12 +192,17 @@ class GRFBViewer(gtk.DrawingArea):
client = GRFBNetworkClient(host, port, self.fb)
client.connect("disconnected", self._client_disconnected)
client.init()
auth_types = client.init()
# NB we delibrately dont assign to self.client until
# we're successfully connected.
self.client = client
self.authenticated = False
self.emit("connected", host, port)
if rfb.AUTH_NONE in auth_types:
self.needpw = False
else:
self.needpw = True
def _client_disconnected(self, src):
self.client = None
@ -216,12 +222,16 @@ class GRFBViewer(gtk.DrawingArea):
self.client.auth()
except:
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
self.disconnect_from_host()
return 0
self.authenticated = True
self.emit("authenticated")
return 1
def activate(self):
if self.client == None:
return
self.client.start()
self.client.request_update()
self.emit("activated")
@ -231,6 +241,9 @@ class GRFBViewer(gtk.DrawingArea):
return False
return self.authenticated
def needs_password(self):
return self.needpw
def is_connected(self):
if self.client == None:
return False
@ -294,7 +307,9 @@ gobject.type_register(GRFBViewer)
def main():
host = sys.argv[1]
port = int(sys.argv[2])
password = sys.argv[3]
password = None
if len(sys.argv) == 4:
password = sys.argv[3]
win = gtk.Window()
win.set_name("VNC")
@ -313,9 +328,13 @@ def main():
win.show_all()
win.present()
vnc.connect_to_host(host, port)
if vnc.connect_to_host(host, port):
print "Need password"
else:
print "No password needed"
vnc.authenticate(password)
vnc.activate()
win.set_title(vnc.get_framebuffer_name())
def autosize():