Skip to content

Commit

Permalink
Fix the VNC question (#2293672)
Browse files Browse the repository at this point in the history
Looks like that due to being skipped, the VNC question TUI was totally broken:

- It should not be necessary to use secret data locally, only in the DBus
structure. So lets drop that, fixing some places where strings were
mixed up.
- Fix DBus assignment to DBus property.
- Fix vnc_data propagating into the wrong argument in the constructor.

All in all, this really should be coverer by some upstream test. :P

Related: rhbz#2293672
  • Loading branch information
M4rtinK committed Aug 12, 2024
1 parent a21ceb4 commit 5c26978
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
8 changes: 3 additions & 5 deletions pyanaconda/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from pyanaconda.flags import flags
from pyanaconda.modules.common.constants.objects import USER_INTERFACE
from pyanaconda.modules.common.constants.services import NETWORK, RUNTIME
from pyanaconda.modules.common.structures.secret import SecretData
from pyanaconda.modules.common.structures.vnc import VncData
from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke
from pyanaconda.ui.tui import tui_quit_callback
Expand Down Expand Up @@ -134,7 +133,7 @@ def ask_vnc_question(anaconda, vnc_server, message):
log.info("VNC requested via VNC question, switching Anaconda to GUI mode.")
anaconda.display_mode = constants.DisplayModes.GUI
flags.usevnc = True
vnc_server.password = vnc_data.password
vnc_server.password = vnc_data.password.value


def check_vnc_can_be_started(anaconda):
Expand Down Expand Up @@ -305,8 +304,7 @@ def setup_display(anaconda, options):
if not anaconda.gui_mode:
log.info("VNC requested via boot/CLI option, switching Anaconda to GUI mode.")
anaconda.display_mode = constants.DisplayModes.GUI
vnc_server.password = SecretData()
vnc_server.password.value = options.vncpassword
vnc_server.password = options.vncpassword

# Only consider vncconnect when vnc is a param
if options.vncconnect:
Expand All @@ -329,7 +327,7 @@ def setup_display(anaconda, options):
anaconda.display_mode = constants.DisplayModes.GUI

if vnc_server.password == "":
vnc_server.password = vnc_data.password
vnc_server.password = vnc_data.password.value

if vnc_server.vncconnecthost == "":
vnc_server.vncconnecthost = vnc_data.host
Expand Down
13 changes: 6 additions & 7 deletions pyanaconda/ui/tui/spokes/askvnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.modules.common.constants.objects import USER_INTERFACE
from pyanaconda.modules.common.constants.services import RUNTIME
from pyanaconda.modules.common.structures.secret import SecretData
from pyanaconda.modules.common.structures.vnc import VncData
from pyanaconda.ui.tui.spokes import NormalTUISpoke
from pyanaconda.core.constants import USEVNC, USETEXT, QUIT_MESSAGE
Expand Down Expand Up @@ -91,7 +90,7 @@ def refresh(self, args=None):

def _use_vnc_callback(self, data):
self._usevnc = True
new_spoke = VNCPassSpoke(self.data, self.storage, self.payload, self.vnc_data)
new_spoke = VNCPassSpoke(self.data, self.storage, self.payload, vnc_data=self.vnc_data)
ScreenHandler.push_screen_modal(new_spoke)

def _use_text_callback(self, data):
Expand Down Expand Up @@ -119,7 +118,7 @@ def apply(self):
self.vnc_data.enabled = self._usevnc
ui_proxy = RUNTIME.get_proxy(USER_INTERFACE)
struct_vnc = VncData.to_structure(self.vnc_data)
ui_proxy.Vnc(struct_vnc)
ui_proxy.Vnc = struct_vnc


class VNCPassSpoke(NormalTUISpoke):
Expand All @@ -132,7 +131,7 @@ def __init__(self, data, storage, payload, message=None, vnc_data=None):
super().__init__(data, storage, payload)
self.vnc_data = vnc_data
self.title = N_("VNC Password")
self._password = SecretData()
self._password = ""
if message:
self._message = message
else:
Expand Down Expand Up @@ -165,7 +164,7 @@ def prompt(self, args=None):
self._print_error_and_redraw(_("The password cannot be more than "
"eight characters long."))
else:
self._password.value = p1
self._password = p1
self.apply()
self.close()

Expand All @@ -177,7 +176,7 @@ def _print_error_and_redraw(self, msg):
self.redraw()

def apply(self):
self.vnc_data.password = self._password
self.vnc_data.password.set_secret(self._password)
ui_proxy = RUNTIME.get_proxy(USER_INTERFACE)
struct_vnc = VncData.to_structure(self.vnc_data)
ui_proxy.Vnc(struct_vnc)
ui_proxy.Vnc = struct_vnc
13 changes: 6 additions & 7 deletions pyanaconda/vnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from pyanaconda.core.i18n import _, P_
from pyanaconda.modules.common.constants.objects import USER_INTERFACE
from pyanaconda.modules.common.constants.services import RUNTIME
from pyanaconda.modules.common.structures.secret import SecretData
from pyanaconda.modules.common.structures.vnc import VncData
from pyanaconda.ui.tui import tui_quit_callback
from pyanaconda.ui.tui.spokes.askvnc import VNCPassSpoke
Expand Down Expand Up @@ -65,7 +64,7 @@ def shutdownServer():
class VncServer(object):

def __init__(self, root="/", ip=None, name=None,
password=SecretData(), vncconnecthost="",
password="", vncconnecthost="",
vncconnectport="", log_file="/tmp/vncserver.log",
pw_file="/tmp/vncpassword", timeout=constants.X_TIMEOUT):
self.root = root
Expand All @@ -87,7 +86,7 @@ def __init__(self, root="/", ip=None, name=None,

def setVNCPassword(self):
"""Set the vnc server password. Output to file. """
password_string = "%s\n" % self.password.value
password_string = "%s\n" % self.password

# the -f option makes sure vncpasswd does not ask for the password again
proc = util.startProgram(
Expand Down Expand Up @@ -232,10 +231,10 @@ def startServer(self):
util.ipmi_abort(scripts=self.anaconda.ksdata.scripts)
sys.exit(1)

if self.password.value and (len(self.password.value) < 6 or len(self.password.value) > 8):
if self.password and (len(self.password) < 6 or len(self.password) > 8):
self.changeVNCPasswdWindow()

if not self.password.value:
if not self.password:
SecurityTypes = "None"
rfbauth = "0"
else:
Expand Down Expand Up @@ -266,11 +265,11 @@ def startServer(self):
"This does not require a password to be set. If you \n"
"set a password, it will be used in case the connection \n"
"to the vncviewer is unsuccessful\n\n"))
elif self.password.value == "":
elif self.password == "":
self.log.warning(_("\n\nWARNING!!! VNC server running with NO PASSWORD!\n"
"You can use the inst.vncpassword=PASSWORD boot option\n"
"if you would like to secure the server.\n\n"))
elif self.password.value != "":
elif self.password != "":
self.log.warning(_("\n\nYou chose to execute vnc with a password. \n\n"))
else:
self.log.warning(_("\n\nUnknown Error. Aborting. \n\n"))
Expand Down

0 comments on commit 5c26978

Please sign in to comment.