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 <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2019-04-10 10:44:15 -07:00
parent a0a8e3350d
commit e87348abca

View File

@ -157,22 +157,21 @@ sub console_login {
sleep 2; 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 we're already logged in, all is good
if (match_has_tag $good) { if (match_has_tag $good) {
_console_login_finish(); _console_login_finish();
return; return;
} }
# if we see the login prompt, type the username # otherwise, we saw the login prompt, type the username
type_string("$args{user}\n") if (match_has_tag 'text_console_login'); type_string("$args{user}\n");
check_screen [$good, 'console_password_required'], 30; assert_screen [$good, 'console_password_required'], 30;
# on a live image, just the user name will be enough # on a live image, just the user name will be enough
if (match_has_tag $good) { if (match_has_tag $good) {
_console_login_finish(); _console_login_finish();
return; return;
} }
# otherwise, type the password if we see the prompt # otherwise, type the password
if (match_has_tag 'console_password_required') {
type_string "$args{password}"; type_string "$args{password}";
if (get_var("SWITCHED_LAYOUT") and $args{user} ne "root") { if (get_var("SWITCHED_LAYOUT") and $args{user} ne "root") {
# see _do_install_and_reboot; when layout is switched # see _do_install_and_reboot; when layout is switched
@ -183,7 +182,6 @@ sub console_login {
console_switch_layout; console_switch_layout;
} }
send_key "ret"; send_key "ret";
}
# make sure we reached the console # make sure we reached the console
unless (check_screen($good, 30)) { unless (check_screen($good, 30)) {
# as of 2018-10 we have a bug in sssd which makes this take # as of 2018-10 we have a bug in sssd which makes this take