Fix luks save_passphrase for missing format context

Resolves: RHEL-142610
This commit is contained in:
Vojtech Trefny 2026-01-20 16:26:22 +01:00
parent b8fefd83a2
commit f661e63899
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 80583b52f4683a05810d2f8f5ab74417d16edcaa Mon Sep 17 00:00:00 2001
From: Radek Vykydal <rvykydal@redhat.com>
Date: Fri, 24 Oct 2025 14:04:36 +0200
Subject: [PATCH 1/2] Fix luks save_passphrase for missing format context
Resolves: RHEL-142610
---
blivet/static_data/luks_data.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blivet/static_data/luks_data.py b/blivet/static_data/luks_data.py
index 3e4cc2a0e..6bb9d1399 100644
--- a/blivet/static_data/luks_data.py
+++ b/blivet/static_data/luks_data.py
@@ -86,7 +86,7 @@ def add_passphrases(self, passphrases):
def save_passphrase(self, device):
""" Save a device's LUKS passphrase in case of reset. """
pctx = device.format.contexts.get_context("passphrase")
- passphrase = pctx._passphrase
+ passphrase = pctx and pctx._passphrase
if passphrase:
luks_data.luks_devs[device.format.uuid] = passphrase
self.add_passphrase(passphrase)
From 317ddb4bb15f3b01bc66ce22bdece274b43fb6dc Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 29 Oct 2025 10:20:32 +0100
Subject: [PATCH 2/2] tests: Add check for saving passphrase with context not
set
Related: RHEL-142610
---
tests/storage_tests/formats_test/luks_test.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/storage_tests/formats_test/luks_test.py b/tests/storage_tests/formats_test/luks_test.py
index b42cacddd..3eb62ba66 100644
--- a/tests/storage_tests/formats_test/luks_test.py
+++ b/tests/storage_tests/formats_test/luks_test.py
@@ -304,6 +304,10 @@ def test_luks_save_passphrase(self):
self.assertIsNotNone(disk)
self.assertTrue(disk.format.has_key)
+ # remove passphrase and try to save it (should not fail)
+ disk.format.passphrase = None
+ blivet.static_data.luks_data.save_passphrase(disk)
+
def test_label_subsystem(self):
disk = self.storage.devicetree.get_device_by_path(self.vdevs[0])
self.assertIsNotNone(disk)

View File

@ -5,7 +5,7 @@ Version: 3.13.0
#%%global prerelease .b2
# prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2
Release: 3%{?prerelease}%{?dist}
Release: 4%{?prerelease}%{?dist}
Epoch: 1
License: LGPL-2.1-or-later
%global realname blivet
@ -18,6 +18,7 @@ Patch0: 0001-remove-btrfs-plugin.patch
%endif
Patch2: 0002-iSCSI-dont-crash-when-LUN-ID-256.patch
Patch3: 0003-Fix-luks-save_passphrase-for-missing-format-context.patch
# Versions of required components (done so we make sure the buildrequires
# match the requires versions of things).
@ -115,6 +116,10 @@ make DESTDIR=%{buildroot} install
%{python3_sitelib}/*
%changelog
* Tue Jan 20 2026 Vojtech Trefny <vtrefny@redhat.com> - 3.13.0-4
- Fix luks save_passphrase for missing format context
Resolves: RHEL-142610
* Mon Nov 03 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.13.0-3
- iSCSI: don't crash when LUN ID >= 256
Resolves: RHEL-122305