Pass libvirt connection username through to VNC console instead of hardcoding root (Soren Hansen)
This commit is contained in:
parent
b0aaad00cc
commit
037cd2f13c
1
AUTHORS
1
AUTHORS
|
@ -28,6 +28,7 @@ Further patches have been submitted by:
|
|||
Bernhard Kaindl <bk-at-suse-dot-de>
|
||||
Eduardo Habkost <ehabkost-at-redhat-dot-com>
|
||||
Dan Hork <dan-at-danny-dot-cz>
|
||||
Soren Hansen <soren-at-ubuntu-dot-com>
|
||||
|
||||
<...send a patch & get your name here...>
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ class vmmConsole(gobject.GObject):
|
|||
finally:
|
||||
gtk.gdk.threads_leave()
|
||||
|
||||
def open_tunnel(self, server, vncaddr ,vncport):
|
||||
def open_tunnel(self, server, vncaddr, vncport, username):
|
||||
if self.vncTunnel is not None:
|
||||
return
|
||||
|
||||
|
@ -407,7 +407,11 @@ class vmmConsole(gobject.GObject):
|
|||
os.close(1)
|
||||
os.dup(fds[1].fileno())
|
||||
os.dup(fds[1].fileno())
|
||||
os.execlp("ssh", "ssh", "-p", "22", "-l", "root", server, "nc", vncaddr, str(vncport))
|
||||
argv = ["ssh", "ssh", "-p", "22"]
|
||||
if username:
|
||||
argv += ['-l', username]
|
||||
argv += [ server, "nc", vncaddr, str(vncport) ]
|
||||
os.execlp(*argv)
|
||||
os._exit(1)
|
||||
else:
|
||||
fds[1].close()
|
||||
|
@ -433,14 +437,18 @@ class vmmConsole(gobject.GObject):
|
|||
|
||||
logging.debug("Trying console login")
|
||||
password = self.window.get_widget("console-auth-password").get_text()
|
||||
protocol, host, port, trans = self.vm.get_graphics_console()
|
||||
protocol, host, port, trans, username = self.vm.get_graphics_console()
|
||||
|
||||
if protocol is None:
|
||||
logging.debug("No graphics configured in guest")
|
||||
self.activate_unavailable_page(_("Console not configured for guest"))
|
||||
return
|
||||
|
||||
uri = str(protocol) + "://" + str(host) + ":" + str(port)
|
||||
uri = str(protocol) + "://"
|
||||
if username:
|
||||
uri = uri + str(username) + '@'
|
||||
uri = uri + str(host) + ":" + str(port)
|
||||
|
||||
logging.debug("Graphics console configured at " + uri)
|
||||
|
||||
if protocol != "vnc":
|
||||
|
@ -457,7 +465,7 @@ class vmmConsole(gobject.GObject):
|
|||
logging.debug("Starting connect process for %s %s" % (host, str(port)))
|
||||
try:
|
||||
if trans is not None and trans in ("ssh", "ext"):
|
||||
fd = self.open_tunnel(host, "127.0.0.1", port)
|
||||
fd = self.open_tunnel(host, "127.0.0.1", port, username)
|
||||
self.vncViewer.open_fd(fd)
|
||||
else:
|
||||
self.vncViewer.open_host(host, str(port))
|
||||
|
|
|
@ -598,7 +598,7 @@ class vmmCreate(gobject.GObject):
|
|||
if self.config.get_console_popup() == 1:
|
||||
# user has requested console on new created vms only
|
||||
vm = self.connection.get_vm(guest.uuid)
|
||||
(gtype, host, port, transport) = vm.get_graphics_console()
|
||||
(gtype, host, port, transport, username) = vm.get_graphics_console()
|
||||
if gtype == "vnc":
|
||||
self.emit("action-show-console", self.connection.get_uri(), guest.uuid)
|
||||
else:
|
||||
|
|
|
@ -462,9 +462,9 @@ class vmmDomain(gobject.GObject):
|
|||
# reliably resolve 'localhost' into 127.0.0.1, either returning
|
||||
# the public IP, or an IPv6 addr. Neither work since QEMU only
|
||||
# listens on 127.0.0.1 for VNC.
|
||||
return [type, "127.0.0.1", port, None]
|
||||
return [type, "127.0.0.1", port, None, None]
|
||||
else:
|
||||
return [type, self.connection.get_hostname(), port, transport]
|
||||
return [type, self.connection.get_hostname(), port, transport, username]
|
||||
|
||||
|
||||
def get_disk_devices(self):
|
||||
|
|
|
@ -398,7 +398,7 @@ class vmmManager(gobject.GObject):
|
|||
logging.debug("VM %s started" % vm.get_name())
|
||||
if self.config.get_console_popup() == 2 and not vm.is_management_domain():
|
||||
# user has requested consoles on all vms
|
||||
(gtype, host, port, transport) = vm.get_graphics_console()
|
||||
(gtype, host, port, transport, username) = vm.get_graphics_console()
|
||||
if gtype == "vnc":
|
||||
self.emit("action-show-console", uri, vmuuid)
|
||||
elif not connect.is_remote():
|
||||
|
|
Loading…
Reference in New Issue