From a21ceb4e2b3f6795a9fb7fe2702bc27eb3216a8e Mon Sep 17 00:00:00 2001 From: Martin Kolman Date: Wed, 31 Jul 2024 14:30:38 +0200 Subject: [PATCH] Check if text mode was actually requested by kickstart (#2293672) Provide information about text mode being requested via DBus property set at kickstart parsing time & check this property when deciding if the VNC question should be shown. Also cleanup the code a bit and fix a typo affecting vnc command parsing. Resolves: rhbz#2293672 --- pyanaconda/display.py | 23 +++++++++++------- .../modules/runtime/user_interface/ui.py | 24 +++++++++++++++++++ .../runtime/user_interface/ui_interface.py | 5 ++++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/pyanaconda/display.py b/pyanaconda/display.py index 8db108e9232..67488db92f6 100644 --- a/pyanaconda/display.py +++ b/pyanaconda/display.py @@ -155,15 +155,20 @@ def check_vnc_can_be_started(anaconda): (blivet.util.total_memory(), min_gui_ram)) vnc_startup_possible = False - # disable VNC question if text mode is requested and this is a ks install - if anaconda.tui_mode and flags.automatedInstall: - error_messages.append("Not asking for VNC because of an automated install") - vnc_startup_possible = False - - # disable VNC question if we were explicitly asked for text in kickstart - if anaconda.display_mode == constants.DisplayModes.TUI: - error_messages.append("Not asking for VNC because text mode was explicitly asked for in kickstart") - vnc_startup_possible = False + # if running in text mode, we might sometimes skip showing the VNC question + if anaconda.tui_mode: + # disable VNC question if we were explicitly asked for text mode in kickstart + ui_proxy = RUNTIME.get_proxy(USER_INTERFACE) + if ui_proxy.DisplayModeTextKickstarted: + error_messages.append( + "Not asking for VNC because text mode was explicitly asked for in kickstart" + ) + vnc_startup_possible = False + # disable VNC question if text mode is requested and this is an automated kickstart + # installation + elif flags.automatedInstall: + error_messages.append("Not asking for VNC because of an automated install") + vnc_startup_possible = False # disable VNC question if we don't have network network_proxy = NETWORK.get_proxy() diff --git a/pyanaconda/modules/runtime/user_interface/ui.py b/pyanaconda/modules/runtime/user_interface/ui.py index d5666ccf97e..82da6a31a58 100644 --- a/pyanaconda/modules/runtime/user_interface/ui.py +++ b/pyanaconda/modules/runtime/user_interface/ui.py @@ -29,6 +29,8 @@ from pyanaconda.modules.common.constants.objects import USER_INTERFACE from pyanaconda.modules.common.structures.policy import PasswordPolicy +from pykickstart.commands.displaymode import DISPLAY_MODE_TEXT + log = get_module_logger(__name__) __all__ = ["UIModule"] @@ -48,6 +50,9 @@ def __init__(self): self.display_mode_nonInteractive_changed = Signal() self._displayMode_nonInteractive = False + self.display_mode_text_kickstarted_changed = Signal() + self._display_mode_text_kickstarted = False + self.vnc_changed = Signal() self._vnc = VncData() @@ -59,6 +64,12 @@ def process_kickstart(self, data): """Process the kickstart data.""" self.set_display_mode(data.displaymode.displayMode) self.set_display_mode_non_interactive(data.displaymode.nonInteractive) + # check if text mode was requested in kickstart + if data.displaymode.displayMode == DISPLAY_MODE_TEXT: + log.debug("Text mode requested by kickstart") + self._display_mode_text_kickstarted = True + self.display_mode_text_kickstarted_changed.emit() + vnc = VncData() vnc.enabled = data.vnc.enabled vnc.host = data.vnc.host @@ -113,6 +124,19 @@ def set_display_mode_non_interactive(self, non_interactive): self.display_mode_nonInteractive_changed.emit() log.debug("Display mode non-interactive set to: %s", str(non_interactive)) + @property + def display_mode_text_kickstarted(self): + """Report if text mode was explicitely requested via kickstart. + + + #NOTE: No setter as this is only set once when parsing the kickstasrt. + + :return: if text mode was requested by kickstart + :rtype: bool + """ + + return self._display_mode_text_kickstarted + @property def vnc(self): """The VncData. diff --git a/pyanaconda/modules/runtime/user_interface/ui_interface.py b/pyanaconda/modules/runtime/user_interface/ui_interface.py index 77196d5d50c..935eb00e4ec 100644 --- a/pyanaconda/modules/runtime/user_interface/ui_interface.py +++ b/pyanaconda/modules/runtime/user_interface/ui_interface.py @@ -101,6 +101,11 @@ def DisplayModeNonInteractive(self, non_interactive: Bool): """ self.implementation.set_display_mode_non_interactive(non_interactive) + @property + def DisplayModeTextKickstarted(self) -> Bool: + """Report if text mode was explicitly requested via kickstart.""" + return self.implementation.display_mode_text_kickstarted + @property def Vnc(self) -> Structure: """Specification of the vnc configuration."""