Skip to content

Commit a91c238

Browse files
committed
simplfiy key command usage
Signed-off-by: Zen <[email protected]>
1 parent 9279da4 commit a91c238

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

src/ugrd/crypto/cryptsetup.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '2.1.0'
2+
__version__ = '2.2.0'
33

44
from zenlib.util import check_dict
55

@@ -187,23 +187,6 @@ def _validate_crypysetup_key(self, key_paramters: dict) -> None:
187187
key_copy = parent
188188

189189

190-
def open_crypt_key(self, name: str, parameters: dict) -> tuple[list[str], str]:
191-
"""
192-
Returns a tuple of bash lines and the path to the key file
193-
Returns bash lines to open a luks key and output it to specified key file
194-
"""
195-
if parameters.get('key_file'):
196-
_validate_crypysetup_key(self, parameters)
197-
else:
198-
raise ValueError("Key file must be specified for cryptsetup mount: %s" % name)
199-
key_path = f"/run/vars/key_{name}"
200-
201-
out = [f" einfo 'Attempting to open luks key for {name}'"]
202-
out += [f' {parameters["key_command"]} "{key_path}"']
203-
204-
return out, key_path
205-
206-
207190
def open_crypt_device(self, name: str, parameters: dict) -> list[str]:
208191
""" Returns a bash script to open a cryptsetup device. """
209192
self.logger.debug("[%s] Processing cryptsetup volume: %s" % (name, parameters))
@@ -215,9 +198,9 @@ def open_crypt_device(self, name: str, parameters: dict) -> list[str]:
215198
# When there is a key command, read from the named pipe and use that as the key
216199
if 'key_command' in parameters:
217200
self.logger.debug("[%s] Using key command: %s" % (name, parameters['key_command']))
218-
out_line, key_name = open_crypt_key(self, name, parameters)
219-
out += out_line
220-
cryptsetup_command = f'cryptsetup open --key-file {key_name}'
201+
out += [f" einfo 'Attempting to open LUKS key: {parameters['key_file']}'",
202+
f" edebug 'Using key command: {parameters['key_command']}'"]
203+
cryptsetup_command = f'{parameters["key_command"]} | cryptsetup open --key-file -'
221204
elif 'key_file' in parameters:
222205
self.logger.debug("[%s] Using key file: %s" % (name, parameters['key_file']))
223206
_validate_crypysetup_key(self, parameters)

src/ugrd/crypto/gpg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ opt_dependencies = [ '/usr/libexec/keyboxd' ] # Pull keyboxd in as an optional
55

66

77
[cryptsetup_key_types.gpg]
8-
key_command = "gpg --decrypt {key_file} >"
8+
key_command = "gpg --decrypt {key_file}"
99

1010
[symlinks.pinentry]
1111
source = "/usr/bin/pinentry-tty"

0 commit comments

Comments
 (0)