Skip to content

Commit

Permalink
security: handle exception on early anaconda certificate import
Browse files Browse the repository at this point in the history
Present human readable error message.

The case for this fix is missing --dir option.  The option will be
probably made required in pykickstart but we still want to handle
import exceptions in user friendly way.

Related: INSTALLER-4030
Resolves: rhbz#2342245
  • Loading branch information
rvykydal committed Jan 28, 2025
1 parent 4366813 commit 893b962
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pyanaconda/startup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
STORAGE,
TIMEZONE,
)
from pyanaconda.modules.common.errors.installation import SecurityInstallationError
from pyanaconda.modules.common.structures.logging import LoggingData
from pyanaconda.modules.common.structures.timezone import (
GeolocationData,
Expand Down Expand Up @@ -161,9 +162,7 @@ def check_memory(anaconda, options, display_mode=None):
else:
reason += reboot_extra
print(reason % reason_args)
print(_("The installation cannot continue and the system will be rebooted"))
print(_("Press ENTER to continue"))
input()
prompt_for_reboot()

ipmi_report(IPMI_ABORTED)
sys.exit(1)
Expand Down Expand Up @@ -347,6 +346,12 @@ def prompt_for_ssh(options):
return True


def prompt_for_reboot():
print(_("The installation cannot continue and the system will be rebooted"))
print(_("Press ENTER to continue"))
input()


def clean_pstore():
"""Remove files stored in nonvolatile ram created by the pstore subsystem.
Expand Down Expand Up @@ -656,7 +661,16 @@ def initialize_security():
certificates_proxy = SECURITY.get_proxy(CERTIFICATES)
import_task_path = certificates_proxy.ImportWithTask()
task_proxy = SECURITY.get_proxy(import_task_path)
sync_run_task(task_proxy)
try:
sync_run_task(task_proxy)
except SecurityInstallationError as e:
log.error(e)
print(_("\nAn error occurred during certificate import:"
"\n%s\n") % str(e).strip())
prompt_for_reboot()

ipmi_report(IPMI_ABORTED)
sys.exit(1)


def print_dracut_errors(stdout_logger):
Expand Down

0 comments on commit 893b962

Please sign in to comment.