From e87348abca64596544b2fd8dd33fb843cfe424d1 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 10 Apr 2019 10:44:15 -0700 Subject: [PATCH] Be more strict in console_login Because we use check_screen not assert_screen here, the match can actually fail, but the match_has_tag conditional can pass on the *previous* match, if that happened to also be matching on a console tag. We don't want that. Let's just make these into assert_screens to avoid it; I don't think there's any path where we're actually expecting this to work if those check_screens didn't match. Signed-off-by: Adam Williamson --- lib/utils.pm | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/utils.pm b/lib/utils.pm index 22c18228..82cdd254 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -157,42 +157,40 @@ sub console_login { sleep 2; } - check_screen [$good, 'text_console_login'], $args{timeout}; + assert_screen [$good, 'text_console_login'], $args{timeout}; # if we're already logged in, all is good if (match_has_tag $good) { _console_login_finish(); return; } - # if we see the login prompt, type the username - type_string("$args{user}\n") if (match_has_tag 'text_console_login'); - check_screen [$good, 'console_password_required'], 30; + # otherwise, we saw the login prompt, type the username + type_string("$args{user}\n"); + assert_screen [$good, 'console_password_required'], 30; # on a live image, just the user name will be enough if (match_has_tag $good) { _console_login_finish(); return; } - # otherwise, type the password if we see the prompt - if (match_has_tag 'console_password_required') { + # otherwise, type the password + type_string "$args{password}"; + if (get_var("SWITCHED_LAYOUT") and $args{user} ne "root") { + # see _do_install_and_reboot; when layout is switched + # user password is doubled to contain both US and native + # chars + console_switch_layout; type_string "$args{password}"; - if (get_var("SWITCHED_LAYOUT") and $args{user} ne "root") { - # see _do_install_and_reboot; when layout is switched - # user password is doubled to contain both US and native - # chars - console_switch_layout; - type_string "$args{password}"; - console_switch_layout; - } - send_key "ret"; + console_switch_layout; } + send_key "ret"; # make sure we reached the console unless (check_screen($good, 30)) { # as of 2018-10 we have a bug in sssd which makes this take # unusually long in the FreeIPA tests, let's allow longer, - #with a soft fail - RHBZ #1644919 + # with a soft fail - RHBZ #1644919 record_soft_failure "Console login is taking a long time - #1644919?"; my $timeout = 30; # even an extra 30 secs isn't long enough on aarch64... - $timeout= 90 if (get_var("ARCH") eq "aarch64"); + $timeout = 90 if (get_var("ARCH") eq "aarch64"); assert_screen($good, $timeout); } _console_login_finish();