fix(luks): surface cryptsetup error output when unlock fails (#4570)

Luks2.unlock() ran 'cryptsetup open' with no error handling, so a failure raised a bare CalledProcessError. Python renders that exception with only the exit status and discards the captured output, so cryptsetup's stderr (merged into stdout by run()) never reached the install log.

encrypt() already wraps its cryptsetup call and raises a DiskError that includes the captured output. Mirror that for unlock() so a failure reports the actual cryptsetup message instead of an opaque traceback.

Reported in #4327, where the underlying 'device-mapper: crypt: unknown table type' error was hidden from the log for this reason.
This commit is contained in:
Clinton Phillips 2026-06-06 04:38:36 -04:00 committed by GitHub
parent d38008483e
commit 7b8fec1af4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -149,7 +149,11 @@ class Luks2:
'luks2',
]
result = run(cmd, input_data=passphrase)
try:
result = run(cmd, input_data=passphrase)
except CalledProcessError as err:
output = err.stdout.decode().rstrip()
raise DiskError(f'Could not unlock luks2 device "{self.luks_dev_path}": {output}')
debug(f'cryptsetup open output: {result.stdout.decode().rstrip()}')