From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id A92891FF0C0 for ; Wed, 18 Nov 2026 00:45:13 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 09487217E5; Wed, 18 Nov 2026 00:43:50 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH installer 4/5] ui: offer full-disk encryption in the graphical and terminal installer Date: Wed, 18 Nov 2026 00:42:28 +0100 Message-ID: <20261117234330.801935-6-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261117234330.801935-1-t.lamprecht@proxmox.com> References: <20261117234330.801935-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794959018518 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.192 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: OARFMTNAFNHZJIOQSYSPQIAUOSK4AMPX X-Message-ID-Hash: OARFMTNAFNHZJIOQSYSPQIAUOSK4AMPX X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The disk options of both installers gain an encryption option, as long as the installer was booted in UEFI mode. The passphrase itself is asked on the password page, which comes after the keyboard layout was chosen, so that it is typed with the same layout the boot prompt uses. Both apply the installer's passphrase rules there, and the help of the graphical installer notes that the passphrase is needed at every boot. Their disk pages already refuse more than 2 ZFS copies with encryption. As the option sits in a dialog, their disk pages show when encryption is enabled, and their summaries show the resulting encryption. Signed-off-by: Thomas Lamprecht --- html/ack_template.htm | 2 + html/pbs/passwd.htm | 1 + html/pdm/passwd.htm | 1 + html/pmg/passwd.htm | 1 + html/pve/passwd.htm | 1 + proxinstall | 99 ++++++++++++++++++++- proxmox-installer-common/src/options.rs | 3 + proxmox-tui-installer/src/main.rs | 68 ++++++++++++-- proxmox-tui-installer/src/options.rs | 19 +++- proxmox-tui-installer/src/setup.rs | 8 +- proxmox-tui-installer/src/views/bootdisk.rs | 49 ++++++++-- proxmox-tui-installer/src/views/mod.rs | 6 ++ 12 files changed, 242 insertions(+), 16 deletions(-) diff --git a/html/ack_template.htm b/html/ack_template.htm index 48d7213a..3c11f2c8 100644 --- a/html/ack_template.htm +++ b/html/ack_template.htm @@ -44,6 +44,8 @@ Disk(s): __target_hd__ + Disk Encryption: __encryption__ + Country: __country__ Timezone: __timezone__ diff --git a/html/pbs/passwd.htm b/html/pbs/passwd.htm index 52a50157..3b535676 100644 --- a/html/pbs/passwd.htm +++ b/html/pbs/passwd.htm @@ -37,6 +37,7 @@

+ __DISK_PASSPHRASE_HELP__

diff --git a/html/pdm/passwd.htm b/html/pdm/passwd.htm index 52a50157..3b535676 100644 --- a/html/pdm/passwd.htm +++ b/html/pdm/passwd.htm @@ -37,6 +37,7 @@

+ __DISK_PASSPHRASE_HELP__

diff --git a/html/pmg/passwd.htm b/html/pmg/passwd.htm index 52a50157..3b535676 100644 --- a/html/pmg/passwd.htm +++ b/html/pmg/passwd.htm @@ -37,6 +37,7 @@

+ __DISK_PASSPHRASE_HELP__

diff --git a/html/pve/passwd.htm b/html/pve/passwd.htm index efd4e5f5..32460cfe 100644 --- a/html/pve/passwd.htm +++ b/html/pve/passwd.htm @@ -38,6 +38,7 @@

+ __DISK_PASSPHRASE_HELP__

