Skip to content

Commit 93c62d1

Browse files
committed
make reset command usage more generalized
Signed-off-by: Zen <[email protected]>
1 parent 5b70c48 commit 93c62d1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/ugrd/crypto/cryptsetup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "3.2.3"
2+
__version__ = "3.2.4"
33

44
from pathlib import Path
55

@@ -311,23 +311,26 @@ def open_crypt_device(self, name: str, parameters: dict) -> list[str]:
311311
" fi",
312312
]
313313

314+
315+
reset_command = parameters.get("reset_command", 'continue')
314316
# When there is a key command, evaluate it into $key_data
315317
if "key_command" in parameters:
316318
self.logger.debug("[%s] Using key command: %s" % (name, parameters["key_command"]))
317319
out += [
318320
f" einfo 'Attempting to open LUKS key: {parameters['key_file']}'",
319321
f" edebug 'Using key command: {parameters['key_command']}'",
320322
]
323+
321324
if "plymouth_key_command" in parameters and "ugrd.base.plymouth" in self["modules"]:
322325
out += [
323326
" if plymouth --ping; then",
324-
f' plymouth ask-for-password --prompt "[${{i}} / {retries}] Enter passphrase to unlock key for: {name}" --command "{parameters["plymouth_key_command"]}" --number-of-tries 1 > /run/vars/key_data || continue',
327+
f' plymouth ask-for-password --prompt "[${{i}} / {retries}] Enter passphrase to unlock key for: {name}" --command "{parameters["plymouth_key_command"]}" --number-of-tries 1 > /run/vars/key_data || {reset_command}',
325328
" else",
326-
f' {parameters["key_command"]} > /run/vars/key_data || continue',
329+
f' {parameters["key_command"]} > /run/vars/key_data || {reset_command}',
327330
" fi",
328331
]
329332
else:
330-
out += [f" {parameters['key_command']} > /run/vars/key_data || continue"]
333+
out += [f" {parameters['key_command']} > /run/vars/key_data || {reset_command}"]
331334

332335
cryptsetup_command = "cryptsetup open --tries 1" # Set tries to 1 since it runs in the loop
333336
cryptsetup_target = f'"$crypt_dev" {name}' # Add a variable for the source device and mapped name
@@ -364,7 +367,7 @@ def open_crypt_device(self, name: str, parameters: dict) -> list[str]:
364367
if not self["cryptsetup_autoretry"]:
365368
out += [' prompt_user "Press enter to retry"']
366369
# Add the reset command if it exists
367-
if reset_command := parameters.get("reset_command"):
370+
if reset_command != "continue":
368371
out += [' einfo "Running key reset command"', f" {reset_command}"]
369372
out += ["done\n"]
370373

0 commit comments

Comments
 (0)