Skip to content

Commit

Permalink
Merge pull request #18437 from Vogtinator/microencrypt
Browse files Browse the repository at this point in the history
Support manual disk unlocking on MicroOS
  • Loading branch information
mloviska authored Jan 12, 2024
2 parents 39a7e0c + 029b14f commit 06c0b3c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/microos.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use Exporter;
use strict;
use warnings;
use testapi;
use utils qw(need_unlock_after_bootloader unlock_if_encrypted);
use version_utils qw(is_microos is_selfinstall is_bootloader_grub2 is_bootloader_sdboot);
use power_action_utils 'power_action';
use Utils::Architectures qw(is_aarch64);
Expand Down Expand Up @@ -48,6 +49,7 @@ sub microos_reboot {
assert_screen 'grub2', 300 if is_bootloader_grub2;
assert_screen 'systemd-boot', 300 if is_bootloader_sdboot;
send_key('ret') unless get_var('KEEP_GRUB_TIMEOUT');
unlock_if_encrypted if need_unlock_after_bootloader;
microos_login;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/opensusebasetest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ sub wait_boot {
reconnect_xen if check_var('VIRSH_VMM_FAMILY', 'xen');

# on s390x svirt encryption is unlocked with unlock_bootloader before here
if (need_passphrase_again) {
if (need_unlock_after_bootloader) {
unlock_if_encrypted unless get_var('S390_ZKVM');
}

Expand Down
19 changes: 12 additions & 7 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use warnings;
use testapi qw(is_serial_terminal :DEFAULT);
use lockapi 'mutex_wait';
use mm_network;
use version_utils qw(is_alp is_sle_micro is_microos is_leap is_leap_micro is_public_cloud is_sle is_sle12_hdd_in_upgrade is_storage_ng is_jeos package_version_cmp is_transactional);
use version_utils qw(is_alp is_sle_micro is_microos is_leap is_leap_micro is_public_cloud is_sle is_sle12_hdd_in_upgrade is_storage_ng is_jeos package_version_cmp is_transactional is_bootloader_sdboot);
use Utils::Architectures;
use Utils::Systemd qw(systemctl disable_and_stop_service);
use Utils::Backends;
Expand Down Expand Up @@ -52,7 +52,7 @@ our @EXPORT = qw(
set_zypper_lock_timeout
unlock_bootloader
is_boot_encrypted
need_passphrase_again
need_unlock_after_bootloader
is_bridged_networking
set_bridged_networking
assert_screen_with_soft_timeout
Expand Down Expand Up @@ -1047,9 +1047,12 @@ sub is_boot_encrypted {
return 1;
}

=head2 need_passphrase_again
=head2 need_unlock_after_bootloader
need_passphrase_again();
need_unlock_after_bootloader();
Whether the disk encryption password(s) need to be entered during system boot
(e.g. plymouth or systemd-cryptsetup text prompt).
With newer grub2 (in TW and SLE15-SP6 currently), if root disk is encrypted and
contains `/boot`, entering the passphrase in GRUB2 is enough. The key is passed
Expand All @@ -1059,9 +1062,11 @@ without LVM configuration (cr_swap,cr_home etc).
=cut

sub need_passphrase_again {
my $need_passphrase_again = is_leap('<15.6') || is_sle('<15-sp6') || is_leap_micro || is_sle_micro || is_alp || (!get_var('LVM', '0') && !get_var('FULL_LVM_ENCRYPT', '0'));
return 0 if is_boot_encrypted && !$need_passphrase_again;
sub need_unlock_after_bootloader {
my $need_unlock_after_bootloader = is_leap('<15.6') || is_sle('<15-sp6') || is_leap_micro || is_sle_micro || is_alp || (!get_var('LVM', '0') && !get_var('FULL_LVM_ENCRYPT', '0'));
return 0 if is_boot_encrypted && !$need_unlock_after_bootloader;
# MicroOS with sdboot supports automatic TPM based unlocking.
return 0 if is_microos && is_bootloader_sdboot && get_var('QEMUTPM');
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/installation/boot_encrypt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use base "installbasetest";
use utils;

sub run {
unlock_if_encrypted(check_typed_password => 1) if need_passphrase_again;
unlock_if_encrypted(check_typed_password => 1) if need_unlock_after_bootloader;
}

1;

0 comments on commit 06c0b3c

Please sign in to comment.