diff --git a/proxinstall b/proxinstall index ea80dd24..e66c4e78 100755 --- a/proxinstall +++ b/proxinstall @@ -1095,6 +1095,11 @@ sub create_ipconf_view { $hostentry->grab_focus(); } +my sub encryption_desc { + my $mode = Proxmox::Install::Config::get_encryption_mode() // return 'none'; + return $mode eq 'zfs-native' ? 'native ZFS encryption' : 'LUKS2'; +} + sub create_ack_view { cleanup_view(); @@ -1152,6 +1157,7 @@ sub create_ack_view { my %config_values = ( __target_hd__ => join(' | ', $target_hds->@*), __target_fs__ => Proxmox::Install::Config::get_filesys(), + __encryption__ => encryption_desc(), __country__ => $iso_env->{locales}->{country}->{$country}->{name}, __timezone__ => Proxmox::Install::Config::get_timezone(), __keymap__ => Proxmox::Install::Config::get_keymap(), @@ -1346,9 +1352,47 @@ sub create_password_view { $eme->set_margin_top(10); $grid->attach($eme, 1, 2, 1, 1); + # asked here, so that it is typed with the keyboard layout the boot prompt uses + my $enc = Proxmox::Install::Config::get_encryption(); + my ($epe1, $epe2); + if (defined($enc)) { + for my $field (['Disk passphrase', \$epe1, 3], ['Confirm', \$epe2, 4]) { + my ($text, $entry_ref, $grid_row) = @$field; + my $elabel = Gtk3::Label->new($text); + $elabel->set_size_request(150, -1); + $elabel->set_xalign(1.0); + $grid->attach($elabel, 0, $grid_row, 1, 1); + my $entry = Gtk3::Entry->new(); + $entry->set_visibility(0); + $entry->set_text($enc->{passphrase}) if defined($enc->{passphrase}); + $entry->set_size_request(200, -1); + $grid->attach($entry, 1, $grid_row, 1, 1); + + if ($grid_row == 3) { + $elabel->set_margin_top(10); + $entry->set_margin_top(10); + } + $$entry_ref = $entry; + } + } + $gtk_state->{inbox}->show_all; - Proxmox::UI::display_html('passwd.htm'); + my $passphrase_help = ''; + if (defined($enc)) { + $passphrase_help = + '' + . 'Disk passphrase: Needed at every boot to unlock the system.' + . ' Store it safely, as the data cannot be recovered without it.'; + } + Proxmox::UI::display_html( + 'passwd.htm', + sub { + my ($html) = @_; + $html =~ s/__DISK_PASSPHRASE_HELP__/$passphrase_help/; + return $html; + }, + ); set_next( undef, @@ -1384,6 +1428,22 @@ sub create_password_view { return; } + if (defined($enc)) { + my $pp = $epe1->get_text() // ''; + eval { + Proxmox::Install::assert_disk_passphrase($pp); + die "the disk passphrases do not match\n" + if $pp ne ($epe2->get_text() // ''); + }; + if (my $err = $@) { + Proxmox::UI::message(ucfirst($err)); + $epe1->grab_focus(); + return; + } + $enc->{passphrase} = $pp; + Proxmox::Install::Config::set_encryption($enc); + } + Proxmox::Install::Config::set_root_password('plain', $t1); Proxmox::Install::Config::set_mailto($t3); @@ -1574,6 +1634,14 @@ sub create_country_view { my $target_hd_combo; my $target_hd_label; +my $encryption_hint_label; + +# the encryption option is in the options dialog, so the disk page shows its state +my sub update_encryption_hint { + return if !$encryption_hint_label; + my $enabled = defined(Proxmox::Install::Config::get_encryption()); + $encryption_hint_label->set_text($enabled ? 'Encryption: ' . encryption_desc() : ''); +} my $hdoption_first_setup = 1; @@ -1894,6 +1962,18 @@ sub create_hdoption_view { $grid->attach($fstypecb, 1, $row, 1, 1); + # the passphrase is asked on the password page, after the keyboard layout is set + my $encrypt_cb; + if (Proxmox::Install::RunEnv::get()->{boot_type} eq 'efi') { + $row++; + my $encrypt_label = Gtk3::Label->new("Encryption"); + $encrypt_label->set_xalign(1.0); + $grid->attach($encrypt_label, 0, $row, 1, 1); + $encrypt_cb = Gtk3::CheckButton->new_with_label("Passphrase at boot"); + $encrypt_cb->set_active(defined(Proxmox::Install::Config::get_encryption())); + $grid->attach($encrypt_cb, 1, $row, 1, 1); + } + $hbox2->show_all(); $row++; @@ -2131,6 +2211,14 @@ sub create_hdoption_view { Proxmox::Install::Config::set_maxvz(undef); } + if ($encrypt_cb && $encrypt_cb->get_active()) { + my $previous = Proxmox::Install::Config::get_encryption() // {}; + Proxmox::Install::Config::set_encryption({ passphrase => $previous->{passphrase} }); + } else { + Proxmox::Install::Config::set_encryption(undef); + } + update_encryption_hint(); + $dialog->destroy(); } @@ -2194,6 +2282,10 @@ sub create_hdsel_view { $options->signal_connect(clicked => \&create_hdoption_view); $hbox->pack_start($options, 0, 0, 0); + $encryption_hint_label = Gtk3::Label->new(); + $hbox->pack_start($encryption_hint_label, 0, 0, 10); + update_encryption_hint(); + $gtk_state->{inbox}->show_all; Proxmox::UI::display_html('page1.htm'); @@ -2204,7 +2296,10 @@ sub create_hdsel_view { my $filesys = Proxmox::Install::Config::get_filesys(); if ($filesys =~ m/zfs/) { apply_raid_disk_selection(); - my ($devlist) = eval { Proxmox::Install::get_zfs_raid_setup() }; + my ($devlist) = eval { + Proxmox::Install::assert_zfs_encryption_copies(); + Proxmox::Install::get_zfs_raid_setup(); + }; if (my $err = $@) { Proxmox::UI::message("$err"); return; diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs index c9ee7192..e3ccf452 100644 --- a/proxmox-installer-common/src/options.rs +++ b/proxmox-installer-common/src/options.rs @@ -259,6 +259,8 @@ pub struct BootdiskOptions { pub disks: Vec, pub fstype: FilesystemType, pub advanced: AdvancedBootdiskOptions, + /// Whether to encrypt the system disks, LUKS2 or native ZFS encryption, as per `fstype`. + pub encrypt: bool, } impl BootdiskOptions { @@ -267,6 +269,7 @@ impl BootdiskOptions { disks: vec![disk.clone()], fstype: FilesystemType::Ext4, advanced: AdvancedBootdiskOptions::Lvm(LvmBootdiskOptions::defaults_from(disk)), + encrypt: false, } } } diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs index f7643b71..450f61ce 100644 --- a/proxmox-tui-installer/src/main.rs +++ b/proxmox-tui-installer/src/main.rs @@ -21,7 +21,7 @@ use proxmox_installer_common::{ }, setup::{LocaleInfo, RuntimeInfo, SetupInfo, installer_setup}, }; -use proxmox_installer_types::ProxmoxProduct; +use proxmox_installer_types::{ProxmoxProduct, answer::DiskEncryption}; mod options; use options::{InstallerOptions, PasswordOptions}; @@ -145,6 +145,8 @@ struct InstallerState { runtime_info: RuntimeInfo, locales: LocaleInfo, steps: HashMap, + /// The cached password screen lacks or has superfluous disk encryption fields. + password_screen_stale: bool, in_test_mode: bool, } @@ -185,6 +187,7 @@ fn main() { runtime_info, locales, steps: HashMap::new(), + password_screen_stale: false, in_test_mode, }); @@ -262,10 +265,13 @@ fn switch_to_next_screen( // replace it if the screen is switched to. // TODO: Could be done by e.g. having all the main dialog views implement some sort of // .refresh(), which can be called if the view is switched to. - if step == InstallerStep::Summary { + if step == InstallerStep::Summary + || (step == InstallerStep::Password && state.password_screen_stale) + { let view = constructor(siv); siv.screen_mut().pop_layer(); siv.screen_mut().add_layer(view); + siv.with_user_data(|state: &mut InstallerState| state.password_screen_stale = false); } return; @@ -391,6 +397,11 @@ fn bootdisk_dialog(siv: &mut Cursive) -> InstallerView { match options { Some(Ok(options)) => { siv.with_user_data(|state: &mut InstallerState| { + if options.encrypt != state.options.bootdisk.encrypt + && state.steps.contains_key(&InstallerStep::Password) + { + state.password_screen_stale = true; + } state.options.bootdisk = options; }); @@ -435,22 +446,44 @@ fn password_dialog(siv: &mut Cursive) -> InstallerView { let state = siv.user_data::().unwrap(); let options = &state.options.password; - let inner = FormView::<()>::new() + let mut inner = FormView::<()>::new() .child( "Root password [at least 8 characters]", - EditView::new().secret(), + EditView::new().secret().content(&options.root_password), + ) + .child( + "Confirm root password", + EditView::new().secret().content(&options.root_password), ) - .child("Confirm root password", EditView::new().secret()) .child( "Administrator email", EditView::new().content(&options.email), - ) - .with_name("password-options"); + ); + // asked here, so that it is typed with the keyboard layout the boot prompt uses + if state.options.bootdisk.encrypt { + inner.add_child( + "Disk passphrase", + EditView::new() + .secret() + .content(&options.encryption_passphrase), + ); + inner.add_child( + "Confirm disk passphrase", + EditView::new() + .secret() + .content(&options.encryption_passphrase), + ); + } + let inner = inner.with_name("password-options"); InstallerView::new( state, inner, Box::new(|siv| { + let encrypt = siv + .user_data::() + .is_some_and(|state| state.options.bootdisk.encrypt); + let options = siv.call_on_name("password-options", |view: &mut FormView| { let root_password = view .get_value::(0) @@ -471,9 +504,20 @@ fn password_dialog(siv: &mut Cursive) -> InstallerView { } else if let Err(err) = email_validate(&email) { Err(err.to_string()) } else { + let mut encryption_passphrase = String::new(); + if encrypt { + encryption_passphrase = view + .get_value::(3) + .ok_or("failed to retrieve disk passphrase")?; + let confirm = view + .get_value::(4) + .ok_or("failed to retrieve disk passphrase confirmation")?; + check_encryption_passphrase(&encryption_passphrase, &confirm)?; + } Ok(PasswordOptions { root_password, email, + encryption_passphrase, }) } }); @@ -494,6 +538,16 @@ fn password_dialog(siv: &mut Cursive) -> InstallerView { ) } +/// Same rules as the installer's preflight check, so a mistake shows while it can still be fixed. +fn check_encryption_passphrase(passphrase: &str, confirm: &str) -> Result<(), String> { + DiskEncryption::check_passphrase(passphrase) + .map_err(|reason| format!("disk passphrase {reason}"))?; + if passphrase != confirm { + return Err("disk passphrases do not match".to_owned()); + } + Ok(()) +} + fn network_dialog(siv: &mut Cursive) -> InstallerView { let state = siv.user_data::().unwrap(); let options = &state.options.network; diff --git a/proxmox-tui-installer/src/options.rs b/proxmox-tui-installer/src/options.rs index 573a4ceb..a4ce43d4 100644 --- a/proxmox-tui-installer/src/options.rs +++ b/proxmox-tui-installer/src/options.rs @@ -4,12 +4,27 @@ use proxmox_installer_common::{ options::{BootdiskOptions, NetworkOptions, TimezoneOptions}, setup::{LocaleInfo, NetworkInfo, RuntimeInfo}, }; -use proxmox_installer_types::{EMAIL_DEFAULT_PLACEHOLDER, answer::NetworkBondOptions}; +use proxmox_installer_types::{ + EMAIL_DEFAULT_PLACEHOLDER, EncryptionMode, answer::NetworkBondOptions, +}; + +/// How the system disks get encrypted, as shown on the disk page and in the summary. +pub fn encryption_summary(bootdisk: &BootdiskOptions) -> &'static str { + if !bootdisk.encrypt { + return "none"; + } + match EncryptionMode::for_filesystem(bootdisk.fstype) { + EncryptionMode::Luks => "LUKS2", + EncryptionMode::ZfsNative => "native ZFS encryption", + } +} #[derive(Clone)] pub struct PasswordOptions { pub email: String, pub root_password: String, + /// Only used if the system disks get encrypted. + pub encryption_passphrase: String, } impl Default for PasswordOptions { @@ -17,6 +32,7 @@ impl Default for PasswordOptions { Self { email: EMAIL_DEFAULT_PLACEHOLDER.to_string(), root_password: String::new(), + encryption_passphrase: String::new(), } } } @@ -49,6 +65,7 @@ impl InstallerOptions { let mut summary = vec![ SummaryOption::new("Bootdisk filesystem", self.bootdisk.fstype.to_string()), + SummaryOption::new("Disk encryption", encryption_summary(&self.bootdisk)), SummaryOption::new( "Bootdisk(s)", self.bootdisk diff --git a/proxmox-tui-installer/src/setup.rs b/proxmox-tui-installer/src/setup.rs index fc3c43df..08eb929d 100644 --- a/proxmox-tui-installer/src/setup.rs +++ b/proxmox-tui-installer/src/setup.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; use crate::options::InstallerOptions; use proxmox_installer_common::{ options::AdvancedBootdiskOptions, - setup::{InstallConfig, InstallFirstBootSetup, InstallRootPassword}, + setup::{InstallConfig, InstallEncryption, InstallFirstBootSetup, InstallRootPassword}, }; impl From for InstallConfig { @@ -80,6 +80,12 @@ impl From for InstallConfig { } } + if options.bootdisk.encrypt { + config.encryption = Some(InstallEncryption { + passphrase: options.password.encryption_passphrase.clone(), + }); + } + config } } diff --git a/proxmox-tui-installer/src/views/bootdisk.rs b/proxmox-tui-installer/src/views/bootdisk.rs index a0267f14..18775e77 100644 --- a/proxmox-tui-installer/src/views/bootdisk.rs +++ b/proxmox-tui-installer/src/views/bootdisk.rs @@ -9,13 +9,13 @@ use cursive::{ Cursive, Vec2, View, view::{Nameable, Resizable, ViewWrapper}, views::{ - Button, Dialog, DummyView, LinearLayout, NamedView, PaddedView, Panel, ScrollView, - SelectView, TextView, ViewRef, + Button, Checkbox, Dialog, DummyView, LinearLayout, NamedView, PaddedView, Panel, + ScrollView, SelectView, TextView, ViewRef, }, }; use super::{DiskSizeEditView, FormView, IntegerEditView, TabbedView}; -use crate::InstallerState; +use crate::{InstallerState, options::encryption_summary}; use proxmox_installer_common::{ disk_checks::{ @@ -50,6 +50,8 @@ pub struct BootdiskOptionsView { } impl BootdiskOptionsView { + const ENCRYPTION_HINT_VIEW_ID: &'static str = "bootdisk-options-encryption-hint"; + pub fn new(siv: &mut Cursive, runinfo: &RuntimeInfo, options: &BootdiskOptions) -> Self { let advanced_options = Arc::new(Mutex::new(options.clone())); @@ -92,7 +94,10 @@ impl BootdiskOptionsView { let view = LinearLayout::vertical() .child(bootdisk_form) .child(DummyView) - .child(advanced_button); + .child(advanced_button) + .child( + TextView::new(encryption_hint(options)).with_name(Self::ENCRYPTION_HINT_VIEW_ID), + ); let boot_type = siv .user_data::() @@ -156,9 +161,17 @@ impl AdvancedBootdiskOptionsView { } }); + let mut form = FormView::<()>::new().child("Filesystem", fstype_select); + // the passphrase is asked on the password page, after the keyboard layout is set + if runinfo.boot_type == BootType::Efi { + form.add_child( + "Encryption (passphrase at boot)", + Checkbox::new().with_checked(options.encrypt), + ); + } let mut view = LinearLayout::vertical() .child(DummyView.full_width()) - .child(FormView::<()>::new().child("Filesystem", fstype_select)) + .child(form) .child(DummyView.full_width()); // Create the appropriate (inner) advanced options view @@ -264,6 +277,12 @@ impl AdvancedBootdiskOptionsView { .and_then(|v| v.downcast_ref::()) .and_then(|v| v.get_value::, _>(0)) .ok_or("Failed to retrieve filesystem type".to_owned())?; + let encrypt = self + .view + .get_child(1) + .and_then(|v| v.downcast_ref::()) + .and_then(|v| v.get_value::(1)) + .unwrap_or(false); let advanced = self .view @@ -283,6 +302,7 @@ impl AdvancedBootdiskOptionsView { disks: vec![disk], fstype, advanced: AdvancedBootdiskOptions::Lvm(advanced), + encrypt, }) } else if let Some(view) = advanced.downcast_mut::() { let (disks, advanced) = view @@ -294,11 +314,16 @@ impl AdvancedBootdiskOptionsView { .check_raid_disks_setup(&disks) .map_err(|err| format!("{fstype}: {err}"))?; } + // OpenZFS stores encryption metadata where the third copy of a block would go. + if encrypt && advanced.copies > 2 { + return Err("native ZFS encryption allows at most 2 copies".to_owned()); + } Ok(BootdiskOptions { disks, fstype, advanced: AdvancedBootdiskOptions::Zfs(advanced), + encrypt, }) } else if let Some(view) = advanced.downcast_mut::() { let (disks, advanced) = view @@ -315,6 +340,7 @@ impl AdvancedBootdiskOptionsView { disks, fstype, advanced: AdvancedBootdiskOptions::Btrfs(advanced), + encrypt, }) } else { Err("Invalid bootdisk view state".to_owned()) @@ -799,6 +825,10 @@ fn advanced_options_view( } siv.pop_layer(); + siv.call_on_name( + BootdiskOptionsView::ENCRYPTION_HINT_VIEW_ID, + |view: &mut TextView| view.set_content(encryption_hint(&options)), + ); *options_ref.lock().unwrap() = options; } }) @@ -806,6 +836,15 @@ fn advanced_options_view( .max_size((120, 40)) } +/// The encryption option is in the advanced options dialog, so the disk page shows its state. +fn encryption_hint(options: &BootdiskOptions) -> String { + if options.encrypt { + format!("Encryption: {}", encryption_summary(options)) + } else { + String::new() + } +} + /// Creates a select view for all disks specified. /// /// # Arguments diff --git a/proxmox-tui-installer/src/views/mod.rs b/proxmox-tui-installer/src/views/mod.rs index a99bd849..09cc9456 100644 --- a/proxmox-tui-installer/src/views/mod.rs +++ b/proxmox-tui-installer/src/views/mod.rs @@ -399,6 +399,12 @@ impl FormViewGetValue for EditView { } } +impl FormViewGetValue for Checkbox { + fn get_value(&self) -> Option { + Some(self.is_checked()) + } +} + impl FormViewGetValue for SelectView { fn get_value(&self) -> Option { self.selection().map(|v| (*v).clone()) -- 2.47.3